Scrivio Interview library

Scheduling

22 questions in 5 subtopics.

@Scheduled

ConceptFoundations7 min read
Explain the difference between fixedRate, fixedDelay and cron in @Scheduled, and what happens with fixedRate when one execution takes longer than the interval.
DebuggingFoundations7 min read
A @Scheduled method in a Spring Boot service never runs, and there are no errors in the logs. List the likely causes.
DebuggingFoundations7 min read
A Spring Boot service has three @Scheduled methods. One of them calls a slow external API that sometimes takes 10 minutes, and during that time the other two jobs do not run. Explain why and how to fix it.
ScenarioIntermediate6 min read
A team uses @Scheduled to send daily reminder emails from a Spring Boot service, and it worked until the service was scaled from 1 to 6 replicas. What happens now, and what options do you have?
LeadershipAdvanced6 min read
Teams across your organisation keep adding @Scheduled jobs inside request-serving services, which caused incidents when jobs competed with traffic or ran on every replica. What guidance would you set?

Scheduling in clusters and ShedLock

CodingFoundations7 min read
Show how to make a @Scheduled method run on only one instance in a cluster using ShedLock with a JDBC lock provider, and explain lockAtMostFor and lockAtLeastFor.
DebuggingIntermediate6 min read
A ShedLock-protected job occasionally runs twice within a minute on different pods. The job takes 20 seconds and lockAtMostFor is 30 seconds. What are the possible causes?
ScenarioIntermediate7 min read
A team uses ShedLock to run a job that processes all pending invoices every minute, but the backlog keeps growing because only one pod works at a time. How would you redesign it to scale?
DesignAdvanced6 min read
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.
LeadershipPrincipal7 min read
A missed or duplicated scheduled job caused a costly incident at your company: interest was calculated twice for some accounts. As the senior technical leader, how do you address the systemic risk rather than this single bug?
LeadershipPrincipal7 min read
Your organisation is considering offering scheduling as a central platform service (triggers, calendars, history, alerting) instead of each team using @Scheduled with ShedLock, Quartz or CronJobs. As the senior technical leader, how do you decide whether to fund it and how to run it?

Quartz

ConceptFoundations6 min read
Describe the main concepts of Quartz (Job, JobDetail, Trigger, Scheduler) and how Spring Boot's spring-boot-starter-quartz wires them.
ScenarioIntermediate6 min read
A Quartz job scheduled every 5 minutes in a clustered JDBC job store sometimes runs concurrently with itself, and after a 1-hour outage it fired many times at once. Explain and fix both problems.
ScenarioAdvanced7 min read
Your team inherits a Quartz cluster with 2,000 triggers across 10 nodes, and the QRTZ tables have become a database hotspot with lock waits on QRTZ_LOCKS. What would you investigate and change?
DesignAdvanced5 min read
Your organisation is deciding whether teams should embed Quartz in their Spring Boot services or use a central job scheduling service. Compare the options for 50 teams.

Cron expressions

CodingFoundations6 min read
Write Spring cron expressions for: every weekday at 06:30, every 15 minutes during business hours 9-17, and the last day of every month at 23:00. Explain how Spring cron differs from Unix cron.
DebuggingIntermediate7 min read
A job scheduled with @Scheduled(cron = "0 30 2 * * *") ran twice on one night and not at all on another night in spring. The servers use the Europe/Berlin time zone. Explain and fix.
ScenarioAdvanced7 min read
Thousands of jobs across your services are scheduled at midnight UTC, and every night the shared database and message broker overload for ten minutes. How would you fix this across teams?
LeadershipPrincipal7 min read
Your company operates in 30 countries and many scheduled processes depend on local business days and holidays. As the senior technical leader, how would you approach calendars and scheduling standards company-wide?

Legacy Timer tasks

ConceptFoundations6 min read
java.util.Timer and TimerTask are considered legacy. What are their problems, and what replaces them?
CodingIntermediate6 min read
Migrate this code to a modern alternative and explain the improvements:
Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
public void run() {
refreshCache();
}
}, 0, 60000);
LeadershipAdvanced6 min read
A code scan finds java.util.Timer in 70 places across many services, and one past incident was caused by a Timer thread dying silently. How do you plan the clean-up?