Improve plugin performance with this one simple hack!
3.8.0 of the Bitcoin and Altcoin Wallets WordPress plugin features significant performance improvements to its cron job mechanism. This is aimed at improving scalability.
- If your site has low traffic you can safely ignore all of this.
- If your site has moderate to high traffic, you can perform a few simple changes to improve performance. The idea, detailed below, is to offload the cron jobs from any end-user HTTP requests. These jobs can run on separate HTTP requests that do not originate from the user’s browser.
The plugin’s cron jobs are tasks that run in the background. They include transaction discovery and execution, cleanup tasks, as well as sending out email notifications.
All of the plugin’s cron jobs will typically run just fine, without any configuration: Once every so often, a regular HTTP request will schedule the cron jobs to run, right after WordPress renders a page or a JSON API response. These jobs run on the shutdown action so as to minimize the performance impact. As long as the WordPress Cron feature is not disabled, transactions will be executed, and the plugin will operate adequately under low to moderate load.
tweaking for optimal performance
Because these jobs are somewhat performance intensive, they can get queued, and later execute in batches that are asynchronous to any user interaction.
To get the best performance out of the plugin, you, the site’s administrator can set up a cron trigger manually: The cron jobs can run on separate HTTP requests, so that end user performance is no longer affected. This will typically result in faster web server response times as seen from the browser.
- First you will want to disable WordPress Cron. Set the following constant in your
- Visit the Wallets → Cron job admin page to find out the URL to trigger. The URL will contain a unique nonce, and will look something like:
- Finally, add a curl command to your Unix/Linux crontab. This command will trigger the URL silently. For example, to trigger once a minute, you would add to your Unix crontab something like:
* * * * * /usr/bin/curl -s 'https://www.example.com/?__wallets_action=do_cron&__wallets_apiversion=3&__wallets_cron_nonce=53854c567d3522b37e8fe96db217debd'
The above assumes that the curl binary is installed in
/usr/bin. Depending on your hosting environment you might need to set this entry into your WHM/Cpanel interface.
improvements behind the scenes
There are a number of new improvements to how the cron jobs run on multisite. When the plugin is network-activated on a multisite installation with many blogs, the plugin will no longer attempt to run cron on all the blogs at once. Instead, it will randomly rotate available blogs and execute jobs on only a few blogs at a time. This is done to avoid PHP execution timeouts.
Additionally, the plugin will stop running cron jobs if it detects that it is running out of allowed PHP execution time. Any remaining jobs will resume on the next cron heartbeat.
For a full list of improvements see the changelog for