Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

You need a cluster-wide scheduling approach for 40 services, some running on Kubernetes and some on VMs. Compare ShedLock, Quartz clustering, Kubernetes CronJobs and a central scheduler service.

There is no single winner, so we would pick per class of job and write it down as a standard. ShedLock is simple and in-process, best for short idempotent jobs, but has no history, no misfire handling and no dependencies. Clustered Quartz adds persistent jobs, misfire handling and load sharing through a JDBC job store at the cost of more tables and configuration. Kubernetes CronJobs give an isolated process per run, good for heavy jobs, but exist only on Kubernetes. A central scheduler gives one place for dependencies, calendars and audit, but is one more critical system to run.

Why this question is asked

Forty services with a mix of Kubernetes and VMs means forty slightly different answers to 'how do we run this at 02:00', unless someone sets a standard. The cost of not deciding shows up as duplicate runs, missed runs nobody noticed and jobs that cannot be audited. Interviewers ask senior engineers to compare these four options because each is right for some jobs and wrong for others, and a good answer is a decision framework rather than a favourite tool. In this answer, we will describe what each option really provides and costs, compare them side by side, and turn the comparison into a standard that maps job classes to options.

1What We Are Choosing Between

Every scheduling approach answers the same questions differently: who decides when a job is due, where the job runs, what happens if it runs twice or not at all, and where the history lives. Keeping these questions in mind makes the comparison concrete, because each option is strong on some of them and silent on others.

It also helps to remember the mix of platforms. Some answers, like Kubernetes CronJobs, only exist for the services on Kubernetes. Others, like ShedLock and Quartz, are libraries inside the application and work the same on a VM or in a pod. A central scheduler can trigger both, as long as it can reach them.

2ShedLock: A Lock Around @Scheduled

ShedLock keeps the schedule in the application, in @Scheduled, and adds a lock in a shared database or cache so only one instance runs each execution. It is a dependency and a table, and engineers can adopt it in an afternoon. It works the same on VMs and Kubernetes.

What it does not do is just as important. It keeps no history of runs, it does not make up a run that every instance missed, for example during a deployment, it has no notion of one job depending on another, and its lock is a lease that can expire under a slow run. That makes it a good fit for short, idempotent jobs where an occasional missed run is harmless: cache refreshes, cleanup, small syncs.

3Clustered Quartz: A Scheduler Library With a Shared Store

Quartz runs inside the application too, but its triggers and job definitions live in database tables, the JDBC job store. In clustered mode, every instance shares those tables and coordinates through row locks, so each firing is taken by exactly one instance, and different jobs spread across instances. Because the schedule is persistent, Quartz knows when a trigger was missed and applies a misfire instruction, such as 'fire once now' or 'skip to the next time'.

The price is about a dozen QRTZ_ tables per scheduler, configuration that teams must understand, such as thread pools and misfire thresholds, and database load that grows with the number of triggers and nodes. Quartz has job listeners but no built-in run history or dashboard, so teams add their own. It suits services with many jobs, or jobs where misfire behaviour matters, on any platform.

4Kubernetes CronJobs: A Process per Run

A Kubernetes CronJob creates a Job, and thus a pod, at each scheduled time. The work runs in its own process with its own CPU and memory limits, so a heavy job cannot slow down request-serving pods, and a memory leak dies with the pod. concurrencyPolicy decides what happens if the previous run is still going: Allow, Forbid or Replace. startingDeadlineSeconds limits how late a missed run may still start, and the timeZone field sets the zone of the schedule in current Kubernetes versions.

The limits are that it exists only on Kubernetes, a run's history is only as long as the cluster keeps finished Job objects unless we ship logs and metrics elsewhere, there are no dependencies between CronJobs, and Kubernetes documents that a CronJob may occasionally create two Jobs or none for one schedule time, so jobs still need to be idempotent. It suits heavy, isolated jobs on Kubernetes, such as nightly exports and reconciliations.

5A Central Scheduler Service

A central scheduler is a separate system, open source, bought or built, that owns all schedules. It triggers work in the services, by HTTP call, by message or by starting a container, and records every run. Because it sees everything, it can offer what no library can: dependencies between jobs ('run the settlement export after all ledger jobs succeed'), business calendars ('the last business day of the month in Germany'), a single audit history and consistent alerting on failed or missed runs. It works across VMs and Kubernetes.

The cost is that it becomes critical shared infrastructure. If it is down, nothing runs anywhere, so it needs high availability, an owning team with on-call and a service level objective, and a migration effort for every team. It earns its place for jobs with dependencies, calendars or audit needs, and for organisations large enough to staff it.

Four ways to schedule across a cluster
ShedLockClustered QuartzK8s CronJobCentral scheduler
Runs whereinside the serviceinside the serviceown pod per runtriggers the service
PlatformsVMs and K8sVMs and K8sK8s onlyVMs and K8s
Run historynoneadd your ownwhile Jobs are keptfull audit
Missed runslostmisfire rulesstartingDeadlineSecondsconfigurable
Dependenciesnononoyes
Isolationshares the serviceshares the serviceseparate processdepends on target
Running costvery lowtables and configmanifestsa team and HA

6Turning the Comparison Into a Standard

With forty services, the useful output is a short standard that maps classes of jobs to options, so most decisions take seconds. Short, idempotent housekeeping uses @Scheduled with ShedLock, through a shared starter. Services with many jobs or misfire rules use clustered Quartz. Heavy, isolated jobs use a Kubernetes CronJob on Kubernetes, or the central scheduler on VMs. Jobs with dependencies, business calendars or audit requirements use the central scheduler, if we decide to run one.

Every option is held to the same baseline: jobs are idempotent, each job has an owner, runs emit the same metrics, and missed runs raise an alert. The standard should be reviewed yearly, because the job mix changes, and exceptions should be written down with a reason.

Step throughChoosing a scheduling option for a job
  1. Needs dependencies, calendars or audit?
    Yescentral schedulerNonext question
  2. Heavy or needs its own resources?
    YesCronJob on K8s, central scheduler on VMsNonext question
  3. Many jobs or misfire rules matter?
    Yesclustered QuartzNoShedLock with @Scheduled

3 steps in order. Play them, or step through them one at a time.

7Follow-up questions

Could one option cover all forty services?

A central scheduler could trigger everything, but using it for a cache refresh every minute adds a network hop and a critical dependency for no benefit. Forcing everything onto ShedLock leaves audited jobs without history. A standard with a few classes avoids both extremes.

What happens to running jobs when a Quartz node dies?

In clustered mode, the other nodes notice the missing check-in after the cluster check-in interval. Jobs that were marked as requesting recovery are run again on another node; others are simply lost for that firing. So a job that must complete should request recovery and be idempotent.

How would you migrate existing jobs to the standard?

Start with an inventory of every scheduled job, its class and owner. Then move the jobs that are misclassified and have caused incidents first, typically heavy or financial jobs running with plain @Scheduled, and leave compliant housekeeping where it is.

8Conclusion

In this answer, we compared four ways to schedule across forty services. ShedLock is the lightest, a lock around @Scheduled for short idempotent jobs, without history, misfire handling or dependencies. Clustered Quartz adds persistence, misfire rules and load sharing at the cost of tables and configuration. Kubernetes CronJobs isolate heavy jobs in their own pods but exist only on Kubernetes. A central scheduler adds dependencies, calendars and audit, and must itself be run as critical infrastructure. We turned this into a standard that maps job classes to options, with a common baseline of idempotency, ownership, metrics and missed-run alerts.

What to say in the interviewAbout 80 seconds aloud

Open with

I'd compare them on where the job runs, what happens on missed or duplicate runs, history, dependencies and running cost. ShedLock is just a lock around @Scheduled, in-process, works on VMs and Kubernetes, adopted in an afternoon, but no history, no catch-up of missed runs, no dependencies, and the lock is a lease; it's for short idempotent housekeeping.

Then, if they want more

Clustered Quartz keeps triggers in a JDBC job store shared by all nodes, so each firing runs on one node, it has misfire handling and spreads jobs across nodes, but it brings the QRTZ tables, more configuration and database load.

Kubernetes CronJobs start a pod per run, so heavy jobs are isolated from serving pods, with concurrencyPolicy to control overlap, but they're Kubernetes only, history lasts only as long as the Job objects, and they can occasionally run twice.

A central scheduler gives dependencies, calendars, audit and alerting across both platforms, but it's another critical system needing HA and a team.

So I'd set a standard by job class: ShedLock for housekeeping, Quartz for services with many jobs or misfire needs, CronJobs for heavy work on Kubernetes, the central scheduler for dependent, calendar-driven or audited jobs, all with idempotency, owners and missed-run alerts.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Batch reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "You need a cluster-wide scheduling approach for 40 services, some running on Kubernetes...": https://scrivio-interview-library.netlify.app/spring-boot/scheduling/be7269f047/