Hello everyone, I’ve deployed my web service on Fly.io and I’m currently using two instances to avoid downtime. However, I have a concern: I’m running two Node.js cron jobs—one checks for payment invoices to process, and the other handles sending email notifications.
My question is: how can I make sure these cron jobs only run on a single instance, so I don’t end up processing the same tasks twice? Alternatively, should I have a dedicated machine just for running these cron jobs?
I’d really appreciate any advice or suggestions on how you’ve handled similar situations. Thanks!
Hello, you need an acid DB to guarantee that you’ll ever send a notification once in a distributed system.
You can manage it all yourself or use something like temporal.io to manage all that for you, it includes error handling, etc.
Running multiple instances is mostly for reliability so if you just need something basic, just have 1 instance of your cron. If you need something serious at scale, look into queue services.