DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

Rethinking Java @Scheduled Tasks in Kubernetes

2 years ago thenewstack.io
Rethinking Java @Scheduled Tasks in Kubernetes

Summary: This is a summary of an article originally published by The New Stack. Read the full original article here →

Historically, most scheduled tasks in Java applications I’ve worked on have used Spring’s scheduling https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/scheduling.html#scheduling-annotation-support-scheduled. Spring handles methods that you annotate with @Scheduled in the background of the application.

This creates a problem in the way scheduled tasks have been used historically: Because scheduled tasks are run in the background of the application, we have duplicated (and possibly competing) scheduled tasks as we horizontally scale the application.

n scheduled tasks duplicating the same scheduled task logic, which could cause duplicated logic, https://thenewstack.io/how-to-deal-with-race-conditions/ and inefficient use of resources.

We can overcome these disadvantages by separating the concerns of running the scheduled task and serving the application.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com