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

[Reporting] Improving CSV generation by supporting concurrent background tasks #181064

Open
mikecote opened this issue Apr 17, 2024 · 8 comments
Open
Labels
Feature:Reporting:CSV Reporting issues pertaining to CSV file export Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)

Comments

@mikecote
Copy link
Contributor

mikecote commented Apr 17, 2024

The report:execute task today has a concurrency per Kibana node set to 1. What Task Manager does when a task type is configured like this is it will prevent more than one reporting task from running on the same node at any given time.

The following exposes some limitations that we have in serverless:

  • Autoscaling will not trigger when there are many CSV generation tasks in the queue given the Kibana node may have another 9 workers available.
  • Having many CSV generation tasks in the queue will cause our users to wait a long time to get their files generated
  • We will get alerts if ever the queue for CSV generation is backed-up however, we would need to manually intervene to fix the CSV queue and it would be better to have the autoscaler manage this situation.

What I propose is running the CSV generation tasks under a new task type report:execute-csv that doesn't have maxConcurrency set within its task definition and keep the report:execute multi-purpose in case there are still CSV tasks in the queue. This will allow 10x throughput per Kibana node for generating CSVs and will benefit serverless, ESS and on-prem users. One thing to keep an eye out for is with 10x concurrency, we also put 10x the memory / CPU pressure and I am not familiar with the internals of how much resource utilization each task needs.

@mikecote mikecote added (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) labels Apr 17, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@kobelb
Copy link
Contributor

kobelb commented Apr 17, 2024

Assuming my understanding of #108485 is accurate, and still relevant, running 10 CSV exports concurrently has the chance of causing Kibana to crash due to an OOM. @elastic/appex-sharedux can you all confirm that each CSV export task could use approximately 100MB of memory?

@tsullivan
Copy link
Member

@kobelb You understanding seems accurate of the current configuration of how we chunk the reports. Currently, @vadimkibana has created an issue to hardcode the chunk size to 4MB: #180829 and that will stop reports from causing OOM in 1GB instances.

@kobelb
Copy link
Contributor

kobelb commented Apr 22, 2024

Thanks, @tsullivan. If we use 4 MB chunks, then I don't have concerns about doing 10 concurrently.

@tsullivan tsullivan added Feature:Reporting:CSV Reporting issues pertaining to CSV file export and removed (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead labels Aug 1, 2024
@tsullivan tsullivan changed the title Improving CSV generation by supporting concurrent background tasks [Reporting] Improving CSV generation by supporting concurrent background tasks Dec 3, 2024
@tsullivan
Copy link
Member

@mikecote @elastic/kibana-security

Having concurrent background tasks for CSV reports will also help in case we want to generate an API key to use as authentication for the report during its runtime. The API key will need a set expiration time, which needs to cover not just (execution time * the number of attempts), but also the time that the report is in "pending" status while waiting for earlier reports to finish. If we can execute CSV reports in parallel, that reduces the time that the report is waiting in pending status.

@mikecote
Copy link
Contributor Author

Thanks @tsullivan, just as a heads up, we're working on supporting API keys at the task manager level (#190661). For reporting, it would mean the reporting document wouldn't have to store and encrypt the API key.

If task manager manages the API key, would that suffice for reporting's use case? From my thinking it does but wanted to make sure. We can also work around the complications of API key expiration by invalidating the API key at the same time the task is done / deleted.

@tsullivan
Copy link
Member

If task manager manages the API key, would that suffice for reporting's use case? From my thinking it does but wanted to make sure. We can also work around the complications of API key expiration by invalidating the API key at the same time the task is done / deleted.

@mikecote Yes! This would be very beneficial to keep the Reporting code as simple as possible. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Reporting:CSV Reporting issues pertaining to CSV file export Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
Development

No branches or pull requests

5 participants