Skip to content

System Design · Worked case study

Designing a Deadline-Safe Auction Platform

Order bids authoritatively per auction, define deadline and extension semantics, fence stale leaders, and settle payment through a reconciled workflow.

Written for readers who already know the basics. If the words here are new to you, read The request lifecycle and Capacity estimation first.

Original educational architecture · Version 2026-11-12.1 · Examples use stated hypothetical assumptions, not a company's actual design.

What you will be able to explain

  • Choose an authoritative acceptance order and explain the exact deadline boundary.
  • Prevent stale owners and duplicate commands from changing the winner.
  • Settle and compensate payments asynchronously with clear reserve, capture, and reconciliation rules.

Choose explicit auction rules

Design timed, single-item auctions with a starting price, minimum increment, reserve price, optional proxy bidding, and a published close time. Assume 5 million registered bidders, 500,000 daily active users, 100,000 live auctions, and bursts around popular closing times. Exclude live-stream auctions, sealed bids, multi-unit allocation, secondary-market resale, and cross-currency bidding for the first version. Every accepted bid must have an unambiguous order within its auction. The platform defines whether the close is a fixed server deadline or an anti-sniping extension; here, a qualifying bid accepted within the final 30 seconds extends the close by 30 seconds, with a maximum total extension of ten minutes. Acceptance is decided at one serialized decision point while holding the auction's state lock under its current fenced owner. At that point, read the actual current database/owner clock (not a transaction-start timestamp), compare it with the current deadline, and if eligible assign the acceptance time and sequence in the transaction. A successful decision is acknowledged only after its transaction durably commits. Thus a pre-deadline decision may commit and be acknowledged after the deadline; the design does not promise that durable commit finishes before an exact wall-clock deadline. A decision at or after the current deadline is rejected. Equal-price bids are ordered by acceptance sequence. Display this policy before bidding. A winning bid creates a payment obligation but does not mean payment has settled or the item has shipped. State a payment grace period and whether the next bidder can be offered the item after a winner defaults.

Estimate bid bursts and hot-auction concentration

Suppose 500,000 daily active bidders each view 12 auction pages and place 0.2 bids per day: 100,000 bids/day, about 1.16/s average. The average is misleading: a popular auction may receive 20,000 bids in its final minute, or about 333 bids/s, while 1,000 simultaneous users refresh its page every second. If each accepted bid event plus indexes occupies 1.5 KiB, raw daily event storage is about 146 MiB; retaining 180 days of full bid history is roughly 26 GiB raw, before replicas and indexes. The highest cost is coordination on a hot auction key, not total database bytes. Reads can be cached but current leading price and close time must be labeled with an as-of sequence and never treated as authority for placing a bid. A bid command may need a serialized per-auction log with 30% throughput headroom, while page reads and notifications scale separately. Include payment workflow records: if 100,000 daily auctions close and 8% have a winner, 8,000 settlement workflows start/day. Providers may burst webhooks at a close, so reserve worker capacity. Model bot retries and invalid bids; rate limiting and admission queues must not alter acceptance ordering ambiguously.

WorkloadIllustrative calculationImplication
Average bid rate100,000 / 86,400 ≈ 1.16/sNot representative of closing peak
Hot auction20,000 / 60 ≈ 333 bids/sSerialize by auction and benchmark contention
Bid history100,000 × 1.5 KiB ≈ 146 MiB/day rawRetain immutable audit events with policy
Read bursts1,000 viewers × 1 refresh/sServe cached views with explicit as-of version

Begin with one writer per auction

A first system can be a monolithic web application with a relational database, an auction close scheduler, and a payment adapter. Each bid transaction locks one auction row, reads the current deadline and clock after acquiring that lock, decides eligibility, then records acceptedAt and the next sequence transactionally while retaining the lock through commit. The same lock serializes close transitions. This is simple and auditable for moderate load. It becomes a bottleneck when popular auctions serialize too many transactions, timers and payment tasks contend with bid writes, and notifications add latency. Evolve by partitioning auction ownership across shards or durable ordered partitions keyed by auction ID. Every auction has one active writer at a time; the fenced owner's serialized decision assigns acceptance time and sequence, while a later successful durable commit makes the decision acknowledgeable. A pre-deadline decision may therefore commit later; no exact wall-clock commit cutoff is promised. Read models and push notifications consume committed events asynchronously. A leader lease alone is insufficient: every write carries a fencing generation checked by the storage owner, so a paused former leader cannot resume after failover. Scheduled close takes the same serialized state lock, rechecks the current deadline and version, and cannot overtake an in-flight bid decision. Payment settlement runs outside the bid ordering path. Regional APIs route each auction to a home region; global active-active writes require consensus or disjoint ownership and are not assumed. This system's mechanics are hypothetical and do not describe any real marketplace implementation.

Single authoritative bid log with independent read and settlement paths
1. Bidder client

Submits bid command with idempotency key

2. Bid API

Authentication, limit checks and routing

3. Auction owner

Fenced single writer for auction partition

4. Auction state store

Sequence, deadline, accepted bids and current leader

5. Committed event stream

Bid, extension, close, and winner events

6. Read model and notifier

Cached page and websocket updates marked by sequence

7. Settlement workflow

Reserve/capture, fulfill, compensate and reconcile

8. Payment provider

External payment state

  1. Bidder client → Bid API: bid request
  2. Bid API → Auction owner: route by auction ID
  3. Auction owner → Auction state store: decision + fenced durable commit
  4. Auction state store → Committed event stream: durable event after commit
  5. Committed event stream → Read model and notifier: asynchronous projection
  6. Committed event stream → Settlement workflow: close and winner
  7. Settlement workflow → Payment provider: idempotent payment command
  8. Payment provider → Settlement workflow: response or webhook

Define bid commands and durable records

POST /v1/auctions/{id}/bids accepts amount, currency, bidder id from the authenticated session, client idempotency key, and optional maximum for proxy bidding. The fenced owner decides under the serialized auction-state lock using the current authoritative clock after lock acquisition, records acceptedAt and sequence in the transaction, and returns accepted or rejected only after a successful durable commit. acceptedAt is the decision time, not the transaction-start time or a promise that commit finishes before close. A timeout is resolved by retrying the same key or GET /v1/bid-requests/{key}; the client must not guess whether it won. A retry returns a previously committed outcome, including an earlier acceptance after deadline, but never invents a new acceptance for a bid whose decision is now late. GET /v1/auctions/{id} returns a potentially cached view with asOfSequence, current deadline, and view timestamp. Core records include Auction(auctionId, ownerRegion, status, closeAt, deadlineVersion, fencingGeneration, reserve, incrementRule), Bid(auctionId, sequence, bidId, bidderId, amount, acceptedAt, idempotencyKey), BidRequest(bidderId, key, payloadHash, outcome), Winner(auctionId, bidderId, winningBidId, settlementState), and Settlement(attemptId, auctionId, providerKey, amount, state, compensationState). Store immutable acceptance events for audit; a mutable current-price projection is rebuildable. Enforce unique(auctionId, sequence), unique(bidderId, idempotencyKey), and one winner transition per auction. Record clock source and configuration version so disputes can be reconstructed. Avoid trusting a client timestamp, browser countdown, cached leading bid, or proxy-reported arrival time.

http · Illustrative example; validate before production use

POST /v1/auctions/a_81/bids
Authorization: Bearer <session>
Idempotency-Key: bidder-44:request-193

{"amountMinor":12500,"currency":"USD"}

201 {"status":"accepted","bidId":"b_991","acceptanceSequence":8802,"acceptedAt":"2026-11-08T20:59:59.842Z","deadlineVersion":7}

Decision is sampled after the auction lock is acquired; 201 is sent only after durable commit.

Trace accepted bid, extension, and close

A bid reaches the API, which authenticates the account, validates funds or deposit rules, and routes to the auction's current fenced owner. The owner acquires the serialized auction-state lock, then samples the actual current database/owner clock (not a timestamp captured when the transaction began) and reads the current deadline, price, and state. If the auction is closed or this decision point is at or after the current deadline, it records a rejected idempotency outcome; otherwise it validates the increment and bidder eligibility, assigns the next sequence, records acceptedAt as the decision time, and writes the bid and idempotency outcome in the same transaction. A qualifying accepted bid updates closeAt and deadlineVersion transactionally. The lock remains held through commit, which serializes this decision with close. Only a successful durable commit constitutes an accepted bid and permits an acknowledgment; if the transaction rolls back, there is no accepted bid or sequence. A pre-deadline decision may commit and be acknowledged after the deadline, so this policy does not promise that the durable commit completes before an exact wall-clock cutoff. The close worker obtains the same auction lock and fencing generation, rechecks the current deadline and version, then reschedules after an extension or atomically closes and records the winner. It cannot overtake an in-flight bid decision. A retry after deadline returns a previously committed idempotent outcome, if one exists; otherwise its new decision is rejected rather than inventing acceptance. The settlement workflow then reserves or authorizes payment using a stable provider key, captures only according to the disclosed policy, and records provider evidence. If the winner fails the payment grace period, a controlled next-bidder offer or auction relist is a new state transition, not an automatic silent reassignment.

Acceptance order and deadline are decided by the auction owner
1. Bid command

Authenticated amount and idempotency key

2. Route to owner

Current auction partition and fencing generation

3. Serialized decision

After locking, read current clock, deadline and bid rules

4. Durable transaction

Record acceptedAt, sequence, outcome and any extension

5. Extend if qualified

Atomic closeAt and deadline-version update

6. Close transition

Same lock; recheck current deadline and version

7. Settlement

Reserve/capture; reconcile or compensate

  1. Bid command → Route to owner: request
  2. Route to owner → Serialized decision: fenced owner acquires auction lock
  3. Serialized decision → Durable transaction: pre-deadline decision only
  4. Durable transaction → Extend if qualified: same durable transaction
  5. Extend if qualified → Close transition: close waits for lock, then checks current deadline
  6. Durable transaction → Close transition: durable bid result
  7. Close transition → Settlement: committed winner event

Specify acceptance ordering and deadline semantics

The critical rule is what “accepted before close” means. For each auction, the fenced owner serializes bid decisions and close transitions on the same state lock. A bid's decision point occurs only after acquiring that lock: sample the actual current authoritative database/owner clock then, read the current deadline, and accept only if that decision time is strictly before the deadline and the auction remains open. Do not compare against a stale transaction-start timestamp or edge arrival time. In the same transaction, record acceptedAt as that sampled decision time, assign the next monotonic acceptance sequence, write the bid and idempotency outcome, and update deadlineVersion/closeAt for a qualifying anti-sniping extension. Keep the lock through transaction completion. A bid becomes accepted and may be acknowledged only if this transaction durably commits; rollback leaves no accepted bid. A decision made before deadline may commit and be acknowledged afterward, and no exact wall-clock commit cutoff is promised. This rule makes a late commit of an already valid decision different from making a new late decision. If the database cannot hold the lock through durable commit, use an equivalent serialized log/owner protocol that makes the decision and durable outcome atomic; do not imply that a later commit-time check can undo an already committed transaction. The close transition takes the same lock, rechecks the active deadline and version, and cannot overtake an in-flight decision. A bid decision at or after deadline rejects; retrying the key returns any previously committed outcome, but a new or previously undecided request after deadline cannot be turned into acceptance. Clock skew is monitored at the authoritative owner; if uncertainty exceeds its bound, pause bidding or invoke an auditable extension/restart policy. Fencing rejects writes from stale owners. Sequence resolves same-price ties; browser countdowns and edge receipt times are advisory only.

  • A browser countdown is informational; the acceptance authority is the serialized decision time and durable transaction outcome.
  • A tie rule must be deterministic and visible before bidding.

Treat winner payment as a separate reconciled workflow

Auction closure identifies a winner and creates a durable settlement intent; it does not atomically charge a card inside the bid transaction. Depending on product and provider capabilities, preauthorization can happen before close, then capture after winner selection. If only post-close authorization is allowed, the winner may fail and the business needs a stated grace period and next-bidder policy. Each provider command has a stable idempotency key and attempt record. A timeout is unknown, not decline; query the provider or wait for signed webhook evidence. Webhooks are deduplicated and can arrive out of order. Reconciliation compares provider state, auction winner, amount, currency, and settlement version. If a charge succeeds but the auction was canceled or the item cannot be fulfilled, create a compensating void/refund workflow with its own idempotency key. A refund timeout also remains unknown until reconciled. Never change the auction winner merely because a browser redirect reports payment success. Operator tools display evidence, age, prior attempts, next safe action, and a complete audit trail; they must not permit unsafe duplicate capture. This saga handles partial failure honestly, unlike a simplistic distributed transaction claim. Payment and fulfillment status are separate from auction outcome and can remain pending while the system communicates clearly with bidder and seller.

Payment stateAuction stateRequired action
Provider unknownWinner selectedQuery provider; do not issue a new key blindly
CapturedWinner valid and fulfillableConfirm settlement and continue fulfillment
CapturedWinner invalid or fulfillment canceledRecord compensation and reconcile refund
DeclinedGrace period remainsApply disclosed retry policy; retain winner state
DeclinedGrace period elapsedCommit next-bidder/relist transition with audit

Recover from leader, clock, and regional failures

If an auction owner crashes, a replacement acquires a higher fencing generation and reloads the durable auction sequence, deadline, and current state. The old owner cannot commit after promotion. If the bid store is unavailable, reject or queue commands only with a clearly stated acceptance rule; a queue receipt is not a bid acceptance. For fairness, a waiting room can control concurrency, but its tokens do not promise a place before the deadline unless the system defines how queued commands are ordered and accepted. If clock monitoring detects a large skew, pause the affected auction and extend or restart it under an auditable policy rather than accepting disputed timestamps. Region failure requires a single-writer promotion and a documented replication RPO. With asynchronous replication, acknowledged last bids may be lost after failover; either accept that bounded risk with transparent remedy or use stronger synchronous/consensus replication at increased latency and availability cost. Never run two owners because both regions believe the other is down. Settlement workflows can continue in a separate healthy region only if idempotency and provider references are globally available. Restore drills reconstruct bid order, extensions, close transitions, and provider state from durable events. If notification service is down, clients poll the authoritative auction state; notifications are not the acceptance record.

FailureSafe behaviorRecovery guard
Owner process lossPromote only after fencing old generationSequence continuity and lease ownership
Clock uncertaintyPause or apply audited close policyBounded clock offset and dispute record
Regional outageOne writer promotion with declared RPONo split brain; reconcile final bids
Payment webhook outageKeep settlement pending and poll provider stateIdempotent reconciliation before release

Protect fair access and financial integrity

Authenticate bidders and sellers, verify identity and payment policy proportional to item value, and prevent account takeover from becoming a high-value bid. Validate currency and minimum increment server-side. Rate-limit by account, device, and auction; detect automated bid flooding without using an IP-only block that harms shared networks. Use bot challenges or deposit requirements for high-risk actions with accessible alternatives and appeal. Protect bid histories and personal identities according to the auction's public-display rules; a public amount does not require public bidder identity. Prevent seller self-bidding through account relationships and risk review, while documenting that fraud detection can be imperfect. Encrypt provider references and never store card data directly. Webhooks require signature verification, replay protection, and deduplication. Administrative cancellation, reserve changes, bidder suspension, and close-time adjustments are audited and preferably require dual control for high-value auctions. Avoid leaking hidden reserve values through error messages or timing. Preserve dispute evidence for a defined retention period, then delete or anonymize as policy allows. Security tests include bid replay, cross-account idempotency key collisions, deadline manipulation, stale leader writes, forged payment hooks, amount/currency tampering, account enumeration, and attempts to view protected bidder identity.

  • Fairness means the same documented acceptance rule applies across client types and regions.
  • Audit privileged overrides as carefully as bid commands.

Measure acceptance fairness and settlement health

Bid API availability should count valid attempts that receive an authoritative accepted or rejected result, with overload rejection reported separately from infrastructure failure. A starting objective might be 99.95% valid bid decisions during active auction windows and p99 decision-to-durable-commit latency below 250 ms, provided load tests support the target; this is a latency objective, not a rule that commits must finish before close. Track the serialized decision timestamp's margin relative to the active deadline separately from decision-to-commit latency, plus owner queue delay, lock contention, fencing rejections, clock offset, duplicate request replay, close-task lag, extension count, and notification lag. Fairness monitoring can compare decision latency by region and client class without exposing identities; investigate whether admission controls systematically disadvantage a cohort. Settlement SLOs measure winner outcome resolution, provider unknown-state age, capture/refund reconciliation, and fulfillment transition. Every auction should have one coherent committed close event and one winner or explicit no-sale state. Synthetic tests submit bids just before, exactly at, and just after the deadline under concurrency, plus owner failover and extension races. Error budgets should trigger capacity or policy changes before an important closing window. Do not use page refresh latency as a proxy for bid acceptance correctness.

IndicatorMeasurement boundaryExample target
Bid decision latencyOwner receives validated command to durable resultp99 < 250 ms under tested peak
Deadline correctnessSerialized decision timestamp and sequence against active deadline versionZero accepted after defined close
Close processing lagDeadline to committed close transitionp99 < 2 s absent extension
Settlement resolutionWinner intent to reconciled provider outcome99% within stated payment grace window

Compare ordering approaches and migrate safely

An illustrative monthly cost could be $16,000 for transactional bid storage and replicas, $8,000 for partitioned auction-owner compute and durable event transport, $5,000 for cached read models and notifications, $6,000 for payment reconciliation and fraud controls, and $5,000 for observability, backups, and regional failover: roughly $40,000 before payment fees, identity checks, dispute handling, and staffing. A per-auction actor or ordered log makes serialization explicit but introduces ownership and hot-partition management. A relational row lock is simpler at moderate scale and provides strong transactional constraints; benchmark the hottest auction before replacing it. A global consensus log gives stronger ownership semantics at the cost of latency and operational complexity. For a migration, add acceptance sequence and deadline version to the existing records, route each auction to one owner, and shadow-compute decisions without returning them. Compare proposed results with the existing transaction for normal, extension, and tie cases. Switch one low-risk cohort, keep reads from the canonical log, and prevent old writers from accepting bids after cutover. Payment workflow extraction happens separately behind the committed close event. Rollback is a controlled ownership transfer with fencing, not simply deploying old code. Follow-ups include proxy bid semantics, reserve price leakage, legal disputes, clock policy, anti-sniping abuse, payment defaults, and recovery after regional data loss.

  • Track cost per accepted bid and per settled auction, not only per API request.
  • Separate read-model migration from authority migration to limit rollback complexity.

Terms in plain language

Acceptance sequence
A durable, monotonic order assigned by the authoritative auction writer to bids it accepts.
Deadline semantics
The documented rule for whether a bid at or near the close time is eligible, including clock source and tie breaks.
Fencing token
A generation that invalidates writes from an old auction leader after ownership changes.
Settlement workflow
Durable steps that verify the winner, reserve or capture funds, notify parties, and compensate if fulfillment fails.

Capacity lab

Change the assumptions and inspect the math. This teaching model assumes every request creates one stored record. Real systems separate reads, writes, uploads and background work.

Average QPS
231.48
daily users × requests per user / 86,400
Peak QPS
1,157.41
average QPS × peak multiplier
Peak payload bandwidth (MB/s)
1.16
peak QPS × bytes/request / 1,000,000
Logical retained storage (GB)
600
requests/day × bytes/request × retention / 1,000,000,000
Replicated storage (GB)
1,800
logical storage × stored copies
Serving nodes
1
ceil(peak QPS / (node throughput × utilization))

Decimal MB/GB, not MiB/GiB. Indexes, protocol overhead, compression, retries, backups and failover capacity are excluded. Measure throughput on your workload; this is not a sizing guarantee or a cloud price quote.

Preparing practice controls…

Check your understanding

These checks explain concepts. They do not measure architecture seniority or update readiness.

1. Under the stated rule, when is a bid eligible to be accepted?
2. What prevents a paused former auction owner from writing after failover?

Design independently

A hot auction's original deadline is 20:00:00.000. Bidder A's request reaches the edge at 19:59:59.900. Bidder B has a qualifying anti-sniping bid whose serialized decision occurs at 19:59:59.970; its transaction commits the bid and a 30-second deadline extension before A can acquire the auction lock. A then reaches its serialized decision point at 20:00:00.040, while the extended deadline is active; its transaction commits durably later. Meanwhile, a regional failover promotes a new owner while the previous owner is paused, and the winner's payment capture response times out. Explain which decision times determine eligibility, why A can be accepted before the extended deadline despite committing later, and when its acknowledgment may be sent. State what happens if its transaction rolls back or if no extension had committed before its decision. Explain fencing and payment reconciliation. Include tie rules, operator evidence, user messaging, metrics, and tests. Do not assume a database transaction can include the payment provider or promise that commit finishes before a wall-clock deadline.

Hints, not a solution
  • The qualifying pre-deadline decision updates the active deadline and version in its transaction.
  • Edge arrival and transaction-start time are not the decision clock.
  • Failover requires a higher fencing generation checked at durable write time.

0 / 20,000 characters · Not saved

Your learning notes

Sign in to save

Marking a lesson read and reviewing an exercise are separate actions. Neither implies mastery. Saved work is account-owned; saves are explicit and do not queue offline.

References and boundaries

Primary documentation supports the mechanisms described. It does not certify these hypothetical architectures, prices or sizing assumptions. Review platform-specific behavior before implementation.

PostgreSQL: Transaction Isolation

Documents isolation behavior relevant to transactional bid decisions; it does not specify the invented auction ordering policy.

AWS Prescriptive Guidance: Leader election

Provides leader-election background; the design's fencing enforcement and auction rules remain hypothetical.

Stripe: Idempotent requests

Documents an external provider's idempotency API behavior; it does not guarantee atomic auction and payment settlement.

Back to curriculum