Subscribe to our newsletter for some WordPress performance and security tips! WP-Cron, the WordPress task scheduler, is a common source of problems, from missed publish schedules and failed auto-updates, to broken garbage collection and cache flushing. There are plenty of good tutorials on working with the scheduler, so in this post we’d like to focus more on performance, and why it’s a better idea to trigger WP-Cron exclusively via a CLI process. The Problems By default, WordPress spawns the cron runner using an HTTP request to itself. Such a request is quite a bit of overhead for the original user-facing request, usually about 1 second. This means that every once in a while (when cron needs to run), regardless of how fast your application is, the response time for an unlucky user will suck. For high-traffic sites it gets even worse, because WordPress options are not thread-safe, you may easily end up with multiple concurrent requests attempting to spawn the scheduler, resulting in multiple unlucky users per cron run. On the contrary, with an aggressive page caching setup, you might never be able to get that cron to spawn, because all requests would be served from cache.
Share This

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.