Update performance docs to touch on server-side considerations (#120356)

* Update performance docs to touch on server-side considerations

* update edited date
This commit is contained in:
Stacey Gammon 2021-12-03 15:43:32 -05:00 committed by GitHub
parent b5895ec0b4
commit dbde0a75f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,11 +3,13 @@ id: kibDevPerformance
slug: /kibana-dev-docs/key-concepts/performance slug: /kibana-dev-docs/key-concepts/performance
title: Performance title: Performance
summary: Performance tips for Kibana development. summary: Performance tips for Kibana development.
date: 2021-09-02 date: 2021-12-03
tags: ['kibana', 'onboarding', 'dev', 'performance'] tags: ['kibana', 'onboarding', 'dev', 'performance']
--- ---
## Keep Kibana fast ## Client-side considerations
### Lazy load code
_tl;dr_: Load as much code lazily as possible. Everyone loves snappy _tl;dr_: Load as much code lazily as possible. Everyone loves snappy
applications with a responsive UI and hates spinners. Users deserve the applications with a responsive UI and hates spinners. Users deserve the
@ -105,3 +107,15 @@ Many OSS tools allow you to analyze the generated stats file:
Webpack authors Webpack authors
- [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/) - [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/)
- [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) - [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)
## Server-side considerations
### Don't block the event loop
[Node.js is single threaded](https://nodejs.dev/learn/introduction-to-nodejs) which means a single CPU-intensive server-side, synchronous operation will block any other functionality waiting to execute on the Kibana server. The affects background tasks, like alerts, and search sessions, as well as search requests and page loads.
**When writing code that will run on the server, [don't block the event loop](https://nodejs.org/en/docs/guides/dont-block-the-event-loop/)**. Instead consider:
- Writing async code. For example, leverage [setImmediate](https://nodejs.dev/learn/understanding-setimmediate) inside for loops.
- Executing logic on the client instead. This may not be a good option if you require a lot of data going back and forth between the server and the client, as that can also slow down the user's experience, especially over slower bandwidth internet connections.
- Worker threads are also an option if the code doesn't rely on stateful Kibana services. If you are interested in using worker threads, please reach out to a tech-lead before doing so. We will likely want to implement a worker threads pool to ensure worker threads cooperate appropriately.