-
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
[Security Solution][Detections] In-memory Rule Management and Monitoring tables #119601
Comments
@FrankHassanabad had valid concerns about this approach a few weeks ago, and I finally compiled a summary of our chat and decisions made so far. Concerns:
Action items:
Other notes:
|
…119611) **Addresses: #119601 ## Summary With this implementation, we load detection rules into the in-memory cache on the initial page load. This change has several notable effects visible to users: - Table pagination is now almost instant as we don't need to make an additional HTTP request to render the table. - Table filters get applied instantly when the cache is hot as we use filter parameters as the cache key. If a user has already filtered rules by a specific parameter, we will first display the rules using cached data and re-fetch for new data in the background. - Table sorting and filtration also happen without visible delays as we don't need to make an additional HTTP request for that. - Faster navigation between pages once rules data is loaded. We do not re-fetch all rules if a user leaves the rules management page and then returns. - Introduced an adjustable threshold that represents the maximum number of rules for which the in-memory implementation is enabled (by default 3000). <img width="1503" alt="Screenshot 2022-01-20 at 16 47 45" src="https://user-images.githubusercontent.com/1938181/150350900-4147775e-82ab-4100-8e80-82c49ef193bf.png"> - Added an indication of when the advanced sorting capabilities were enabled or disabled: <img width="200" alt="Screenshot 2022-01-20 at 16 49 23" src="https://user-images.githubusercontent.com/1938181/150351879-7974ebcc-487e-4368-90f5-728308c8155c.png"><img width="200" alt="Screenshot 2022-01-20 at 16 52 29" src="https://user-images.githubusercontent.com/1938181/150351929-852d6d18-0c18-4d88-9fce-cf13c05ed80e.png"> - Added sorting by all rules table columns. - Removed Idle modal and the `idleTimeout` UI setting. Added a saved object migration to remove the unused setting. Notable changes from a technical standpoint: - Automatic query cancellation; Removed all AbortSignal-related manual logic. - Re-fetching by a timer logic has been removed in favor of react-query built-in implementation. - Removed manual logic of keeping `lastUpdated` date up to date along with `isLoading` and `isRefreshing` flags. It also has been delegated to react-query. - Refetch behavior slightly changed. We re-fetch table data only when the browser tab is active and do not re-fetch in the background. Additionally, we re-fetch when the browser tab becomes active. ## Scalability Risks It's worth noting performance deterioration with an increasing number of parallel requests: **20 rules per request (200 requests, 50 in parallel)** ``` Summary: Total: 10.4503 secs Slowest: 1.6089 secs Fastest: 0.3398 secs Average: 1.0381 secs Requests/sec: 19.1383 ``` **100 rules per request (200 requests, 50 in parallel)** ``` Summary: Total: 14.0456 secs Slowest: 1.9323 secs Fastest: 0.9952 secs Average: 1.3991 secs Requests/sec: 14.2393 ``` **500 rules per request (200 requests, 50 in parallel)** ``` Summary: Total: 32.6509 secs Slowest: 4.8964 secs Fastest: 0.5494 secs Average: 3.2379 secs Requests/sec: 6.1254 ``` **1000 rules per request (200 requests, 50 in parallel)** ``` Summary: Total: 47.8000 secs Slowest: 6.1776 secs Fastest: 1.2028 secs Average: 4.7547 secs Requests/sec: 4.1841 ``` ### JSON response parsing time Time spent by Kibana parsing Elasticsearch response JSON. | 20 rules | 100 rules | 500 rules | 2500 rules -- | -- | -- | -- | -- mean, ms | 9.920000 | 22.540000 | 62.380000 | 195.260000 max, ms | 11.000000 | 29.200000 | 76.300000 | 232.800000
UPD on the action items and things left to do in this ticket.
There are some follow-up items, most of which we're going to start addressing in the next 8.2 dev cycle:
|
@xcrzx I updated the above comment with follow-up tickets, and I think at this point we can close this one. Please check the new tickets and let me know if you'd like to change anything in them. |
Summary
Previously we considered an option of implementing in-memory filtering, sorting and searching in the browser for our Rule Management and Monitoring tables: #89877
This PR was abandoned because:
rules/_find
andrules/_find_statuses
endpoints were extremely slow when the page size was 100+ items. We had N+1 problem and were fetching rule status and actions SOs per each rule in separate requests to Elasticsearch. This was leading to the fact that in-browser app in attempt to load all the 500+ rules was generating 1500+ requests to ES under the hood. If we multiply that by the number of simultaneous users and add the fact that some of them have more than 500 rules, it becomes clear that it wasn't a scalable solution.Since now SO API supports aggs, and we're in the process of getting rid of legacy SOs, we are going to reconsider the in-memory approach.
To do
The text was updated successfully, but these errors were encountered: