We have scheduled jobs in our Spring Boot services.
We was using spring bootScheduled annotationfor syncing data and sending notifications.
It worked fine when we had one instance but then we decided to scale to multiple pods and regions in openshift cloud platform, so using Scheduled will run the job on each pods.
We decided to go with Shedlock as it is small library and the idea is simple, before a job runs, it takes a lock in a shared store. If another pod already took the lock, the job just skips. For shared store, we used Couchbase as ShedLock has a Couchbase lock provider.
Few months in production now with zero duplicate runs, just take care of below two things.
First is that lockAtMostFor is important. If your pod dies mid job, this is how long the lock stays before another pod can pick it up. You can set it a bit longer than your worst case job time. And second is that ShedLock will not retry or re run missed jobs. It only makes sure at most one instance runs.
What other solution you have used for same problem?