Backend Developer Interview Question

You run six instances of a service and need a nightly job to run exactly once. How do you arrange that?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Do not rely on every instance running a local cron. Use a leader lock, such as a row or key acquired with a lease and a time to live, so only the holder runs the job, or delegate scheduling to a platform level cron that enqueues one job for a worker to pick up. Either way, make the job idempotent and observable, because a lease can expire mid run and cause an overlap.

Why interviewers ask this

It is a small distributed systems problem with a lot of subtle failure modes. The interviewer wants to see that you would not assume in process schedulers on identical instances fire once, that you know locks need expiry to survive a crash, and that idempotency remains the real safety net. Monitoring for a job that silently stops running is the detail most candidates leave out.

How to structure your answer

  • State the problem: identical instances each fire their own timer.
  • Give the two viable approaches, lock based and platform scheduled.
  • Cover lease expiry, overlap and crash recovery.
  • Add monitoring for the job that never ran.

Example answer

Spoken example, first person

The naive version runs six times, and the version where one special instance is designated stops working the day that instance is unhealthy. So I either use a lock or take scheduling out of the application entirely. With a lock, each instance tries to acquire a lease at the scheduled time, typically an insert or a conditional update on a jobs table with an expiry, and only the winner runs, renewing the lease while it works. The subtlety is that a lease can expire during a long run, and then a second instance starts, so the job still has to be safe to run twice. My preference at any scale is the second approach: platform level scheduling that enqueues a single message, and ordinary workers consume it. That gives retries, visibility and history for free, and the application code becomes just a handler. Whichever way, I record start and finish times and alert when a job has not completed within its expected window, because a job that quietly stops running is the failure people notice weeks later.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What happens if the job takes longer than the interval between runs?
  • How would you make a nightly report job idempotent?
  • How do you handle a job that must run once per tenant across thousands of tenants?

Related backend developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot