LESSON 08 · Reliability and operations

Measure the feed that readers receive

Watch publish-to-visible delay, queue lag, read latency, cache behavior, and privacy failures.

SYSTEM VIEW

The feed path

Diagram view
Publish success—
Fanout age—
Probe—

Watch a healthy Post API hide an hour of fanout lag, then see dead letters, a capped fallback, a hot partition and a test probe at work.

  1. Monitoring tracks eight signals along the whole path: commit success and handoff failures at the Post API, Fanout queue age, the share of followers who see a post within the 1-minute target, first-page latency, cache hit rate, empty feeds and media errors.

    Freshness target
    seen within 1 min
    Write path
    commit, handoff, queue age
    Read path
    latency, hits, empty feeds

    What changed

    • Signals on the write path
    • Signals on the read path
    • Target: seen within 1 min
  2. The Post API reports 99.99% publish success, yet followers see posts an hour late: the oldest Fanout queue job has waited 60 minutes. Kafka’s consumer lag, for example, counts messages behind, so Monitoring converts lag to age before comparing it with the 1-minute target.

    Publish success
    99.99%
    Kafka lag
    messages behind
    Oldest job
    60 min, target 1 min

    What changed

    • Post API healthy at 99.99%
    • Oldest fanout job 60 min
    • Lag read as age
  3. With the queue caught up, workers retry failed writes, and keys of post and recipient make each repeat harmless. Post 4602 is a poison event: it fails on every attempt, so it moves to Dead letters, and post 4603 behind it still reaches the Inboxes.

    Retry key
    post + recipient
    Poison event
    post 4602
    Next in line
    post 4603 written

    What changed

    • Dead letters
    • Post 4602 set aside
    • Post 4603 written
  4. The Inboxes store is unavailable. Rather than an empty feed, the Feed service pulls recent posts from the Author index for a degraded first page, if capacity allows, and caps that pull so a broad outage doesn’t overload the post database.

    Inbox store
    unavailable
    Fallback
    recent posts, capped
    Protects
    the post database

    What changed

    • Dead letters
    • Inboxes store down
    • Capped pull from the index
    • Degraded first page
  5. Workers write 20,000 inbox entries a second. One post to 5 million followers takes 250 seconds, and other authors’ posts in that partition wait behind it for over four minutes. Partition the work, cap concurrency and monitor per-author hotspots.

    One post
    5M inbox entries
    At 20,000/s
    250 s
    Same partition
    waits over 4 min

    What changed

    • Author index
    • Post to 5M followers
    • Partition busy 250 s
    • Partitions, caps, hotspot watch
  6. A test account posts every minute, and a test follower reports when each appears: this one after 40 seconds, inside the 1-minute target. Reconciling sampled inboxes against canonical posts catches lost fanout or duplicates at a small read cost. Revisit fanout thresholds from observed activity.

    Test post
    every minute
    Seen after
    40 s, target 1 min
    Reconcile
    sampled inboxes

    What changed

    • Test post every minute
    • Seen after 40 s
    • Sampled inboxes reconciled
    • Fanout thresholds from activity

Space plays · ← → step · Home resets

THE IDEA

How it works

Define service-level signals across the complete path: post commit success, event handoff failures, fanout queue age, percentage of eligible followers seeing a post within the freshness target, feed first-page latency, cache hit rate, empty-feed rate, and media error rate. A healthy post API with hours of fanout lag is still a broken feed. Kafka consumer lag, for example, counts messages behind; convert it to age before comparing it with the target.

Retry workers with idempotent post-recipient keys and dead-letter handling for poison events, ones that fail on every attempt. If the inbox cache or store is unavailable, offer a bounded pull from canonical recent-post indexes for a degraded first page if capacity allows. Limit that fallback so a broad cache outage does not overload the post database.

Skew matters: a high-follower publisher can produce a burst even at a modest global posts-per-second rate. In an example, workers write 20,000 inbox entries per second. One post to 5 million followers takes 250 seconds, and other authors sharing that partition wait behind it for over four minutes. Partition work, cap concurrency, and monitor per-author hotspots.

Reconcile sampled inboxes against canonical posts to detect lost fanout or duplicate entries; sampling keeps the read cost small. A test account that posts every minute, watched by a test follower, measures the delay readers actually get. Revisit read and write fanout thresholds using observed activity, not a fixed rule from the diagram.

DECISION POINT

Publish success is 99.99%, but followers report that posts arrive an hour late. Which signal reveals the fault?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Observe user-visible freshness and latency, not only API status.
  • Retries, bounded fallback, and reconciliation make derived feeds recoverable.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

Which measure best captures feed freshness?

Choose an answer. You’ll see the explanation once you get it right.

Design a workout activity feed for a fitness app

Apply the news feed chapter to workouts, where a few athletes have huge followings, uploads arrive late, and a route map can reveal where someone lives.

The brief

Athletes record a run or ride, and the app uploads it when it next has a connection, sometimes hours later. Followers see a card with a route map, distance, and pace in a home feed. A few popular athletes have about a million followers. Each activity is visible to everyone, followers only, or only the athlete, and that setting can change later. Keep comments, segments, leaderboards, and ranking outside this exercise.

  • 20 million registered users, 5 million active each day. Active users open the feed 4 times a day and load 2 pages per open. Peak traffic is 3 times the daily average. Use decimal units and 86,400 seconds per day.
  • 1 million activities a day come from ordinary athletes, who average 150 followers. Separately, 100 popular athletes average 1 million followers and post twice a day.
  • Followers of popular athletes are as active as anyone else, so about 25% open the app on a given day. The inbox store is sized for 10,000 writes per second.
  • Each activity stores a 72 KB GPS track and 200 KB of rendered map images. An inbox keeps at most 500 entries of 16 bytes each.
  • 95% of activities should reach followers’ feeds within 60 seconds of upload. Setting an activity to “only me” must stop new reads, including its map image, within 60 seconds.

Reading a design isn’t the same as producing one under a clock. Try it timed: the requirement change stays hidden until partway through.

Loading your draft…

State your scope. Estimate feed page reads, ordinary fanout writes, what pushing popular athletes’ posts would cost, how long one popular post takes to push, inbox storage, and 30 days of activity storage. Keep units visible.

0 / 4,000 characters

Name the components and what each stores. Trace one late upload from the phone to a follower’s feed, and one feed page that includes a popular athlete. State which timestamp orders the feed and what the cursor contains.

0 / 4,000 characters

Pick a likely bottleneck and the signal that would reveal it. Explain what a follower sees if fanout falls behind or the inbox store fails, and how a stale inbox entry is kept from returning a private activity.

0 / 4,000 characters

Respond to the safety review below. Explain how the switch takes effect in 60 seconds without rewriting every inbox, how map images and old links comply, and one cost of your approach.

The requirement changesA safety review asks for a private-account switch. When an athlete turns it on, all of their past activities, perhaps 3,000 of them, must disappear from everyone but approved followers within 60 seconds, including map images. The review also wants the first and last 500 meters of every route hidden from anyone but the athlete. What changes?

0 / 4,000 characters

Write an initial response in all four sections to unlock the checklist and two worked approaches.

0 of 3 checkpoints answered correctly to complete this lesson.