Critical request flows
We follow the operations that determine the design. Missing intermediate states hide duplicate effects and lost data. We will trace reads, writes, uploads, and live delivery.
#Section 21The complete read flow
The viewer requests a score with a permitted freshness requirement. The edge routes it, the API validates the resource and caller context, and the read path checks a versioned cache. A usable hit returns its state; a miss or stale value triggers a bounded authoritative read or a documented fallback.
Record the returned version and outcome. Coalesce concurrent misses where safe so they do not all reach the database. If the source is unavailable, distinguish an allowed stale reply from a correctness failure. A response can include age or pending status according to the contract, but it should not silently claim current state. Trace the request back to its final viewer-visible result, because a successful server handler does not prove delivery.
Use a scorer’s required version to make the read flow concrete. The cache holds seven while the write response established eight, so existence is insufficient for a hit that satisfies this request. The read waits within its deadline, queries an eligible source under admission limits, or returns the documented pending outcome. Ordinary viewers may follow a different freshness allowance. If the source read succeeds but filling the cache fails, the caller can still receive the correct source result. That separates response correctness from cache maintenance and exposes the extra source work generated by a cold or broken cache.
A cache hit without version or age cannot prove it satisfies a read-your-writes requirement.
#Section 22The complete write flow
A background thread started after commit can disappear with the process. The durable intention must exist before acceptance, and a restartable worker must discover it independently of that original thread.
The scorer sends a key, match identity, expected version, and change. The command authority checks permission and the transition. It conditionally moves version seven to eight and stores the result and downstream intention in one local transaction.
After commit, it returns version eight. If the reply is lost, the caller repeats the same key and intent, receiving the stored result. If another distinct command expects seven after eight exists, it conflicts and must reconsider the change. The relay and projectors later apply their own duplicate-safe effects. This flow establishes the authority, unique effect, returned version, and recovery after both process and network failures.
Compare the repeated command with a distinct command racing on version seven. The repeated command locates the stored version-eight result under its key and produces no additional score change. The distinct command finds that seven is no longer current and receives a conflict. Returning the same HTTP code for these cases without explaining their states would conceal the mechanism. The downstream relay publishes the committed intention independently of either request’s thread. This walkthrough demonstrates why business identity, expected version, and publication progress have separate fields and why acceptance waits for their protected source commit.
Returning the new version before commit completes can give the client a result that recovery cannot find.
#Section 23The complete upload flow
The API creates a session and pending clip. The client uploads the 5,000,000,000-byte illustrative object as 50 parts of 100,000,000 bytes. A retry resends a part under the same session and part identity instead of creating another clip.
Completion names the expected parts and object identity. The control path verifies the storage result and checksum policy, then commits a processing intention. Workers transform the stored object and publish only a confirmed playable result. Abort or expiry cleans up incomplete bytes under a lifecycle policy. Amazon S3’s multipart overview explains separate initiation, part upload, and completion operations; the hypothetical service still needs its metadata state machine.
Lose a part-upload reply and keep the session and part identity unchanged on retry. The completion request names the assembled object, after which the API verifies its stored result and commits the processing transition. A completed storage object with failed metadata commit remains an orphan candidate, not a published clip. Reconciliation can attach it to the still-valid session or cleanup can remove it under policy. A processing worker similarly publishes only verified outputs for the intended revision. The illustrative part arithmetic counts original bytes; it does not establish rendition size, processing time, or playback readiness.
A completed object with failed metadata publication is an orphan state that needs reconciliation, not proof that the whole user operation completed.
#Section 24The complete live-update flow
The scorer commit produces a durable event. The stream preserves the chosen match order, gateways consume it, and each gateway delivers to its connected viewers. With 50,000 viewers and a 10,000-connection capacity assumption, the arithmetic minimum is five gateways.
That minimum does not supply failure spare capacity or balanced placement. The browser tracks the last accepted version and detects a gap after reconnect. It requests replay if retained history covers the gap, otherwise a current snapshot plus a safe continuation boundary. Presence is a lease-like observation, not proof that a browser received every event. Bound slow-client queues and reconnect bursts so one impaired viewer does not retain unlimited gateway memory.
A gateway can send an event just before the viewer’s connection fails without learning whether the browser applied it. Reconnect therefore starts from the browser’s accepted version rather than the last attempted socket send. Replay supplies the missing ordered tail while the client rejects duplicates; expired history requires a current versioned snapshot and safe continuation. A gateway restart changes socket ownership but should not erase authoritative score history. Bound the client’s catch-up queue and spread reconnect attempts under admission capacity. The connection-count minimum explains normal placement, while loss of an owner creates a separate capacity and recovery workload.
A message sent on a socket is not an application-level receipt. Delivery guarantees need explicit acknowledgement or a reconnect recovery contract.