Design a Video Processing Pipeline, stage 5 of 14: model
Trace the happy path end to end
You have made the structural decisions. Before you start breaking things, trace one video all the way through. Getting the order right matters: several of the system's guarantees depend on which step happens before which.
System so far· 6 parts
Select a component to see what it is responsible for and which state it owns.
- 1Instructor browser → Video API: Create upload, report parts, poll status
- 2Instructor browser → Object storage: Upload parts via presigned URLs
- 3Video API → Object storage: Complete multipart upload, verify object
- 4Video API → Postgres: Video row and job row in one transaction
- 5Transcode workers → Postgres: Claim lease, heartbeat, fenced completion
- 6Transcode workers → Object storage: Read raw upload, write attempt output
- 7Reconciler → Postgres: Find abandoned uploads and orphaned output
- Request / response
- Bulk data
What you need to know
When several writes together make something visible, their order decides what a reader can see in between. A safe rule: write the things being pointed to before the thing that points to them.
For a video: segments are pointed to by the manifest, and the manifest is pointed to by the video's status. So segments first, then manifest, then status.
Think first
Suppose a worker flipped the status to 'ready' first, then wrote the manifest and segments. What could a student see?A habit that catches most ordering bugs: for every write, ask "what does a reader see if the process dies right after this?" Acceptable answers are "garbage nobody references" or "unfinished work that a retry will finish". Unacceptable answers involve a reader following a reference to something that isn't there.
Check
A worker dies after writing the manifest but before flipping the status. What's the state?