-
Notifications
You must be signed in to change notification settings - Fork 235
High CPU usage related to rocket_saas_warmup async process #4072
Description
Describe the bug
We’re getting some reports about high CPU usage with RUCSS enabled, notably on Kinsta/WP Engine, and both pointing to the asynchonous process of the resource fetcher.
As a reminder, this process is triggered asynchronously on rocket_buffer, so running on uncached pages during the caching process. the AJAX action is rocket_saas_warmup
From their logs, some of those calls are running for too long, up to 6 min.
Looking at the code, during this call, we are:
- parsing the HTML for CSS/JS files
- for each file, we are getting the URL, path, content, type (and media value for CSS)
- For the content itself, we are getting it from the local file, or from the remote file if it’s an external path, and then we are Minifying it
- We finally send those to the background process which sends to warmup
I believe what would be causing the issue here is the content fetching + minifying step. Depending on the number of files found, it means a loop with a lot of processing in it.
I’m thinking this specific part should be delegated to the background processing task instead, as it can be running for longer in the background, and it has time and memory limit control.
We can investigate how to move get_url_details() from this class to the background processing class.
Expected behavior
No high CPU usage during this process
Screenshots
Backlog Grooming (for WP Media dev team use only)
- Reproduce the problem
- Identify the root cause
- Scope a solution
- Estimate the effort
