0

I have a containerized spring boot application. Currently there are 10+ instances of same spring boot application. Application is deployed in Azure and based on load pods may come up and go down.

Within that application i have scheduled a task to perform an activity. This activity is a high memory intensive task.

Since I have 10+ instances of same application running, when schedule get triggered say Example 09:00 AM, all my pods are performing scheduled activity at same time.

Because of this memory is not sufficient and pods are going down.

Is there a way to handle this in spring boot? Say for example since I have schedule at 09:00 AM, instead of all 10 instances starting at 09:00 AM I have to start three instances schedule @09:00 other three @09:01 and remaining @09:02

Can i schedule like this in spring boot? Or Is there any better way to handle this?

anonymous
  • 483
  • 2
  • 8
  • 24
  • 1
    use Shedlock. see these links [link1](https://rieckpil.de/lock-scheduled-tasks-with-shedlock-and-spring-boot/) & [link2](http://buraktas.com/spring-shedlock-tutorial/). shedlock with [postconstruct](https://stackoverflow.com/questions/67567624/how-to-call-scheduled-method-in-only-one-instance-using-postconstruct) – gowridev May 28 '21 at 11:46
  • You can also use something like Quartz Scheduler to synchronize tasks in clustered environment – Nikolai Shevchenko May 28 '21 at 11:47
  • I think you can use ShedLock to do this https://www.baeldung.com/shedlock-spring – andersonbalves May 28 '21 at 12:20

0 Answers0