Skip to content
RED SAGSkills
mediumBackend Developer interview question

Sending emails and generating PDF invoices makes your checkout API slow. How would you move this work to the background?

What the interviewer wants to hear

  • Return quickly and enqueue a job to a queue
  • Workers process jobs separately and scale independently
  • Retries with backoff and a dead-letter queue
  • Idempotent jobs because of at-least-once delivery
  • Monitoring queue length and failures; job status for the user

Model answer

The checkout request should only do what must be done before replying: validate, save the order and charge payment. Then it pushes a job, such as SendInvoice with the order id, to a queue like SQS, RabbitMQ or BullMQ on Redis, and returns. To avoid losing the job if the app crashes after commit, I would use an outbox table. Separate worker processes consume jobs, generate the PDF, store it in object storage and send the email. Workers scale independently from the API. Failed jobs retry with exponential backoff, and after several failures go to a dead-letter queue for investigation. Because queues usually deliver at least once, jobs must be idempotent, for example by marking the invoice as sent. I monitor queue depth, job age and failure rate, and alert when they grow.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Backend Developer questions