elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.73k stars 8.14k forks source link

Expensive queries are causing unnecessary load and delays on Elasticsearch #93770

Open rudolf opened 3 years ago

rudolf commented 3 years ago

Until https://github.com/elastic/kibana/pull/89915 (v7.12.0) saved objects didn't support paging through large result sets. Now that we have _search_after support, plugins who previously paged through "all" results by setting size: 10000 should be refactored to use search after instead.

The problem with creating searches with large batches of 10000 is that it blocks the Elasticsearch thread pool for a long time which negatively impacts the performance of other search queries. Since Kibana started using system indices for the saved objects index in 7.11, this has had a much bigger impact because these searches share a thread pool with the security index. Paging with smaller batches means faster responses per request, allowing the thread pool to interleave Kibana searches with other requests.

In addition to the performance impact on Elasticsearch, large searches also mean large response payloads which blocks the Kibana thread for an extended amount of time. This causes spikes in the event loop delay which impacts the performance of all plugins.

Short term: fix all 10k searches against the saved object indices

The following is a list of plugins performing searches with perPage: 10000. Please audit each occurrence and mark the task as complete with a link to the PR once it has been resolved. These links are based on a quick search, if the linked code isn't searching against a saved objects index with size > 1000 please mark the item as done.

Blocked on https://github.com/elastic/kibana/issues/91175 because that will make it significantly easier for teams to address these issues. Done. Here are docs on the new point-in-time finder.

Medium term

elasticmachine commented 3 years ago

Pinging @elastic/kibana-core (Team:Core)

lukeelmers commented 3 years ago

https://github.com/elastic/kibana/issues/91175 has been addressed, so teams should now be unblocked on moving forward with the short-term fixes outlined here.

smith commented 3 years ago

None of the APM items listed are querying saved object indices. Checked them off.

alexwizp commented 3 years ago

changes related to the KibanaApp team are ready (#99031, #99023, #98914, #98903) but blocked by #99044

afharo commented 2 years ago

All the items for @elastic/kibana-telemetry are listed in #96715. We'll try to prioritize them.

yctercero commented 2 years ago

Just FYI, security solution platform has this ticket we've been trying to get to of moving over to PIT - https://github.com/elastic/kibana/issues/103944

afharo commented 2 years ago

All the @elastic/kibana-telemetry items are handled in https://github.com/elastic/kibana/pull/135689