Cache github api requests in ApplicationSet #11376
Labels
component:application-sets
Bulk application management related
enhancement
New feature or request
type:scalability
Issues related to scalability and performance related issues
Summary
Make the github api client used by ApplicationSet cache responses.
Motivation
Using an
scm_provider
generator withallBranches
leads to a lot of queries to the GitHub API. This takes some time and eats through GitHub's rate limit.We can save time and rate limit by caching responses and using the
If-None-Match
andIf-Modified-Since
headers to check whether the cached response is up to date. This is described in GitHub's api documentation here: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requestsProposal
I propose using https://github.com/gregjones/httpcache and https://github.com/die-net/lrucache to implement the cache.
httpcache
provides an http transport that does the header checks and wraps a cache.lrucache
is an in-memory least-recently-used cache made to be used with httpcache. I have used this combination with the go-github client successfully other projects.An environment variable
ARGOCD_APPLICATIONSET_CONTROLLER_GITHUB_CLIENT_CACHE_SIZE
can be added to set the cache size. If it is unset, no cache will be used. Otherwise an LRU cache will be created with the given size in kilobytes.This is what the code might look like:
AWholeNewOrg@7516d64?w=1
The text was updated successfully, but these errors were encountered: