Skip to content
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

[Fleet] Improve performance of data stream API #97058

Merged
merged 3 commits into from
Apr 14, 2021

Conversation

jen-huang
Copy link
Contributor

Summary

Resolves #97044. This PR improves the performance of GET /api/fleet/data_streams endpoint. Previously, we were retrieving dashboard information for each package, one dashboard ID at a time. This caused the endpoint to become slower and slower as the number of data streams/installed packages grew. And in some cases with unluckly timing against other ES operations/searches, this can cause the endpoint to time out or throw a 500 search_phase_execution_exception error.

With this PR, we retrieve dashboard information for all installed packages with one call upfront, and map the results for fast lookup in downstream operations. In my testing of 116 data streams, with 4 packages installed, this reduced the average response time from 2.5s to 180ms, more than 10x improvement:

Before
image

After
image

@jen-huang jen-huang added release_note:fix v8.0.0 Team:Fleet Team label for Observability Data Collection Fleet team v7.13.0 v7.12.1 labels Apr 13, 2021
@jen-huang jen-huang self-assigned this Apr 13, 2021
@jen-huang jen-huang requested a review from a team as a code owner April 13, 2021 22:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Contributor

@jfsiii jfsiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left two comments, but nothing blocking.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jen-huang

@jen-huang jen-huang merged commit 39e4ea8 into elastic:master Apr 14, 2021
@jen-huang jen-huang added the auto-backport Deprecated - use backport:version if exact versions are needed label Apr 14, 2021
@jen-huang jen-huang deleted the fix/97044 branch April 14, 2021 03:52
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 14, 2021
* Improve performance of data stream API

* Remove extra logger, replace filter with reduce

* Remove unused import
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.12 Commit could not be cherrypicked due to conflicts
7.x

Successful backport PRs will be merged automatically after passing CI.

To backport manually run:
node scripts/backport --pr 97058

jen-huang added a commit to jen-huang/kibana that referenced this pull request Apr 14, 2021
* Improve performance of data stream API

* Remove extra logger, replace filter with reduce

* Remove unused import
# Conflicts:
#	x-pack/plugins/fleet/server/routes/data_streams/handlers.ts
#	x-pack/plugins/fleet/server/services/epm/packages/get.ts
kibanamachine added a commit that referenced this pull request Apr 14, 2021
* Improve performance of data stream API

* Remove extra logger, replace filter with reduce

* Remove unused import

Co-authored-by: Jen Huang <its.jenetic@gmail.com>
jen-huang added a commit that referenced this pull request Apr 14, 2021
* Improve performance of data stream API

* Remove extra logger, replace filter with reduce

* Remove unused import
# Conflicts:
#	x-pack/plugins/fleet/server/routes/data_streams/handlers.ts
#	x-pack/plugins/fleet/server/services/epm/packages/get.ts
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 14, 2021
…ax_primary_shard_size

* 'master' of github.com:elastic/kibana: (99 commits)
  added missing optional chain for bracket notation (elastic#96939)
  [Discover][DocViewer] Fix toggle columns from doc viewer table tab (elastic#95748)
  [TSVB] Fix per-request caching of index patterns (elastic#97043)
  [Datatable] Fix filter cell flakiness (elastic#96934)
  Unskip heatmap suite and fixes flakiness (elastic#96941)
  [Fleet] Improve performance of data stream API (elastic#97058)
  [ML] Data Frame Analytics: remove beta badge (elastic#96977)
  [App Search] Migrate expanded rows for meta engines table in Engines Overview (elastic#96251)
  Instances latency distribution chart tooltips and axis fixes (elastic#95577)
  [Monitoring] Using primary average shard size (elastic#96177)
  [Workplace Search] Hide Kibana chrome on 3rd party connector redirects (elastic#97028)
  ## [Security Solution] Fixes `Exit full screen` and `Copy to cliboard` styling issues (elastic#96676)
  Index pattern field editor - Add warning on name or type change (elastic#95528)
  [App Search] Add small engine breadcrumb utility helper (elastic#96917)
  Copy esArchiver commands from ./reassign.ts to fix tests (elastic#97012)
  [Security Solution][Detections] Updates MITRE Tactics, Techniques, and Subtechniques for 7.13 (elastic#97011)
  Index patterns server - throw correct error on field caps 404 (elastic#95879)
  Use `EuiThemeProvider` in lists plugin tests and stories (elastic#96129)
  [npm] upgrade caniuse database (elastic#97002)
  chore(NA): moving @kbn/apm-utils into bazel (elastic#96227)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts
phillipb added a commit to phillipb/kibana that referenced this pull request Apr 14, 2021
…to-metrics-tab

* 'master' of github.com:elastic/kibana: (61 commits)
  [Usage collection] Usage counters (elastic#96696)
  UI actions readme (elastic#96925)
  [TSVB] Enable brush for visualizations created with no index patterns (elastic#96727)
  [Data telemetry] Add Async Search to the tests (elastic#96693)
  added missing optional chain for bracket notation (elastic#96939)
  [Discover][DocViewer] Fix toggle columns from doc viewer table tab (elastic#95748)
  [TSVB] Fix per-request caching of index patterns (elastic#97043)
  [Datatable] Fix filter cell flakiness (elastic#96934)
  Unskip heatmap suite and fixes flakiness (elastic#96941)
  [Fleet] Improve performance of data stream API (elastic#97058)
  [ML] Data Frame Analytics: remove beta badge (elastic#96977)
  [App Search] Migrate expanded rows for meta engines table in Engines Overview (elastic#96251)
  Instances latency distribution chart tooltips and axis fixes (elastic#95577)
  [Monitoring] Using primary average shard size (elastic#96177)
  [Workplace Search] Hide Kibana chrome on 3rd party connector redirects (elastic#97028)
  ## [Security Solution] Fixes `Exit full screen` and `Copy to cliboard` styling issues (elastic#96676)
  Index pattern field editor - Add warning on name or type change (elastic#95528)
  [App Search] Add small engine breadcrumb utility helper (elastic#96917)
  Copy esArchiver commands from ./reassign.ts to fix tests (elastic#97012)
  [Security Solution][Detections] Updates MITRE Tactics, Techniques, and Subtechniques for 7.13 (elastic#97011)
  ...
@ruflin
Copy link
Member

ruflin commented Apr 14, 2021

Great improvement!

with one call upfront

When is this "upfront" exactly happening? On package installation? Another way I was thinking of it to only retrieve it the first time the user actually clicks on a data stream and then cache it.

@jen-huang
Copy link
Contributor Author

jen-huang commented Apr 14, 2021

@ruflin One call upfront means when the user hits GET /api/fleet/data_streams, we retrieve all installed package dashboards in a single call at the start of the route handler - previously we were retrieving dashboards one by one as we looped through each data stream.

madirey pushed a commit to madirey/kibana that referenced this pull request May 11, 2021
* Improve performance of data stream API

* Remove extra logger, replace filter with reduce

* Remove unused import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v7.12.1 v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Data streams page is slow when there are many data streams
5 participants