System Design Atlas

Timed examination platform

04 / 10Worked example

Interfaces

What happens to the same requestKey with another answerHash?

Server time, version and requestKey belong to the command.

Starting point Compare command fingerprints.

Assumptions for the example case

Illustrative design: 50,000 attempts per day, 10,000 simultaneous starts, a 90-minute duration, autosave every 10 seconds and a peak of 1,000 answer writes/s. This gives at most 540 save opportunities per attempt open for the full duration; actual writes depend on changes and batching.

Interfaces

Four contracts connect the participant, administration and platform.

API contracts

  1. POST/attempts/V-17/start

    Start attempt

    Input
    Participant and R-3
    Result
    V-17 in_progress with closesAt
    Retry behaviour
    The same key gives the same attempt
  2. PUT/attempts/V-17/answers/A-17

    Save A-17

    Input
    expectedVersion, answerHash, receivedAt, requestKey
    Result
    New answer and attempt revisions
    Retry behaviour
    identical content gives first result
  3. POST/attempts/V-17/submission

    Submit on time

    Input
    expectedVersion, receivedAt, requestKey
    Result
    E-17 and submitted
    Retry behaviour
    identical repetition gives E-17
  4. POST/attempts/V-17/extension

    Extend the deadline before its current expiry.

    Input
    Exam administration, expectedVersion, the new deadline newClosesAt and the server-side check time observedAt.
    Result
    Only in_progress, a matching version, observedAt < closesAt and newClosesAt > closesAt permit an atomic update of the deadline and incremented version.
    Retry behaviour
    After a lost response, read the current attempt state. Resending the original expectedVersion returns version_conflict; a further extension requires a new decision against the current version.

Terms in this step

Optimistic version
A command applies only to the last confirmed attempt state.

Try it yourself

Decide replay or conflict.

A hint for your attempt

A key identifies exactly one payload.

Compare with a possible solution
Equal
Return the original save result.
Other
idempotency_conflict.

Apply to your project

Define the fingerprint for a file upload.

The data model connects the deadline and state.