Customize Preload Parameters

This article contains the information about the parameters that control the speed of the Preload feature, and how you can modify them.

The Preload option has three parameters:

  • Batch size, which is the number of URLs that will be processed on each run. By default, the maximum is 45 (URLs).
  • Interval between batches, that is the pause that will be applied between processing of batches. Its default value is 60 (seconds).
  • Delay between requests, which is the delay between the requests sent to the server, for each URL. By default, the value is 500000 (microseconds = 0.5 seconds).

Controlling the parameters should help to reduce the CPU usage in those cases where the server struggles to preload all the pages.

Using a helper plugin 

You can use a helper plugin to reduce the parameters, and limit the speed of the preloading. To get the best results, with this helper plugin, the Used CSS generation speed will also be limited.

The helper plugin and more information about how it works can be found here.

Additional customization of the parameters

If you need to further decrease or increase the preloading speed, you can apply additional customizations to the above helper plugin, as shown below.

Important! In this part, you must edit the helper plugin before use! Only proceed if you are comfortable editing files via (S)FTP!

You can set your custom values to this helper plugin by editing:

    • Line 37, to set the maximum batch size. It is the number of URLs that will be processed on each run.
      • Decrease in case the default value is causing a higher CPU usage. This will result in the server running shorter preload tasks.
      • Increase progressively if you have enough resources to process long standing tasks
    • Line 44, to set the minimum batch size. It is the number of URLs that will be processed on each run.
      • Decrease in case the default value is causing a higher CPU usage. This will result in the server running shorter preload tasks.
      • Increase progressively if you have enough resources to process long standing tasks
    • Line 51, to set the desired cron interval in seconds. It is the pause that will be applied between the processing of batches. 
      • Increase in case the default value is causing a higher CPU usage. The server will have more time to rest between processing batches.
      • Decrease progressively if you don't notice any increase in CPU load.
    • Line 59, to change the pause between each request made to a URL. You can use a value in seconds. 
      • Increase in case the default value is causing a higher CPU usage. The server will have more time to rest between consecutive URL preloads.
      • Decrease if you don't notice any increase in CPU load. I will speed up the preload process. It will generally require a higher CPU frequency.

Then, compress the helper as ZIP, upload it and activate it.

Large website on dedicated servers

For large website with dedicated servers and enough resources to spare, it's possible to use the following Action Scheduler filter to increase the number of concurrent batches:

  • Concurrent batches: action_scheduler_queue_runner_concurrent_batches
    The filter increases the number of concurrent batches allowed and speeds up the processing of large numbers of actions that are scheduled by executing them simultaneously.
    The default value: 1 (batch running at a time).

Important! 
action_scheduler_queue_runner_concurrent_batches affects all plugins using the Action Scheduler and will generally cause a higher server load.
- Do not use if you already have a high CPU usage with the default value.
- Do not use if you are on a shared hosting environment as they usually restrict the resources' usage.
- Do not use unless you have enough spared resources on your server.

To increase the concurrent batches, you can add the following snippet to your theme's functions.php file:

function wpr_increase_action_scheduler_concurrent_batches( $concurrent_batches ) {
	return $concurrent_batches * 2;
}
add_filter( 'action_scheduler_queue_runner_concurrent_batches', 'wpr_increase_action_scheduler_concurrent_batches' );

Increase the return value progressively and monitor closely the server's load.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.