-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Cache usage data to prevent expensive collection queries #117084
Comments
Pinging @elastic/kibana-core (Team:Core) |
As a first step, we could use an in-memory only cache, meaning if there's more than one Kibana server each server will repeat the usage collection. It might be worth creating a usage collection task that runs every X hours, and stores its results in a document with a last updated value. Kibana could then just read whatever is in the document. But this document would be quite large (I've seen > 37MB) so we would have to exclude it from e.g. saved object migrations. |
Beats might be using the API so check the impact it might have on that integration. |
Seems good enough for an initial implementation.
I'm sorry, I tried to find where this was done in the code, but couldn't find it. Is this performed at a fixed time (e.g same time every day for each browser session), or is the browser sending the data 24h after their initial load? Asking because depending on this, caching the data on the server-side may be harder, or at least we need a lower TTL for the cache. |
We try to send usage data and if successful store the timestamp in localstorage. Every minute that the browser is open we check if 24 hours has expired since the last success timestamp. Given the urgency simple server-side caching is a good first step but I think we can do more here like ask browsers to report to the server if they successfully sent a payload. If one browser session sent usage data we don't need the other browsers to also send it. So once every 24hours the browser could ask the server "has anyone sent telemetry?" if the answer is no the browser tries, sometimes multiple browsers will do so in parallel but that's fine, at least not all e.g. 100 users of this cluster are trying to send the same payload. |
Given that the browser retries every 60s and that usage collection could theoretically take longer than 60s to complete, we should also consider what will happen if the cache isn't primed. In such a case we would want to start usage collection only once regardless of how many browsers are requesting it. |
Hi Rudolf, I highly recommend making the cache refresh time configurable so that everyone can adjust its value according to their environment |
Every browser session will request usage data every 24 hours. In large clusters collecting usage data leads to expensive Elasticsearch queries and large response payloads which affect the performance of both Elasticsearch and Kibana #93770
When Elasticsearch / Kibana performance is degraded these expensive queries take longer to complete causing timeouts and then each browser retries the request #115221.
Instead of collecting this usage data for every browser session requesting it, we should cache this data server side.
The text was updated successfully, but these errors were encountered: