Prevent Double-Booked Tours Under Concurrent Requests and Webhook Retries

Last updated: November 29, 2026

Quick Overview

Two prospects, one texting the AI and one using the property website, try to book the same agent's 10:00 slot at the same moment, and the SMS provider retries its webhook after a timeout. Design and implement booking logic that never double books and treats a retry as the same booking.

EliseAI
Software Engineering Fundamentals
Software Engineer
EliseAI
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Two prospects, one texting the AI and one using the property website, try to book the same agent's 10:00 slot at the same moment, and the SMS provider retries its webhook after a timeout. Design and implement booking logic that never double books and treats a retry as the same booking.

Conversations arrive through several channels and providers that deliver at least once, so races and duplicates are normal at a leasing company's scale. The interviewer checks whether you push correctness into the database instead of relying on check-then-insert in application code.

What the Interviewer Expects
  • Explain the check-then-act race clearly
  • Use a unique constraint or row lock as the source of truth
  • Add an idempotency key derived from the inbound message id
  • Distinguish a retry from a genuine conflict
  • Discuss what the prospect hears when they lose the race
Key Topics to Cover
race conditions
idempotency
unique constraints
transactions
at-least-once delivery
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • The slot is reserved in your DB but the PMS write fails: what now?
  • How would this work if the calendar lives in Google or Outlook rather than your DB?
  • Would you use optimistic or pessimistic locking for agent calendars, and why?
  • How long should idempotency keys be retained?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

At most one tour per (agent, slot). A repeated request with the same idempotency key returns the original booking, not an error. A different prospect asking for a taken slot gets a clean 'taken' resul...

High-Level Design

Naive code reads 'is the slot free?' then inserts; two servers can both read free. Instead let the database arbitrate: a UNIQUE(agent_id, slot_start) constraint and a UNIQUE(idempotency_key) colum...


Submit Your Answer
Markdown supported

Related Questions