← Lessons

quiz vs the machine

Silver1110

System Design

The Instagram Feed and Stories

Ranked feeds and ephemeral stories pull on very different storage tradeoffs.

4 min read · intro · beat Silver to climb

Two different products

Instagram serves a ranked feed of posts and a row of ephemeral stories that expire in 24 hours. They look similar but stress storage in opposite ways.

The feed

The feed is not strictly chronological. A ranking model scores candidate posts by predicted engagement, recency, and relationship. So Instagram first gathers candidates from people you follow, then ranks them.

  • Candidate generation collects recent posts from followed accounts
  • Ranking scores candidates with a model
  • Media itself lives on a CDN, only ids and metadata flow through the feed service

Stories and expiry

Stories carry a time to live. Rather than scanning to delete, the system tags each story with an expiry timestamp and filters out expired ones at read time, while background jobs reclaim storage.

Separating durable ranked content from short lived ephemeral content lets each use the right retention and indexing strategy.

Key idea

Treat the ranked feed and ephemeral stories as separate pipelines, ranking one and expiring the other, while heavy media is always served from a CDN.

Check yourself

Answer to earn rating on the learn ladder.

1. Why is the Instagram feed not purely chronological?

2. How are expired stories typically handled at read time?