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] Split bulk delete into chunks to avoid high memory consumption #188208

Closed
Tracked by #187969 ...
xcrzx opened this issue Jul 12, 2024 · 4 comments · Fixed by #188248
Closed
Tracked by #187969 ...

[Fleet] Split bulk delete into chunks to avoid high memory consumption #188208

xcrzx opened this issue Jul 12, 2024 · 4 comments · Fixed by #188248
Assignees
Labels
8.16 candidate Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team:Fleet Team label for Observability Data Collection Fleet team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture

Comments

@xcrzx
Copy link
Contributor

xcrzx commented Jul 12, 2024

Related to: #187969

Summary

For packages with a large number of assets, when performing reinstall or upgrade, we need to limit bulk delete requests to a fixed number of saved objects.

Currently, the bulk delete method is called with all package assets:

await savedObjectsClient.bulkDelete(assetsToDelete, { namespace });

This means that significant request and response objects will be created and stored in memory at the same time before being garbage collected. Splitting that work into smaller chunks can reduce memory pressure:

const chunks = chunk(assetsToDelete, MAX_ASSETS_TO_DELETE);

for (const assetsChunk of chunks) {
  await savedObjectsClient.bulkDelete(assetsChunk, { namespace });
}

This way, completed bulk delete requests with smaller payloads and responses can be garbage collected along the package removal process, leading to smaller overall memory consumption.

@xcrzx xcrzx added technical debt Improvement of the software architecture and operational architecture Team:Fleet Team label for Observability Data Collection Fleet team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules 8.16 candidate labels Jul 12, 2024
@xcrzx xcrzx self-assigned this Jul 12, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.16 candidate Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team:Fleet Team label for Observability Data Collection Fleet team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants