[wp-hackers] Best methodology for running wp-cron on separate server.

Ryan Frankel ryan.frankel at gmail.com
Tue Apr 2 15:51:20 UTC 2013

  I am wondering if anyone has any experience with having mutliple
load-balanced servers and trying to run wp-cron on only one specific
server.  I have tried this a few ways and I am not sure the best approach.
Here are some ideas I had and if anyone has experience with this I would
love to hear it.

1. Ideally, it would be nice if I could use something like Gearman to
'farm' out the jobs to servers I desire as things scale.  It seems to me
that what the Gearman worker would need to do is fire up WP via wp-load run
its job and return the data.  This way I can scale as needed to multiple
servers that are not web servers at all (as in they don't attach to the
load balancer)

2.  I could have a web server that I weight very low in the load balancer
that runs the cron.  The question then becomes how to tell wp-cron to run
on only that server.  My initial attempt was to wrap all of the add_actions
in an if that looked for a specific IP and have pingdom hit that server
every minute to make sure the crons did run.  I didn't have much success
with that because there is no guarantee that WP will try the cron on that
specific server and if it is on a different on it seems it will just skip
it.  I have seen some thought about adding a transient if it runs on
another server but I'm not sure that that will scale nicely and we would
end up with code all over the place.

Maybe I should just pose the question to you WP experts out there...has
anyone ever tried to offload processing of wp-cron and come up with a
methodology that works?  I would be more then happy to hear any advice.


Ryan S. Frankel

More information about the wp-hackers mailing list