High CPU usage
If you are experiencing high CPU usage on your site, there are a few possible ways WP Rocket could cause this:
Pages are not cached
Make sure that WP Rocket is active and caches your pages:
If your site has a lot of pages to preload and/or lacks enough server resources, preloading will cause a spike in CPU usage. If the spike causes a problem for your site you can try:
- Limiting the number of URLs to be preloaded in each Preload event; reducing the frequency of the Preload event; and setting up a delay between requests made to the same URL. See this article: Customize Preload parameters
- Increasing the Cache Lifespan to avoid too frequent entire cache deletion and preloading
- Setting up cron jobs to clear and preload the cache during periods of low server activity.
If disabling or limiting preload doesn't resolve the issue, try the steps below.
Remove Unused CSS
The process of generating Used CSS can cause high CPU usage.
You can use the available filters to decrease the number of Used CSS entries to process or to decrease the frequency of the processing, this should decrease the CPU usage in the cases where this optimization is causing it.
rocket_rucss_pending_jobs_cron_rows_count filter to decrease the processing batch value. A lower value (default is 100 URLs) can help the server to work on fewer requests at a time.
If that doesn't help, you should decrease the frequency using the
rocket_rucss_pending_jobs_cron_interval filter. By setting a higher value (default is 60 seconds), the server will have more time to rest between processing batches.
See this article for more details: Customize Remove Unused CSS parameters.
Excessive cache clearing
Sometimes, you might notice the cache is being cleared randomly, without a clear explanation, and this can cause CPU issues because cached won't be available, and the requests will reach the server with more frequency.
Please check our Cache is incomplete, cleared too frequently or randomly guide for more information.
Other file optimizations
Occasionally some of the other options on the File Optimization tab, such as Minify/Combine can cause high CPU usage in cases where your site has a lot of CSS or JS files. Try disabling these options and then monitor your CPU usage to see if it helps.