Discuss Home · Bootstrapped Podcast · Scribbleton Personal Wiki · HelpSpot Customer Service Software

How do you implement scheduled tasks in your SaaS?


This is a nice approach. It does have the problem that Jenkins is a single point of failure, but I think for those of us running tiny software companies, we can manage that.

I liked the idea in your blog post that servers are cattle, not pets.


I’m probably late to the party, but in case the jury is still out I have a very simple and effective pattern for this:

  • implement your job behind an HTTP endpoint so that you can trigger it by posting (with a secret key of course) to a URL in your app.
  • set up a cron job to hit that URL through the load balancer. This ensures you only run on one node at a time and that you’re resilient against nodes failing.

Other advantages:

  • It’s all inside your app so you don’t need to manage a separate set of config/db passwords.
  • Easy to test because you can trigger the job yourself manually.
  • Easy to disable


So what to do if the whole node where cron is running is down?


We’ll yeah, you do have a potential single point of failure there. One additional point I should’ve mentioned is that (provided what you’re scheduling isn’t particularly time sensitive) you can run more than one cron node and stagger the timings.

Alternatively you can live with it being a single node and put a heartbeat monitor on it. Cron services tend to be fairly robust anyway and easy to fix or recommission if they do go wrong.


I think SPOF was the reason Steve created this thread.