A write-heavy flow with async fan-out - a very common interview walkthrough.
Synchronous path (what the user waits for):
- Client requests a pre-signed upload URL from the API.
- Client uploads the image directly to blob storage, bypassing the application servers entirely. This is the key move - never proxy large media through your API tier.
- Client calls POST /posts with the blob key, caption and an idempotency key.
- Gateway authenticates, rate limits, validates.
- Post service writes the row to the primary database and returns 201. The user is done here, in roughly 100 ms.
Asynchronous path (everything else):
- Post service publishes a PostCreated event to the queue.
- Image worker generates thumbnail variants and pushes them to the CDN.
- Fan-out worker writes the post ID into each follower's timeline cache. For a user with 1,000 followers this is fine; for a celebrity with 50 million it is not - so use the hybrid model: push for normal users, and for celebrities skip fan-out and merge their posts in at read time.
- Search indexer updates the index; moderation worker scans content; notification worker alerts mentioned users.
Failure handling to mention: the event must be published atomically with the database write - use the transactional outbox pattern, since a write that commits without its event causes a permanently missing timeline entry. Consumers must be idempotent because the queue delivers at-least-once.