-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deduplicate cache fill requests to avoid cache stampede in proxy #308
Comments
Totally agree. Taking inspiration from https://github.com/golang/groupcache, I have a rough proposal (which I'm pretty sure needs work!). The basic idea is that we build a distributed lease on which any process can watch for release events. Then, when a server receives a
These are leases and not locks, so they should have timeouts. So a few notes:
Some implementation notes on the distributed lease table:
|
I'm hesitant to put the fetch logic on the request side of the interaction. If we keep the fetch on the storage side, we can keep the retry logic there. That also allows us to register failed requests to a background worker that performs the retry with back-off and/or fill from elsewhere in the athens system. As a wrapper around the storage backend, the "cache-warmer" would implement
All of this can live between the storage backend interface and the selected backend, giving us flexibility to change how we fill the cache and return results. I think if we focus on deduplication at the instance level, we can scale that out with distributed leases across larger deployments later. We'll already be reducing the traffic on the VCS site by doing so, while getting the single-instance proxy ready for users to test locally and in-org. |
I'd like to grab this if no one has worked on it yet. PS. This is the package you're talking about @arschles right? https://github.com/golang/groupcache/tree/master/singleflight |
we should think whether or not proxy will be scaled 1:1 with underlying DB. |
@michalpristas does the proxy need to be scalable? It's meant to run internally and so 1 instance of the proxy server seems ok to me for MVP. But happy to do a distributed lock thing if people wanna scale the proxy, sounds more fun to implement anyway :) |
that's the question. we should elaborate more on that. |
Large and heavily-used projects will have users with automated update mechanisms, leading to a flood of requests for the newest tag. Proxy & Olympus need to be able to identify duplicate requests and only fill cache from VCS once.
Initially, we can simply block all duplicate requests until the module is downloaded (#290), but this will become more complicated when working with streams (#281).
The text was updated successfully, but these errors were encountered: