-
Notifications
You must be signed in to change notification settings - Fork 499
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
Horizon Lite: Automate ledger cache management for the web service. #4526
Comments
@Shaptic , wanted to confirm on scope, this would be one new startup parameter to the horizon light web server, like |
That's a great question 🤔 I don't think starting at the earliest available ledger is a good idea. Based on our research, recent ledgers make much more sense to cache up-front. Perhaps we can do something like As for async/parallel, my perspective was more that it happens before the web server launches, i.e. if you want to deploy the webserver, it first loads X ledgers into the cache, then starts the webserver. So it's almost part of the provisioning/installation/setup step of deployment. I'm concerned about synchronization and race conditions issues if it's done in parallel to serving requests. |
I think (if possible) it would be better for it to happen in the background after the webserver is launched. That way you can launch quickly, and still have a hot cache. Though that might be more complicated, as you would be serving requests so you'd want those cache fills to take precendent so they don't get evicted. If the operator is concerned about cache latency they could use a ramp-up or delay config option in their load-balancer (I forget what HAProxy calls this). But IMO it is better to be serving requests slowly than refusing until the cache is populated (which may or may not even help, depending on the queries). As for what to populate initially, for the default we use 90 days of ledgers. so maybe the latest 90 days? or maybe even just the latest 30 days, then start serving requests? Depending on cache size it could be |
If you want to do it at the start, k8s supports init containers https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ This means that as long as the tool is containerized, you don’t need do any any further scripting or embed the command in horizon light itself |
@Shaptic , any thoughts on lightweight/fast approaches for getting the 'latest' indexed ledger from the index store. I see the explorer tool |
You're right, @sreuland, it's pretty much impossible without changes to the index builder (hence the necessity for the tool). I think the initial design meant that the ledger source and the index source were "in sync," but otherwise it's not feasible without additional metadata. |
A crucial part of getting Horizon Lite to an acceptable level of performance is caching ledgers locally to avoid latency spikes from downloading ledgers.
There's a toolkit to "pre-load" the cache in addition to the existing behavior of caching ledgers on use, e.g.:
This same process should be done in parallel on startup of the web service if a parameter is provided, and it should subsequently be integrated into the k8s deployment.
Acceptance Criteria
Sub tasks
--preload-cache=<count>
flag support to web server startup params, k8s manifest, @sreulandThe text was updated successfully, but these errors were encountered: