← Back to practice catalog

System design interview guide

Vaccine Booking System Design

TL;DR:

Picture a vaccination clinic that opens its booking calendar at eight in the morning, with exactly one chair left at nine o'clock tomorrow. Two people, each on their own phone, both see "1 left" and both tap Confirm in the same second. If the website simply believes what each phone saw, it promises that one chair to both of them, and two families arrive at the clinic expecting the same appointment. A vaccine booking system is the website that finds nearby clinics, decides who is allowed to book, and gives every open time to exactly one person. The hard part is doing that while millions of people arrive at once and the rules about who may book can change overnight.

Overview diagram for Vaccine Booking System Design

Problem statement

Picture a clinic calendar that opens at eight in the morning with one chair left tomorrow at nine. Two people both see "1 left" and both tap Confirm in the same second. A vaccine booking platform is the website that finds nearby vaccination centers, decides who may book, and gives each open time to exactly one person. The hard part is doing that while millions arrive at once, the rules about who may book can change overnight, and every wrong promise shows up at the clinic door—and often in the news.

Introduction

The problem: two phones, one last chair

Picture a vaccination clinic that opens its booking calendar at eight o'clock on a Monday morning. Tomorrow at nine there is exactly one chair left. Maya and Daniel, who have never met, both see "1 slot left" on their phones, and both tap Confirm within the same second. Each phone showed an honest picture a moment ago, but only one of them can actually get the chair. If the website simply trusts what each phone saw, it will confirm both, and the next morning two families will stand at the clinic door holding the same appointment.

That is one small corner of a much larger problem. A vaccine booking system is the website that finds clinics near a person, decides whether that person is currently allowed to book, shows the open times, and gives each open time to exactly one person. On an ordinary day it feels like any scheduling site. On the morning when a new group becomes eligible, millions of people open the page at the same moment, the open times disappear within seconds, and every mistake becomes visible to the public.

This page walks through the design in the order you would actually think about it in an interview. First we say what the problem is and why anyone bothers. Then we agree on what the system must do and how well it must do it. Then we estimate the size. Only after that do we make the design choices one at a time, and finally we draw the result and dig into the questions an interviewer is likely to ask next.

Why teams bother with online vaccine booking

Before online booking, people stood in line outside a clinic or dialed a busy phone line for an hour hoping for one open chair. That pain is why booking moved to a website, and each reason below is something a health department still cares about in a real launch.

Fair access. When a vaccine is scarce, the first people to get through should not be decided by who owns the fastest phone or who can run a script. People expect a clear and believable rule about who gets in first.

Using every chair. A clinic that has capacity but half-empty hours wastes staff and vaccine. A booking system that keeps an accurate count lets the health department fill the day and move people to quiet clinics.

Following the rules about who may book. Vaccines are released in stages, such as by age, by job, or by area. Checking that on the server, with a record of which rule applied, avoids the argument at the clinic door and gives the department something to show when asked.

Public trust. Slots vanishing in seconds, double bookings, and unexplained denials end up in the news. A system that is slow but correct is forgiven much more easily than one that is fast and wrong.

Planning supply. A department that knows how many appointments exist at each site can send doses and staff where they are needed.

The two phones at the start of this page are the sharpest version of all of these: a promise made to one person must not also be made to another.

What problem are we solving?

At its simplest, the system answers three questions for every person who opens it:

“Which times are open near me, am I allowed to book one, and if I confirm, is this time really mine?”

The inputs are a person who has signed in, a location, and a time window. The outputs are a list of open times, a yes or no on whether this person may book, and, after a confirm, either an appointment that exists or a clear message that the time is gone. A good outcome has four parts. Every confirmed appointment belongs to exactly one person. People who are turned down hear a reason they can understand. The site does not fall over on release morning, even though demand is far above normal. And a reminder reaches the person before the visit.

There are two situations that make this harder than an ordinary booking form. The first is competition for very few chairs, where a busy clinic may offer only tens of times per hour and thousands of people want the same few. The second is a sudden crowd, where traffic jumps to many times its normal size within a few seconds because everyone was waiting for the same announcement. We will not guess at the answers yet. First we need to be clear about what the system must do and how well, so that every design choice later has a reason behind it.

This page is the interview deep dive in the system design interview guides hub. If you want to practice only the opening requirements stage first, there is a short exercise linked right after the requirements below.

How to approach

In an interview you do not start by drawing boxes. You turn a short, vague prompt into a clear contract: who is booking, what must the system do, how well must it do it, and what is out of scope. Only then do you size the problem, make the design choices one at a time, and draw the result. The list below is the order this page follows.

How to design a vaccine booking system in an interview

  1. Clarify the problem: who signs in, how a last slot should behave, which fairness rule applies on release morning, and who is the source of truth for the slots.
  2. Write the functional requirements (what the system does) and the non-functional requirements (how fast, how big, how reliable, how fair).
  3. Estimate the size: normal traffic, the release-morning spike, how many chairs each clinic really has, and how long records must be kept.
  4. Make the design decisions in order: who decides eligibility, how the crowd is admitted, how slots are stored, how the last slot is protected, how retries stay safe, how browsing stays fast without lying, how reminders are sent, and how the second dose and cancellations fit.
  5. Draw the picture those decisions produce, then walk one booking through it.
  6. Go deeper where the interviewer pushes: the exact booking transaction, repeated taps, rule changes, scaling a famous clinic, and one production failure.

Clarifying questions (say these in the room)

In a real interview the prompt is only a few words: “Design a vaccine booking system.” Before designing anything, ask questions until the problem is clear. Each answer below changes the design, which is why it is worth asking.

You: “How do people sign in, with a government login, a phone code, or an existing health account? That decides which facts about them we can trust when we check whether they may book.”

Interviewer: “Assume a verified login that gives age and home region. Other form fields may be self-reported.”

That answer tells you which facts the server can rely on (age and region) and which it should treat with caution. It also tells you the server must check the rules itself and cannot simply believe what the phone says.

You: “When only one slot remains, do we hold it for a few minutes while the person finishes, or confirm in one step? Either way, we must never double-book.”

Interviewer: “Either a hold followed by a confirm, or a single safe booking step, is fine. Just prevent double booking.”

So the last-slot rule is not negotiable, and you are free to choose how to enforce it. You can write “last slot, one winner” on the board before you draw anything else, and pick between a short hold and a single step later, when the tradeoff is clear.

You: “On release morning, do we admit people first come first served, run a lottery, or give priority to certain groups?”

Interviewer: “Pick one fairness model and defend it.”

Name the model in one sentence, for example “first come first served, in an ordered line.” You will need to show later, in records, that the system really followed it.

You: “Is our database the source of truth for online slots, or must every clinic’s own calendar match ours at every moment?”

Interviewer: “Your system is the source of truth for online slots. Clinics can sync later if needed.”

That keeps you from designing a two-way connection to every clinic’s internal calendar, which is a separate integration project.

You: “Roughly how many people and clinics are there, and how big is the burst when times open? And does the list of open times need to be exact to the second, or may it be slightly behind as long as the final confirm is always exact?”

Interviewer: “Millions of people, thousands of clinic sites, and about 100,000 requests a second at release. Browsing can be a moment behind, but a confirmed appointment must be exact.”

Those numbers feed the sizing section that comes next. The second half of the answer is a gift: it lets the list of times be fast and slightly stale while only the confirm has to be strictly correct.

You: “I want to park payment and insurance billing, building the national login system itself, and a full call-center product, so we can focus on slot safety and release-day traffic. Does that match what you want?”

Interviewer: “Yes, focus on booking under contention.”

If the interviewer later asks about the exact rule engine, audit tables, or retry keys, you do not have to answer yet. Park them until the design decisions, where each one has a natural place.

Functional requirements

Functional requirements describe what the system does. From the answers above, the booking system must:

  1. Show open times by clinic. A person searches by place and time window and sees which times still have room. This is the part people use most.
  2. Decide on the server whether a person may book. The phone can show a friendly hint, but only the server decides, using the current rules, because the rules can change and a phone can be tampered with.
  3. Book one slot for one person. The confirm either creates an appointment or says clearly that the time is gone. It never quietly creates two appointments for one chair.
  4. Move or cancel an appointment, and give the slot back. A cancelled or missed slot returns to the pool so someone else can use it.
  5. Link the second dose to the first. The next dose must use a matching vaccine and respect a minimum gap after the first, so the system has to remember the first appointment.
  6. Explain a denial. When someone is turned down, support must be able to say which rule applied, without exposing private health details.
  7. Send a reminder before the visit. The reminder is a follow-up after the booking is saved, not a part of saving it.
  8. Optionally offer a cancelled slot to a waitlist. This is a bonus, and the design should leave room for it.

Non-functional requirements

Non-functional requirements describe how well the system must do its job. They are the numbers and promises that shape the design.

  1. Correctness of inventory. A slot is never booked twice, and the count never goes below zero. This is the requirement that every design choice must protect first.
  2. Fairness at release. People are let in by a rule they can understand, so the fastest refresh is not the whole contest, and bots do not take everything.
  3. Scale and spikes. Millions of people, thousands of clinics, and a flash of about 100,000 requests a second when times open. Most of the day is just browsing, so the spike is the case the design must survive.
  4. Availability. The site stays up about 99.9% of the time, and when something fails, it fails in a way that is safe: a long wait is acceptable, a wrong booking is not.
  5. Auditability and privacy. Every decision about who may book is recorded in a way support and regulators can read, while raw health details stay out of ordinary logs.
  6. Usability on weak devices. Pages work on a slow phone and with assistive tools, which means the pages must not depend on heavy scripts that only load at full speed.
  7. Visibility. The team can tell whether the whole path from the line at the door to a saved appointment is healthy, not just whether the servers are busy.

Out of scope (and why you park these)

Write a short out-of-scope list on the board so the interviewer sees you can bound the problem.

Payment and insurance billing. Charging a card or filing a claim is a real product, but it steals the interview from the hard part, which is safe inventory under a flash crowd. If payment is needed, say that it should be safe to repeat and should not hold a slot forever without a timeout.

Building the national identity provider. You need verified facts about each person, but you do not need to design the whole login network in this round.

A full call-center and ticketing product. Support needs a way to read the record of a decision, not a complete ticket system drawn on the whiteboard.

Perfect real-time sync with every clinic’s internal calendar. Treating your database as the source of truth for online slots keeps the design honest, and two-way sync is a later integration project.

That is the requirements stage. If you want to practice it before reading on, try the requirements stage on Practice System Design (about 5–10 minutes), then come back for the sizing and the decisions.

Minute pacing (about 40 minutes)

MinutesFocus
0–5Clarify the problem; write functional and non-functional requirements; agree out of scope
5–12Size the problem, then the design decisions and the high-level boxes with one booking story
12–25The last-slot transaction, the line at the door, and rule checks (the deep dive)
25–35Scaling a famous clinic, failure, cancellations and the second dose
35–40One production war story and questions

In the room (how you open): “I’d start by agreeing who signs in and how, what should happen to the very last slot, which fairness rule applies on release morning, and who is the source of truth for the slots. I’ll write down what the system must do and how well it must do it, including the size of the spike, and I’ll say what I’m leaving out, such as payment and the national login system. Only after that will I size the problem and start making design choices, so every box I draw has a reason.”

If you remember one thing: Ask first, write the requirements down, and only then design.

Capacity estimation

Now that the requirements are clear, the next step is to find out how big the problem is, because the size decides which parts of the design are really needed. You do not need exact statistics. You need enough sense of scale that you do not promise something impossible. All numbers below are rough estimates for the whiteboard, to be tuned in the room.

On most days, booking traffic is moderate and mostly people browsing times. On a release day, when a new group becomes eligible, traffic can jump ten times or more compared to a normal day, and for the first few seconds it can be far higher than that. If you design only for quiet hours, release morning will surprise you.

DimensionRough scale (estimate)What this means for your design
Requests when times openAbout 100,000 per second at the peak (from the problem statement)Control traffic before it reaches search and booking
People vs. chairsMillions of people, thousands of clinics, often only tens of chairs per hour at a busy clinicMany people fight over the same few rows
Booking writes at peakThousands per second if nothing slows the crowdKeep each booking short, and split data by clinic or region
Browsing vs. bookingBrowsing is far larger than booking, perhaps 100 browses for every bookingBrowsing can use copies of the data, and only booking needs the real count
Audit recordsOne per decision, kept for yearsStore them separately or split them by time
Reminder messagesSpike the day before visitsSend reminders in the background, never during the booking request

What the numbers imply

  • The spike, not the average, sets the design. An average day looks easy. The first minute of a release is the moment that decides whether the site stays up.
  • Booking writes are small compared with browsing. Even at the peak, only a small share of requests are real confirms, so the careful, slower, exact path can be kept narrow while the fast, slightly stale path handles the crowd.
  • Few chairs, many people means contention. Because a busy clinic has so few times, the same few rows are touched by many people at once, so how each row is updated matters more than raw machine count.
  • Audit data grows for years. It must not share a table with the live inventory, or the live path slows as the record keeps growing.
  • Reminders arrive in waves. Most are sent the day before the visit, so they need their own workers.
  • Do not send every reminder while the user waits on the confirm screen. And when the API says a booking succeeded, that must mean the appointment is saved, not that a text message was already delivered.

Checkpoint: What actually limits the site on release morning, and why will more web servers alone not fix it?

If you remember one thing: The release spike is mostly a crowd problem first, and a database problem second.

Design decisions

We now know what the system must do, how well it must do it, and roughly how big it is. Now we choose. Each decision below answers one question that the requirements raised, and each one rules out an easier idea that would not survive those requirements. Read them in order, because every decision builds on the one before it.

Decision 1: Who decides whether a person may book?

The requirements said that only the server may decide who is allowed to book, and that support must be able to explain a denial later. The simplest idea is to check the person’s age in the app and only show them the slots they qualify for. That is quick to build and gives a smooth screen.

It fails the moment someone changes the request or runs a script, because the phone is not under our control. It also fails because the rules change. A new age group opens, a postcode is added, or a mistaken rule is rolled back, and a check made a few minutes ago may no longer be true.

So the server decides. It keeps the rules as versioned data, a numbered set of policies such as “version 12: age 50 and above in these regions,” instead of if statements scattered through many services. Each time it decides, it saves a small decision record with the person, the rule version, the yes or no, and a short reason code such as “below minimum age.” That record is what lets support answer “why was I denied?” without searching through logs that contain health details. The phone can still show a friendly “you look eligible” hint, but it is only a hint, and the server asks the question again at the moment of booking (the reason is in the deep dive).

Decision 2: How do we let people in when times open?

On release morning about 100,000 requests a second arrive. The simplest idea is to let them all in and add more web servers. Many people try this first, because adding servers feels like the standard answer to more traffic.

It fails against the availability requirement. Every extra server just forwards more callers to the same slot rows in the same database, so the database melts however many servers sit in front of it. It also fails the fairness requirement, because whoever refreshes fastest wins.

There are a few alternatives. A lottery picks random winners from everyone who signed up, which is very fair but changes the product. Priority groups let certain groups go first by published rules. First come first served in an ordered line is the closest to what people expect.

We choose a waiting room at the front, in line with the fairness model you named in the clarifying questions. People join a line at the edge of the network (the content delivery network or the API gateway). The line lets people through at a fixed rate and gives each admitted person a signed admission token, a short-lived pass the server can verify without asking anyone. Only requests carrying a valid token reach search and booking. People may wait, but the database stays healthy enough to serve the ones who get in. The waiting room trades user waiting time for database safety, and that is a cost you accept on purpose.

Decision 3: How are slots stored?

Booking needs a record of how many chairs each clinic has at each time. The first idea is a single national counter of “slots remaining.” It is simple, and it is also the quickest way to make every clinic wait on the same row.

That breaks the scale requirement, because a busy clinic and a quiet one would line up behind the same lock. It also spreads trouble widely, since one problem on that row would affect the whole country.

Two shapes remain. A counter per slot is one row per clinic and time window that holds how many chairs remain, and the count may only go down while it is above zero. It is compact and fits clinics with few chairs per time. One row per seat gives every physical chair its own row, with a rule that a seat can be booked only once. It is strong against double booking, because the database itself refuses a second winner, but it uses more rows and makes search add up the free seats.

We choose a counter per slot, split by clinic (stored by clinic or region so one famous clinic cannot slow another), with one row per seat kept as a stronger alternative if the interviewer worries about lost updates. We also keep a separate pool for walk-ins at each clinic, so a flash of online traffic cannot use up the chairs reserved for people who arrive at the door.

Decision 4: How do we protect the very last slot?

Now that slots live in rows, two people can still touch the last one together. The simplest idea is to read the remaining count, subtract one, and write it back:

t0  Person A reads remaining = 1
t0  Person B reads remaining = 1
t1  A writes remaining = 0 and confirms
t1  B writes remaining = 0 and confirms
    two families, one chair

Both people read “1 left,” both thought the chair was theirs, and both were confirmed. This breaks the one requirement we said must always hold. Adding a second server does not change that, because two servers can each read the same number before either has written.

The alternatives are to put the whole booking inside one short database transaction (a group of steps the database runs as a single unit, so nothing else can slip between them), to use one row per seat with a uniqueness rule, or to use a hold then confirm flow where the slot is reserved for a few minutes while the person finishes. A hold is kinder to someone typing details, but held slots that never get confirmed need a timer and a cleanup job.

We choose the one short transaction as the default: re-check that the person may book, lock the slot row, check that something remains, decrease the count, save the appointment, and commit. If nothing remains, the second person receives a clear “slot gone” answer (HTTP 409). A hold is added only if the product genuinely needs several minutes of checkout.

Decision 5: How do we keep a retry or a double tap from booking twice?

Even with a safe transaction, a person on a weak connection can tap Confirm twice, or the phone can retry because the first answer was lost on the way back. The simplest idea is to treat every request as new. Then one intention becomes two appointments for two different chairs, which wastes a slot and confuses the person.

The answer is an idempotency key, a unique id the phone creates once per Confirm tap and sends with the request. The server saves the key with the first successful booking. If the same key arrives again, the server returns the same appointment instead of making a new one. This keeps repeated requests harmless without blocking real new bookings.

Decision 6: How do we keep browsing fast without lying?

Millions of people will browse times for every person who books. The simplest idea is to read the live count from the main database each time. That keeps the numbers exact, but it sends the entire browsing crowd to the one place that must stay free for confirms.

So browsing uses copies of the data (read replicas or a cache) that may be a second or two behind. That fits the requirement we agreed with the interviewer, because a list of times is only a hint. The price is that a person may pick a time that has just gone, so the page should say “availability is confirmed at checkout,” and the confirm step always rechecks the real count on the main database. Browsing shows what was probably free a moment ago, and booking is the moment you actually take the slot.

Decision 7: How do reminders and other follow-ups run?

After a booking is saved, the system sends a reminder, may update a calendar, and records analytics. The simplest idea is to do all of that inside the confirm request. Then a slow text-message provider makes every booking slow, and a failed message might seem to undo a valid booking.

So the confirm request only saves the appointment and an outbox entry, a small row saying “send a reminder for this appointment,” in the same transaction. Background workers read the outbox and send messages, retrying when a provider is slow. A missed text never deletes the appointment, and the booking answer means the appointment exists, nothing more.

Decision 8: How do the second dose and cancellations fit?

Two more requirements remain: the second dose must follow the first, and a cancelled slot must come back. The simplest idea is to treat every visit as an unrelated booking, and to run a nightly cleanup that adds cancelled seats back to the pool. That loses the link between doses, and the slot stays missing until the cleanup runs, while someone else could have used it.

Instead, each appointment stores the vaccine type and the dose number, and a rule (stored with the other rules) requires the matching product and a minimum gap after the first dose. When dose one is confirmed, the system can offer second-dose slots in a later window, through the same booking transaction so inventory stays exact. Cancelling or missing an appointment returns the slot in the same style of safe update as booking it, and an optional waitlist worker, fed from the outbox, offers it to the next person with the same safe claim.

Putting the decisions together

Taken together, the eight decisions are the design. A crowd waits in a line at the edge and passes with a signed token. The server decides who may book from versioned rules and records the reason. People browse times from fast copies that may lag. A confirm repeats the rule check and takes the slot in one short transaction on the main database, tied to an idempotency key so repeats are harmless. Reminders are sent afterward from an outbox, and the second dose and cancellations use the same safe update.

In the room (a fuller opening you can actually say): “Eligibility is decided on the server with versioned rules, and every decision saves its rule version and a reason code so support can explain it. On release morning a waiting room at the edge admits people at a fixed rate and gives each a signed token, so the database only sees the people who got in. Browsing uses read copies that can lag a second, and the confirm always rechecks on the primary. Booking is one short transaction: re-check eligibility, lock the slot row, make sure something remains, decrement, insert the appointment, commit. If nothing remains, the person gets a 409. The request carries an idempotency key so a double tap returns the same appointment. Reminders go out afterward from an outbox, so a failed text never cancels a booking. Second doses and cancellations use the same safe update, and if anything about correctness is unclear I fail closed.”

The next section draws these decisions as one picture and shows who owns what.

High-level architecture

The decisions above were made one at a time. This section puts them on one page as a picture: which boxes exist, who owns what, and how one booking travels through them. The deeper mechanics come later, so keep this at the level of a map.

What breaks if you merge everything

Imagine one service that uploads files, checks eligibility, updates slot counts, sends email, and writes analytics, all in one slow step. At peak, a person waits for the slowest part, so a simple confirm can get stuck behind unrelated work. The design also fails if each server keeps its own copy of “slots remaining,” because two servers can both think one chair is left, and it fails if debugging logs hold readable health data, which breaks trust.

What works: separate rules, inventory, and audit

Break the system into clear responsibilities.

Identity answers “who is this person?” through a government login or phone verification, and it is needed before eligibility and before tying an appointment to someone.

The rules service loads the current policy (age, location, dose rules) as versioned configuration and returns whether the person may book, saving which rule version it used.

Search lets people browse clinics and times. It is read-heavy and may use copies that are slightly out of date, as long as the confirm rechecks.

Booking updates inventory on the main database in one safe step: confirm eligibility, lock the slot, decrement the count, save the appointment.

Audit keeps a durable record of decisions, especially denials, so support can explain them later.

Notifications send reminders after the appointment is saved, through a background queue, so email or SMS delays do not block booking.

[ User ] --> [ CDN / static ] --> [ Waiting room edge ]
                    |
                    v signed admission token (rate limited)
[ Eligibility API ] --> Rules engine (versioned) --> decision + audit
        |
        v
[ Slot search ] --> read-optimized (may be slightly stale)
        |
        v
[ Book slot ] --> [ TX: decrement remaining OR lock row ] --> confirm
        |
        +--> outbox --> reminders / calendar / analytics (async)

The diagram below shows the same flow: users pass through admission control, eligibility runs before browsing, and booking commits on the primary database while reminders run later.

High-level flow from user through waiting room, eligibility, slot search, transactional book, and async notifications

Figure: Search results may lag slightly. Booking always re-checks eligibility and slot count in one transaction on the primary database.

In the room: Narrate one booking from left to right: join the line, receive a token, pass the eligibility check, browse times, confirm in one transaction, then reminders from the outbox. Then say: “Search is a hint, booking is the lock.”

Three short phrases help you sound precise, and each answers a follow-up interviewers often ask.

  • A successful book response means the appointment row is saved. When the booking call succeeds, you are promising the row exists in the primary database, with the count decreased inside one transaction. Do not call it done only because a reminder job was queued.
  • Email and SMS come afterward. Messages run from a background queue after the commit. If the provider is slow or down, the appointment still stands, and if booking fails you never send a confirmation that would confuse support.
  • Search is a hint, and booking is the lock. Search may be a second or two stale, which is fine while someone is picking a time. At booking you recheck the current rules and the current slot count on the primary.

If you remember one thing: Draw the line at the door first, then the one safe booking step, and push everything else, like reminders, to the side.

Core design approaches

The architecture used a few choices that have real alternatives, and interviewers want you to compare options, not name one database and stop. This table puts those alternatives side by side.

ApproachPlain ideaGood whenWatch out
Counter per slotOne row per time slot; decrease count only if above zeroFew seats per slot; simple designOne popular clinic can create a hot row many requests fight over
One row per seatEach physical seat is its own row; only one booking allowedStrong protection against double book under loadMore rows; search must add up available seats
Hold then confirmSlot moves from available → held → confirmed with a time limitA person needs a few minutes to finish checkoutHeld slots that never confirm need cleanup
Waiting room tokensEdge lets in a fixed number of users per secondNational release at a fixed timeQueue order (first-come vs lottery) is a product choice, so state yours
Rules as dataPolicy lives in versioned config, not only in codeRules change often during rolloutA bad deploy needs a quick rollback to the prior version

For the last available slot, use either a safe counter update inside one database transaction or one row per seat with a rule that rejects a second booking. For release day, control traffic at the edge instead of hoping the database survives unlimited refreshes. When millions of people open the site at the same second, every refresh cannot become a search and a book call against the primary database, and “add more app servers” does not fix that, because each new server just forwards more traffic downstream.

Data model

The architecture names the pieces, so the next question is what exactly each one stores. Saying “we use a database” is not yet a design, because you have not said what the records look like. These are the main records interviewers expect you to name.

Inventory and appointments

RecordWhat it storesWhy it matters
clinicLocation, capacity settingsLets you split load by clinic so one busy site does not slow the others
slot or seatTime window, remaining count or one row per physical seatThe row you lock at book time
appointmentUser, slot/seat, status, vaccine type, dose number, idempotency key, timestampsProof the booking exists, and links dose one to dose two
hold (optional)Temporary reservation with expirySupports hold-then-confirm
outboxPending reminder or waitlist event tied to an appointmentLets background workers act after the commit

Rule of thumb: If you use a counter, never allow remaining to go below zero, for example with a database check rule. If you use one row per seat, a unique constraint on “this seat is booked” prevents two winners. A unique constraint on the person and the idempotency key keeps a retry from creating a second appointment.

Eligibility and audit

RecordWhat it storesWhy it matters
rules_vNVersioned policy (age, region, dose)Rollback and explainability
eligibility_decisiondecision_id, user, rule_version, allow/deny, reason codesSupport can answer “why was I denied?”
Admission token claimsUser/session id, expiry, signatureWaiting-room proof without trusting the client alone

Keep audit data separate from noisy application logs. Audit is durable and access-controlled, while debug logs are not where private health details belong.

Detailed design

We now know what is stored and who owns it, so we can put the pieces in motion. This section follows one real booking, from the moment a person joins the line until they either hold a confirmed appointment or are told the time is gone. Then it shows the same thing from the caller’s side: the calls a client makes, the answers it receives, and the small admin calls the operators use. Read it once as a story. The exact transaction and the follow-up questions come in the deep dive right after it.

One booking, step by step

A person opens the site when times are released and lands in the waiting room. The waiting room admits people at a fixed pace, and when their turn arrives it gives them a signed admission token that expires after a short time. Every later call carries that token, and a call without a valid token is turned away at the edge before it reaches the booking system.

Once inside, the person is already signed in, and the server knows their verified age and region. They ask whether they may book, and the rules service loads the current rule version, decides yes or no, and saves a decision record with the rule version and reason codes. The person may remember this answer on screen for a moment, but it is only a guide.

They then browse. The search call reads from fast copies of the inventory and returns clinics and times near them. These results can be a second or two behind, and that is fine because the person is choosing a time, not taking it.

When they tap Confirm, the phone sends the booking request with an idempotency key. Now the server stops guessing. In one database transaction it loads the current rules and checks again that this person may book, locks the slot row, checks that at least one chair remains, decreases the count, saves the appointment, and writes an outbox entry for the reminder. It commits and only then answers success. If no chair remained, the transaction ends without changes and the person receives a clear “slot gone” answer.

After the commit, background workers read the outbox and send the reminder, update the calendar invite, and record analytics. If the text provider is down, the workers retry, and the appointment stays valid. If the database in this region is unhealthy, the server does not guess, and it stops new bookings in that region until it recovers.

  1. Join the line; receive a signed admission token.
  2. Ask the server whether you may book; it records the rule version and reason.
  3. Browse times from fast copies that may lag.
  4. Confirm with an idempotency key.
  5. One transaction: re-check rules, lock slot, check remaining, decrement, insert appointment, write outbox, commit.
  6. Return success, or 409 if the slot is gone.
  7. Reminders and invites go out afterward from the outbox.
Phone → Waiting room → token → Eligibility → Search (copies)
Phone → Confirm + Idempotency-Key → Book (primary DB, one TX)
       → 201 appointment   |   409 slot gone   |   403 not eligible
Outbox → workers → reminder / calendar / waitlist

API design: what callers see and what operators change

The booking calls are the product’s own public interface, so the interface needs to be small and clear. It covers three things: the calls the app makes, what comes back, and how operators change rules and capacity.

The calls the app makes.

EndpointRole
POST /v1/eligibility:evaluateCheck the rules; return a decision id and the rule version
GET /v1/slotsSearch by location and time
POST /v1/appointmentsBook a slot; requires an Idempotency-Key header
DELETE /v1/appointments/{id}Cancel according to policy; the slot goes back to the pool

GET /v1/slots parameters

ParamRole
lat, lng, radius_kmFind centers near the person
from, toTime window
rule_versionOptional hint; the server still validates

The usual flow runs in three steps: check eligibility (the server decides with rule_version), browse times on the read path (knowing results may lag), then book in one safe transaction on the primary with the idempotency key. Do not merge browsing and booking into one ambiguous “reserve” call that leaves inventory unclear.

Three-step API flow: eligibility evaluate, slot search, transactional book with idempotency key

Figure: Idempotency-Key makes duplicate submits safe. HTTP 409 means the slot is gone, so ask the person to pick another time.

What the client receives. A successful booking returns 201 Created with the appointment id, the clinic, the time, and the dose number. If the same Idempotency-Key arrives again, which is common on a mobile retry, the server returns the same appointment id as the first success, and the app treats it as “already booked.”

Which status code means what. A 409 means the slot is no longer available, and the app should offer other times. A 403 means the person is not eligible under the current rules, and the answer includes a reason code that the app maps to plain wording in the person’s language. A 401 means the person is not signed in, or the admission token is missing or has expired, so the app should send them back to the waiting room. A 429 means the person is sending requests too quickly and should wait. Keep 409 and 403 apart, because one means “try a different time” and the other means “you cannot book yet.”

How operators change things. A small internal admin API lets the team change rules and capacity without redeploying everything.

POST   /v1/admin/rules                 # publish a new rule version (canary first)
POST   /v1/admin/rules/{v}:rollback    # switch back to a prior version
PUT    /v1/admin/clinics/{id}/slots    # add or change capacity; keep walk-in pool separate
GET    /v1/admin/decisions/{id}        # support reads why a person was denied

In the room: “Three public calls: evaluate, search, and book. Booking needs an idempotency key and returns 201, 409 or 403. Operators publish and roll back versioned rules through an admin API, and support reads the decision record, not raw logs.”

Deep dive: the questions an interviewer asks next

You have drawn the design and walked one booking through it. This is the point where a good interviewer starts digging, and the questions usually come in a fairly predictable order, because each answer raises the next one. Read this section as that conversation. Each question is followed by an answer you can give, plus a hint of where the interviewer is likely to go next. When the next question is already obvious from your answer, you can volunteer it before they ask.

“Ten million people refresh at 8:00. Why not just add web servers?”

More web servers mean more callers reaching the same slot rows. The bottleneck is the inventory in the main database, and each new server forwards its share of the crowd straight to it, so nothing is protected. Release day is an admission-control problem before it is a database-capacity problem.

The waiting room has a clear life cycle. A person joins the line, and the edge admits people at a fixed number per second. Each admitted person receives a signed token with an expiry. Only requests carrying a valid token reach eligibility, search, and booking.

The fairness model shows up here. First come first served is enforced by the order in the line, and you can prove it with the join time and the admission time stored for each token. A lottery draws random winners from the people who joined within a window, and a draw id proves it. Priority groups use a published rule version. Whichever you pick, the records must let support answer “why did they get in before me?”

A few details come up: server clocks must agree closely enough that tokens do not look expired when they are fresh, older app versions must not be blocked by a missing header, and bots need extra friction such as a challenge or device signals.

Where it goes next: the interviewer will probably ask what happens once people are inside, when two of them reach for the last chair.

“Two people tap Confirm on the last slot. Walk me through it.”

Start with what goes wrong without a safe step. Both read “1 left,” both subtract one, and both get confirmed, as the earlier example showed. The fix is to make the check and the update one indivisible step.

BEGIN
  re-check eligibility for current rule_version
  LOCK slot/seat row
  IF remaining > 0 (or seat free)
    decrement / mark booked
    INSERT appointment (+ outbox row)
    COMMIT → 201
  ELSE
    ROLLBACK → 409 Conflict

The same idea can be written as a single guarded statement, which is shorter and avoids holding a lock for long:

UPDATE slot
   SET remaining = remaining - 1
 WHERE slot_id = :id AND remaining > 0;   -- 0 rows changed means the slot is gone → 409

Walk the race. Person A and person B both send their confirms in the same millisecond. The database processes A’s update first, and the count goes from 1 to 0. When B’s update runs, the condition remaining > 0 is false, no row changes, and B is told the slot is gone. Neither person could see the other’s half-finished work, because there was no half-finished work to see. Search can be stale, but booking is the lock: one transaction, one winner.

Where it goes next: “Why check eligibility again inside that transaction?”

“You already checked eligibility. Why check it again at booking?”

Because eligibility is not a stamp you can reuse. A person might pass the check at 9:00 and see “you look eligible,” then spend five minutes choosing a clinic and a time. By 9:05 the policy may have changed: a new age group opened, a postcode was removed, or operators rolled back a mistaken rule. If you only checked once at the start, you could confirm an appointment that the current rules would reject.

So at booking the server loads the current rules, asks again whether this person may book, and only if the answer is yes takes the slot and saves the appointment, all in the same transaction. It also saves a decision record containing the rule_version and reason codes, so support can later say exactly which rule applied. The earlier “you’re eligible” screen was a guide. The real decision happens at Confirm.

Where it goes next: “And if the person taps twice, or the answer never reaches the phone?”

“What if the person taps twice, or the response gets lost?”

Mobile networks drop responses, and people double tap. Without protection a timeout retry creates a second appointment for the same intention. The idempotency key solves this. The server stores it with the first successful booking, protected by a unique constraint on the person and the key inside the same transaction, so even two simultaneous copies cannot both succeed.

On a repeat, the server finds the key, skips the booking step, and returns the same appointment id with the same success answer. The phone shows “already booked,” and the person stays safe. It is worth saying what the key does not do: it protects the same intention being repeated, and it does not stop one person from deliberately booking two different slots, which is handled by a rule on one active appointment per dose.

Where it goes next: “Okay, what about the second dose?”

“How does the second dose fit the model?”

Link the appointments for the same person. Each appointment row stores the vaccine type and the dose number. A rule stored with the other versioned rules requires the same product and a minimum gap after the first dose. When dose one is confirmed, the system can offer second-dose slots in a later window, and booking one still goes through the same transaction, so inventory stays exact.

Cancelling dose one needs a policy. It may invalidate a linked dose-two appointment, or move it to a later window, and the rule says which. Say that you would write this in the rule data instead of in scattered code, so a change is a new version and not a deploy.

Where it goes next: “And when someone cancels or doesn’t show up?”

“What happens on a cancellation or a no-show?”

The slot must go back to the pool in the same style of safe update that took it. A cancel increases remaining (or frees the seat row) inside a transaction. A scheduled job marks no-shows after a grace period and does the same. Both write an outbox entry, so an optional waitlist worker can offer the freed slot to the next person with the same atomic claim. If policy limits repeat offenders, a no-show count per person is kept on the person’s record. A cleanup job that later adds seats back is the weaker option, because the chair stays unavailable until it runs.

Where it goes next: “Does a successful booking mean the text has gone out?”

“Does a 201 mean the confirmation message was sent?”

No. A 201 Created means the appointment row was committed in the database. The reminder is written to the outbox in the same transaction and sent afterward by workers. If the text provider fails, the workers retry and raise an alert when the dead-letter queue grows, and the appointment is still valid. Say this clearly in the interview so you do not confuse inventory truth with message delivery.

Where it goes next: the interviewer may now ask what breaks as this grows, which is the next section.

Say it in the interview: “One short transaction on the primary: check eligibility, lock the row, make sure something remains, decrement, insert, commit, and use an idempotency key so repeats are harmless. Search can be stale. Booking is the lock.”

If you remember one thing: Read-then-write is the red flag, one short transaction is the fix, and the waiting room protects it from the crowd.

Key challenges

The deep dive showed that the booking step is simple once it is safe. What makes the real system hard is everything around that step, and a few hard parts come up again and again. Name them early in the interview, because each one is a place the interviewer is likely to push.

ChallengeWhat people see if it goes wrongWhat to say in the interview
Rules changed since last check“I was eligible earlier but denied now”Re-check eligibility and inventory together at book time
Double click or retryTwo confirmations for one attemptIdempotency-Key plus database uniqueness rules
BotsSlots gone in seconds; real people shut outCAPTCHA, rate limits, staggered release windows
Hot clinicOne famous site is slow for everyone booking thereSplit data by clinic; per-clinic 409 rate as a signal
ReportingNews about leaked health dataAggregate reporting with strict access controls
Clinic calendar syncDesk disagrees with the appYour saved appointment is source of truth; sync calendars in the background

Correct inventory and clear explanations matter more than extra features in public-health booking systems. People forgive a long queue more easily than a wrong denial or a double-booked chair, and journalists and regulators will ask for proof, not a prettier homepage.

If you remember one thing: Re-checks at book time and a fair, provable line are design requirements, not polish.

Scaling the system

Those hard parts get worse as demand grows, so the next question is what changes when more people and more clinics are added. You do not have to wait for the interviewer to ask. Right after you finish the design, say the scaling story yourself, then be ready for the follow-ups.

What you can say upfront: “Browsing scales with copies and caches, because it can be slightly stale. Booking writes stay on the primary database for each region and are split by clinic or region so one busy hospital does not block the country. The waiting room caps how fast people reach booking, so adding web servers never floods the database. Reminder workers scale on queue depth, separately from booking traffic. Health and identity data may have to stay in its home country, so booking writes run in the region that owns the data.”

That one paragraph answers most of what follows. Here are the follow-ups, in the order they usually come.

Interviewer: “Traffic is ten times larger next release. What do you change?”

You: “The waiting room and the read side first, since they are the easy half. I add read copies and cache capacity for search, and I check how many people per second the waiting room admits against what the booking path can finish. I do not add more booking servers hoping that helps, because the limit is the inventory rows, so I watch booking latency and the rate of 409s before I change anything.”

Interviewer: “One famous clinic is on the evening news. What happens?”

You: “That clinic’s slot rows become hot, because many requests fight over the same few records, and the rest of the country should not feel it. I store slot data partitioned by clinic or region, so the contention stays on that partition. If it is still too busy, I can give that site its own partition and lower the admission rate for it. The tradeoff is that people who wanted that clinic wait longer, which is better than a slow site for everyone.”

Interviewer: “Can search read from the primary to stay exact?”

You: “I would not. Searching is the largest share of traffic and would crowd out the confirms. Search reads copies that can lag a second or two, and the confirm rechecks on the primary. I measure the stale conflict rate, meaning how often someone sees a time and loses it at confirm, and tune cache freshness from that.”

Interviewer: “What about more than one country or region?”

You: “Some countries require health and identity data to stay in-country. I serve browsing from nearby infrastructure when I can, but booking writes run on the authoritative database for that region. A person in region A must not book rows that legally live only in region B.”

Interviewer: “How do reminders scale?”

You: “They spike the day before visits, so I scale workers on queue depth, not web CPU, and keep them on separate workers so they never compete with live booking.”

What to watch: the rate of “slot gone” answers (409) per clinic. A high rate at one site often means stale search, a hot inventory row, or demand far above supply, not simply impatient people.

If you remember one thing: Scale browsing with copies, scale booking by splitting by clinic or region, and let the waiting room set the pace.

Failure handling

Scaling answers “what if there is more demand.” This section answers “what if something breaks.” Again, say it first, because what impresses an interviewer is that the answer was decided before the failure happened.

What you can say upfront: “When in doubt about correctness, I fail closed: if the rules cannot be checked, or the database in a region is unhealthy, I stop new bookings in that region instead of guessing slot counts, because a long queue is forgiven and a double booking is not. Reminder failures never undo a booking. A wrong rule deploy is handled as an incident: pause bookings, roll back the rule version, and use the decision records to find affected people.”

The follow-ups are about the details of those decisions.

Interviewer: “The rules service is down. What does a person see?”

You: “They cannot start a new booking, and I say so plainly on screen. I block new eligibility checks until it recovers instead of letting people through on a guess, and I keep the waiting room open so people are not lost. Appointments already saved are not affected.”

Interviewer: “The database in one region is unhealthy.”

You: “Booking fails in that region and I fail closed there. I do not guess slot counts or send people to another region’s rows, since the data may legally need to stay put. Search can keep serving from copies with a banner that availability will be confirmed later.”

Interviewer: “A wrong rule goes live. Operators set the minimum age to 18 when it should have been 65. Thousands booked overnight.”

You: “I treat it as an incident. First stop new bookings so I do not make it worse. Then switch back to the previous rule version. Then look up who booked under the bad version using the rule_version stored on each decision, and cancel or fix appointments if policy says I must. Then tell people honestly what happened. This is why rules are versioned and every decision records its version.”

Interviewer: “The reminder text provider is failing.”

You: “The appointment still exists, because the reminder only runs after the commit. Workers retry, and an alert fires when the dead-letter queue grows. People might need a second channel, such as email, but no booking is lost.”

Interviewer: “The waiting room itself breaks.”

You: “I give it its own on-call owner and runbook. If it admits too few people, I widen admission when policy allows. If its tokens fail validation because clocks differ or an old app lacks a header, I watch the token failure rate and fix it fast, because from the outside the whole site looks down while my servers look idle.”

ScenarioWhat the user seesWhat to build
Rules service downCannot start a new bookingBlock new checks until recovered; keep the line open
Database trouble in one regionBooking fails thereFail closed in that region; do not guess slot counts
Reminder email failsNo email, but appointment still existsRetry reminders; alert if messages pile up dead
Wrong rules deployedWrong people booked or deniedPause bookings; roll back rule version; re-check affected people
Waiting room too strict or brokenHours in line, idle serversWatch token issue and failure rates; own runbook

If you remember one thing: Fail closed on booking correctness, and decide the reminder and waiting-room behavior before the day.

Observability (what you measure)

Once the system is live, you need a way to tell whether it is healthy, and a single number is not enough. Watching only server CPU misses the case where the line at the door is hours long while every server sits idle.

SignalWhy it matters
Tokens issued per second, token failures, and how many people who leave the line finish a bookingShows the whole journey, not just the servers
Booking latency at the slow end (p99, the slowest 1% of requests) and rate of 409 “slot gone” per clinicFinds hot clinics and stale search
Stale conflict rate (seen a time, lost it at confirm)Tunes how fresh search needs to be
Eligibility errors by rule_versionCatches a bad rule deploy fast
Outbox age and dead-letter queue size (messages that failed too many times)Reveals reminders piling up

Alert ideas: queue wait far above plan while origin CPU is low; 409 rate at one clinic far above others; any duplicate or negative inventory row (treat as a severe incident); sudden rise in denials after a rule deploy.

Security and abuse

A booking site is also a target, so this section covers how to keep it honest. Check who the person is (authenticate) before eligibility and booking so anonymous callers cannot burn slots or probe other people’s appointments. Prefer verified login attributes over self-reported fields when the rule depends on them. Cap how fast any one person can call eligibility and booking (rate-limit those paths), and pair the waiting room with bot controls (a challenge page, device signals) when release-day abuse is likely. Do not put age, medical history, or other sensitive details in ordinary searchable application logs. Save structured reason codes and rule_version in an access-controlled audit store instead, so support reads the audit record while engineers debug with redacted logs. Stolen sessions need a fast way to cancel them (revoke), and admin rule changes should go to a small slice of traffic first (canary) with a one-step rollback, because a bad age rule is a security and fairness incident, not only a configuration mistake.

Cost awareness

Every choice so far also has a price, and interviewers like to hear that you noticed. Every double booking wastes clinic time, trust, and overtime support. Every release-day outage wastes public confidence even if “the servers were busy.” A waiting room trades user waiting time for database capacity, which is an explicit cost you accept to keep writes correct. Read copies and caches make search cheap, but overusing them for inventory writes creates waves of “slot gone” (409) answers and angry callers. Audit storage costs money for years, so store compact reason codes, not full profiles, and split it by time. Reminder senders should scale on queue depth so message spend and worker cost peak the day before appointments, not during the live booking request.

Green Dashboard. Angry Users. The Production Mindset System Design Interviews Expect.

Everything so far describes how the booking system should work on a good day. This section is about a bad day, told as short stories from the people who carry the pager (the on-call engineers). Textbooks teach boxes and arrows. On-call teaches this: the graph can look fine while users are furious.

One service returning HTTP 200 (a plain “ok” status) is not a finished booking. A push notification marked “delivered” is not proof the slot was saved. Interviewers like this gap because it separates diagram-only answers from people who have thought about launch day.

Three nightmares that look “healthy” on a dashboard:

What the dashboard showsWhat is actually happening
The status page says every system is operational.People sit in a virtual queue for hours because almost no traffic is reaching the booking APIs.
The book API reports a low error rate and normal latency.Two families receive confirmation emails for the same clinic chair at the same time.
A log line only says not eligible with no other detail.Support and angry callers have no way to explain which rule blocked the booking.

Track the whole journey, from the line at the door through the booking to the saved appointment row, not one green metric in the middle.

Scene 1: The queue that never moves

The moment: It is eight o’clock on a Monday morning, and a new age group has just become eligible. National news runs the story, millions of people open the booking site, the homepage loads, and social media fills with “the site is broken.”

The trap: The servers look idle because most people never get past the waiting room. The real bottleneck is at the front door, not the database. The line may admit too few people per second, reject valid people because server clocks do not match, or block older app versions that stopped sending a required header. Teams often test only the booking call in a lab and never follow the full path a real phone takes: join the line, get a token, search slots, book.

What to build:

  • Watch how many tokens you hand out, how often they fail, and how many people who leave the line finish a booking, not just whether your servers are busy.
  • Give the waiting room its own on-call owner and runbooks, for example to widen admission when policy allows.
  • Rehearse the full browser funnel before every known release day.

Scene 2: Two families, one chair

The moment: The health department’s support desk gets the call nobody wants: two families received confirmation emails for the same clinic slot, and both arrived on the same morning.

The trap: Two booking requests both read “1 slot left” before either write finished, or search and cache still showed the slot after the primary database had sold it. Sending the confirmation email twice is annoying; promising the same chair twice destroys trust, and the inventory update is the part that must never race.

What to build:

  • One short transaction: lock the row, check the count, decrement only if still positive, insert the appointment, and otherwise answer 409.
  • A database rule that forbids negative inventory.
  • Treat every duplicate or negative row as a severity incident, not background noise.

Scene 3: “Not eligible”, with no explanation

The moment: A person who was turned down calls the help line, and a reporter calls the department asking which rule blocked the booking. The only line in the log says not eligible.

The trap: Rules lived only in code with no version history, and support has no read-only view. Engineers had removed personal data from logs and accidentally removed every useful detail along with it.

What to build:

  • An audit store with rule_version and plain reason codes (“below minimum age”, “outside eligible postcode”).
  • Strict access controls, separate from noisy debug logs.
  • Support reads the audit record, and the person gets a human answer.

Scene 4: CPU is calm. The funnel is not.

The moment: On another release morning, people have been waiting in the virtual line for hours. Alerts fire because queue wait is far above plan, yet the booking servers show almost no work—their CPUs are nearly idle. The team adds more web servers, and nothing improves, because the bottleneck was never those servers; it was how slowly the waiting room lets people through.

Waiting room caps tokens per second while a large queue waits; origin load stays flat

Figure: A flat CPU graph can hide a queue that is hours deep.

The trap: Everything the dashboard measures sits behind the line, and the line is the part that is slow. Watch end to end: queue wait, time to a committed row, the 409 rate at checkout, audit write delay, and rule errors by rule_version. Compare regions so one bad edge configuration does not look like a national outage.

In the interview: Pick one scene. Tell it like a short story: what people felt, what metric lied, and what you would ship next. You do not need all four. You need to sound like someone who knows green is not the same as done.

Bottlenecks and tradeoffs

Those stories all trace back to a small number of choices where you cannot have both things you want. Interviewers listen for whether you can name the tension, say what breaks, and pick a side on purpose.

Fairness vs velocity

The tension: On release day you want slots to fill fast, but people also need to believe the process was fair. If they think bots or insiders jumped the line, the site can stay online and you still lose public trust.

What “fair” can mean (pick one and say it aloud in the interview):

  • First come, first served. Whoever reaches the booking step first gets the slot, backed by queue order and timestamps.
  • Lottery. Demand is too high for everyone to refresh at once, so winners are drawn at random from the eligible pool.
  • Priority groups. Certain groups go first by policy (age, job, location), with clear rules everyone can read.

What to build: Whatever model you choose, the system must prove it in records: queue position, admission token time, lottery draw id, or priority rule version. Support should answer “why did they get it and I didn’t?” without guessing.

In the interview: Name your fairness model first, then explain how code enforces it (waiting room, tokens, audit rows), not just “we use a queue.”

Stale search vs fresh booking

The tension: People want the list of open times to feel instant, and they also want the time they pick to still be free when they confirm. Search can use read copies or a cache to stay fast during spikes. Those results may be a second or two behind the main database. That is usually fine for browsing if booking always checks the main database in one safe step.

People get frustrated when they select a slot, wait on checkout, and then hear it is already taken. Clear wording (“availability is confirmed at checkout”), a fresh check at booking, and tracking how often this happens help you tune caching.

In the interview, say the line plainly and explain each half:

  • Search is a hint. When people browse, the app reads from fast copies so the site does not melt under load. The list can be a second or two out of date, and that is fine while the person is only looking. Tell the interviewer you never treat search results as a promise.
  • Booking is the lock. When the person taps Confirm, you stop guessing. In one transaction on the primary database, re-check eligibility and ask again whether the slot is free. If yes, take it and save the appointment. If no, return 409 (“slot gone, pick another time”).

Waiting time vs database safety

The tension: The waiting room makes people wait, which feels bad, but it is what keeps the database writable.

What breaks: Too strict a line, and hours of waiting while servers idle. Too loose a line, and the database melts.

What teams do: Start from what the booking path can finish per second, set the admission rate a little under that, and raise it as the 409 rate and latency stay calm.

Say in the interview: “The line is a deliberate cost: I trade waiting time for correct writes.”

If you remember one thing: Name the tension, say what breaks, and choose a side on purpose.

Interview tips

You now have a full design and the tradeoffs behind it, so the last thing to practice is defending it when the interviewer pushes back. These five are the pushes that come up most after you finish the design.

The app can show “you look eligible”, but only the server may decide

In the room

You might say: “The app checks the person’s age on the phone and only shows slots they qualify for.”

Interview Push: “What if the person changes the request or uses a script? Can they still book?”

Land here: The app can guide the person, but only the server decides. At booking time the server loads the current rules, checks age, location, and dose requirements from trusted data, and saves a decision record that includes which rule version was used. If someone tampers with the client, the server still runs the real check. The phone is for convenience, not authority.

Two people can both see “1 slot left”, but only one booking can succeed

In the room

You might say: “We read how many slots remain, subtract one, and save.”

Interview Push: “Two requests hit the last slot at the same time. What happens?”

Land here: Both requests can read “1 slot left,” both subtract one, and both confirm unless you prevent it. Use one database transaction: lock the slot row, confirm the count is still above zero, decrement, insert the appointment, then commit. The second request gets a clear 409 Conflict answer, such as “slot no longer available.” Also use an Idempotency-Key on the booking request so a double tap from the same person does not create two appointments.

Millions refresh at the same second, so more web servers will not save the database

In the room

You might say: “We add more web servers when traffic spikes.”

Interview Push: “Ten million people refresh at 8:00 AM. What protects the database?”

Land here: More web servers mean more callers hitting the database unless you slow the crowd down first. Use a waiting room at the edge that admits people at a fixed rate and gives each admitted person a signed token. Only those requests reach search and booking. Waiting in line is frustrating, but it is better than a site that crashes for everyone.

A wrong age rule can let the wrong people book before anyone notices

In the room

You might say: “We can change eligibility rules in production anytime. Just update the config and deploy.”

Interview Push: “Operations sets the minimum age to 18 by mistake instead of 65. Thousands already booked overnight. What do you do?”

Land here: Treat it like an incident, not a quick code tweak. First, stop new bookings until you know how bad it is. Second, switch back to the previous rule version, the one you trust. Third, look up who booked under the bad rule using your audit log (rule_version on each decision), and cancel or fix appointments if policy says you must. Fourth, tell people honestly what went wrong and what you are doing about it. This is why eligibility rules are versioned and every decision saves which version applied. Without that, support is guessing, and reporters will ask questions you cannot answer.

Support must explain a denial without dumping health data in logs

In the room

You might say: “When booking fails, we log the full profile so engineers can debug faster.”

Interview Push: “A person calls support: ‘Why was I denied?’ Your log only says not eligible. What do you tell them, and what are you allowed to store?”

Land here: Separate debugging from explaining. Do not put age, medical history, or other sensitive details in normal application logs that every engineer can search. Do save a small audit record for each decision, holding the rule version that ran and a plain reason code such as “below minimum age” or “outside eligible area.” Give support read access to that audit store, not to raw debug logs, and hide or hash sensitive fields everywhere else. That way support can answer the person in plain language, and you stay within privacy rules without guessing what the system meant at booking time.

Red flags to avoid without correcting yourself: “read the count then subtract,” “add more web servers for the spike,” “check eligibility once on the phone,” “log the full profile,” “reminder inside the booking request.”

After each push, close with one real part of the design you would build, such as a versioned rule check, one safe booking transaction, or a signed queue token, not a vague line like “we will scale it later.”

What should stick

After working through the requirements, the decisions and the depth sections, you should be able to explain:

  1. Versioned rules. The server decides eligibility, and each decision records which rule version applied.
  2. Safe inventory updates. One transaction locks the slot and decreases the count, with no unsafe read-then-write outside that step.
  3. Traffic control on release day. A waiting room limits how fast people reach the booking calls.
  4. Clear denials. Reason codes explain “why not?” without health data in ordinary logs.
  5. Reminders after save. Email and SMS run in the background, and a missed text does not cancel the appointment.

Tell it in the room: “Eligibility runs on the server with versioned rules and an audit record. Spike traffic hits a waiting room first. I book in one safe transaction with an idempotency key. Search may lag, but booking never lies.”

Quick check before a mock: (1) Why can two people both be confirmed for one chair? (2) Why check eligibility again at booking? (3) Why do more web servers not fix release morning? → (1) both read the same count before either wrote (2) the rules may have changed since the first check (3) they all forward the crowd to the same slot rows.

Key Takeaways

  • The server decides who may book, using versioned rules, and saves the rule version and a reason code with every decision.
  • Release day is an admission problem first: a waiting room admits people at a fixed rate with signed tokens, so the database only sees the people who got in.
  • Protect the last slot with one short transaction that re-checks eligibility, locks the row, checks that something remains, decrements and saves, and returns 409 to the loser.
  • Use an idempotency key so a double tap or a lost response returns the same appointment instead of creating a second one.
  • Let browsing use copies that can lag a second or two, and let the confirm be the only place that takes the slot.
  • Send reminders after the commit from an outbox, so a failed text never cancels a valid appointment.
  • Fail closed on booking correctness, split data by clinic or region, and watch the whole journey from queue to saved row, not one green metric.

Quick revision notes

The problem in your own words. A vaccine booking system shows open clinic times, decides on the server who may book, and gives each time to exactly one person, even when millions arrive in the same few seconds. The hard parts are the crowd at the door, the very last slot, and being able to explain every decision.

The design in one breath. A waiting room admits people at a fixed rate with signed tokens. The server decides eligibility from versioned rules and records the version and a reason. People browse times from copies that may lag. Confirm repeats the rule check and takes the slot in one short transaction on the primary database, with an idempotency key so repeats are harmless. Reminders, calendar invites, and waitlist offers run afterward from an outbox.

The choices you must be able to defend. A named fairness model that the records can prove. A counter per slot split by clinic, with one row per seat as a stronger option. A single transaction as the default, with a hold only if checkout takes minutes. Fail closed when correctness is unclear.

The numbers worth remembering. About 100,000 requests a second at release, millions of people, thousands of clinics, and often only tens of chairs per hour at a busy site. These are estimates you would confirm with a load test.

The mistakes that cost points. Reading then writing the count, adding web servers instead of a line, checking eligibility only on the phone or only once, logging full health profiles, sending reminders inside the booking request, and treating a stale search result as a promise.

Frequently asked follow-ups

  • How do you handle flash traffic when slots open?
  • How do you prevent double booking on the last slot?
  • Where and how do you check eligibility?
  • How do second-dose rules work?
  • How do reminders and no-shows fit the design?

Deep-dive questions and strong answer outlines

How do you handle a flash open when millions refresh at once?

I would not let every browser hit slot search and book APIs at full spike rate. A waiting room at the edge admits users in batches and issues a signed admission token at a fixed tokens-per-second rate. Only requests with a valid token reach origin slot search and book. That trades honest queue wait for a database that stays up. I would measure token issue rate, validation failures, and end-to-end funnel from queue exit to committed appointment row—not only origin CPU.

Walk through booking the last available slot under concurrency.

Two users can both see "1 slot left" from a slightly stale search result. Booking must be one short database transaction: begin, re-check eligibility for the current rule_version, lock the slot row (or seat row), verify remaining > 0, decrement, insert the appointment, commit. The second request gets 409 Conflict with clear retry guidance. I would also require Idempotency-Key on POST so the same user double-submitting does not create two rows. Optional pattern: one row per seat with a unique booking constraint instead of a counter—stronger against lost updates.

How do you enforce eligibility without trusting the client?

The mobile app may show a friendly "you look eligible" hint, but only the server decides. On evaluate, load versioned rules (rules_vN), compute eligibility from verified attributes, and persist an eligibility_decision with decision_id, rule_version, and structured reason codes. At book time, re-check inside the transaction—rules may have changed since yesterday. Support and regulators get explainability from the audit record, not from debug logs full of personal health fields.

How do second-dose scheduling rules fit the model?

Link appointments for the same user. Store vaccine type and dose number on the appointment row. Rules enforce minimum interval between doses and matching product type. When dose one is confirmed, the system can auto-offer eligible second-dose slots in a later window—still through the same transactional book path so inventory stays exact. Cancelling dose one may invalidate or reschedule linked dose-two holds per policy.

What happens on no-show or cancellation?

A scheduled job marks no-shows after grace period and returns inventory in the same transactional style as booking (increment remaining or free the seat row). Optional waitlist workers get an event from the outbox and offer the slot to the next person—again with atomic claim. Track no-show counts per user if policy limits repeat offenders. Reminders are async after commit; a missed SMS does not delete the appointment.

How is this different from designing Ticketmaster?

Both have flash demand, virtual queues, and inventory that must not double-sell. Vaccine booking adds policy engines (age, zip, dose rules), public trust and media scrutiny, and often lower slots per site but higher stakes on eligibility mistakes. Contention per slot may be lower than a stadium, but the explainability and audit bar is higher. The queue and atomic book patterns rhyme; the rules and compliance layer do not.

AI feedback on your design

After a practice session, InterviewCrafted summarizes strengths, gaps, and interviewer-style expectations—similar to a written debrief. See a static example report, then practice this problem to get feedback on your own answer.

FAQs

Q: How do walk-ins work alongside online booking?

A: Treat walk-ins as a separate inventory pool at each site—either reserved seats per hour or a walk-in counter not exposed to the public API. Staff tools book from that pool with the same transactional decrement so online and walk-in never share one counter without coordination. In the interview, say you would separate pools early so flash online traffic does not starve clinic walk-ins.

Q: Do you need multi-language support?

A: User-facing copy and notification templates should use translation keys (often called i18n keys), not hard-coded English in the booking service. Eligibility reason codes stay stable machine identifiers; the UI maps them to wording in the person's language. That keeps audit logs language-neutral while support can still explain a denial in the caller's language.

Q: How do you think about HIPAA and sensitive data?

A: Treat personal health details with the care US health-privacy rules (often called HIPAA) require: encrypt personal fields at rest, minimize what each service stores, and keep raw health attributes out of application logs. The audit trail stores rule_version, decision inputs you are allowed to retain, and reason codes—not a dump of the full medical record. Access to audit data is role-based. In the interview, name structured reason codes plus encryption; do not hand-wave "we comply."

Q: How does this compare to a ticket sale system?

A: Ticketmaster-style systems taught the industry about virtual queues and holding inventory during checkout. Vaccine booking often has fewer seats per time slot but stricter eligibility and more regulatory attention. The inventory math is similar; the versioned rules engine and immutable audit layer are the extra depth interviewers expect here.

Q: Should slot search show exact remaining counts?

A: Search can come from a read replica or cache and may be slightly stale. That is acceptable for browsing if book time re-validates inside a transaction. Honest UX copy ("availability updates at checkout") reduces anger when someone gets 409. Measure stale conflict rate—how often users see a slot then lose it at book—to tune caching versus freshness.

Q: What does HTTP 201 mean versus email sent?

A: 201 Created means the appointment row committed in the database. Email and SMS reminders run after commit via an outbox and queue workers. If notification fails, the appointment is still valid; workers retry and alert on dead-letter queues. Say this clearly in the interview so you do not confuse inventory truth with SMTP success.

Practice interactively

Open the practice session to use the canvas and stages, then review AI feedback.