Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Doctor Appointment Booking and Search System

Design a doctor appointment system where patients search for doctors near them, ranked and page by page, and book, view, change and cancel appointments, with each doctor's time locked so two patients can never book the same slot.

Problem statement

Design an appointment booking system for doctor visits. Patients search for doctors by region and see the results ranked and page by page, then book, view, change and cancel appointments. When different patients try to book the same doctor for the same time, only one may get it.

For this exercise, assume each visit is a 30-minute slot, doctors set their weekly working hours and time off, and patients can book up to 60 days ahead. A patient who picks a slot holds it for up to 5 minutes while filling in a short visit form, and no one else can book it during that time.

Patients search by location within a distance they choose, such as 25 km, and by specialty; results are ranked by a mix of distance, rating and how soon the doctor has an open slot, 20 doctors a page.

For this exercise, also assume patients and doctors are already signed in, each doctor's rating comes from another system once a day, and payments, insurance, video visits, reminders and writing reviews are out of scope.

What to build

  1. A patient searches for doctors of a chosen specialty within a chosen distance of a location, sees them ranked by distance, rating and how soon each has an open slot, and pages through the results without skipped or repeated doctors.
  2. A patient sees a doctor's open slots over the booking window.
  3. A patient holds an open slot while filling in a short visit form, then confirms it; a slot is never booked by two patients.
  4. A patient views their appointments, moves one to another open slot, or cancels it, which frees the slot for others.
  5. A doctor sets weekly working hours and time off and sees their booked appointments.

At scale

  • For this exercise, assume 200,000 doctors and about 1 million bookings, moves and cancellations a day, with peaks of 100 booking requests a second.
  • For this exercise, assume a popular doctor's newly opened slots can draw a few hundred booking attempts within a minute.
  • For this exercise, assume up to 2,000 searches a second at peak, and a search page should load within 300 ms p95 (95 of every 100 requests are faster).
  • For this exercise, assume search results may lag bookings by up to 1 minute, while every hold and confirm is decided on the live slot state, and a booking answer should come within 1 second.