System Design: Instagram (Walnut Snap: Resumable Uploads, the Publish Gate, Signed Media URLs, Stories, Hot Counters)
We design a photo and video sharing app, like Instagram, and call it Walnut Snap. People post photos and videos, follow each other, and see their friends' posts in a feed. They also post Stories, which disappear after 24 hours.
The feed of posts from people one follows is its own classic question, and our news feed post covers it in depth. This post spends its time on what makes Instagram different.
Large media files come from phones on weak networks. A post must not go live half-made, and Stories must vanish on time.
As in any system design interview, the numbers are assumptions for planning. Every number here is our own assumption, and the design is our own.
All times are on Saturday 28 November 2026. They are in US Pacific Time, Seattle's time, unless a line says otherwise. Austin is two hours ahead of Seattle.
1. Requirements
1.1 What we are building
Walnut Snap does three jobs:
- Take a post in. Receive photos and videos from a phone, even when the network drops halfway. Make every size each screen needs, check the post for harmful content, and publish it only when all of it is ready.
- Show it to the right people, fast. Put the post in each follower's feed within seconds. Serve its photos and videos from servers near each viewer, and never to someone the author blocked.
- Stories and reactions. Show Stories for 24 hours, some only to a chosen list of close friends. Count likes and comments, even when one post gets 20,000 likes a second.
The story, one Saturday evening:
- 18:40. Maya Chen is on a hiking trail near Seattle. She posts a carousel, one post with several items: two photos and a 22-second video of 46 MB.
- 18:40:55. Her signal drops when 32 MB of the video have arrived. At 18:42:05, 70 seconds later, her phone joins the Wi-Fi of the lodge and the upload goes on from 32 MB.
- 18:42:30. The post goes live, with every photo size and the first video versions ready. Three seconds later it sits in her followers' feeds.
- 19:05. In Austin, it is 21:05. Jake Rivera opens his feed, and Maya's post is first. Its photos load from a server in Dallas.
- 19:10. Jake asks to follow Emily Nguyen in Denver, whose account is private. At 19:12, which is 20:12 in Denver, she approves.
- 19:12 to 19:19. The model that ranks feeds slows down in our US East region. Rachel Kim, our on-call engineer, moves 30% of its work to US West.
- 19:15 to 19:18. Maya posts three Stories. The last one goes only to her Close Friends list, which includes Sam Ortiz in Portland.
- 19:30. Derek Hall, in Phoenix, writes a rude comment on Maya's post. At 19:31 she blocks him.
- 20:00. Nora Vale, a pop star in Los Angeles with 310 million followers, posts a short video. It gets 1.2 million likes in its first minute. A network of fake accounts tries to add 40,000 likes a minute.
What happens to each person, by Saturday night:
- Maya's video upload resumes from 32 MB, not from zero. Her post appears with no missing photo and no broken video.
- Jake sees Maya's post first, then her Stories. He never sees her Close Friends story.
- Sam sees all three of Maya's Stories. Each leaves his tray 24 hours after it was posted, the last on Sunday at 19:18.
- Derek's comment is hidden within 60 seconds of the block, and Maya's posts no longer appear for him.
- Jake sees Emily's recent posts in his feed once she approves.
- Nora's like count climbs smoothly to 1.2 million. Most fake likes are refused at once, and the rest are removed the next day.
- During the slow ranking model, Jake's feed still loads, in a simpler order for a few minutes.
The hard part has three pieces:
- About 800 million photos and videos arrive each day, mostly from phones on weak networks.
- On average, about 42 Tbit/s of media goes out to viewers every second, from servers near them. Tbit/s means trillions of bits a second.
- Three things must be right and must happen fast. A post goes live only when complete, a story is gone at 24 hours, and a block applies within a minute.
1.2 Words we use
Words used in only one place are explained there. Each word below is used all through the post.
Posts and media.
| Word | Meaning here |
|---|---|
| Post | One share by one person: a caption and 1 to 20 photos or videos. A post with several items is a carousel |
| Item | One photo or one video inside a post |
| Original | The file as the phone sent it |
| Variant | A photo resized for one kind of screen, such as 640 pixels wide |
| Rendition | A video encoded at one size and bitrate, such as 720p at 2 Mbit/s. Bitrate is the bits the video uses each second; Mbit/s means millions of bits a second. 720p means 720 rows of pixels |
| Chunk | A 4 MB piece of an upload. MB means megabytes; GB, TB, PB and EB are each 1,000 times the one before |
| Offset | How many bytes of an upload the server has safely stored |
| Checksum | A short fingerprint computed from a file's bytes. If one byte changes, the checksum changes. SHA-256 is the method we use |
| Story | A photo or a video shown for 24 hours, then removed |
| Close Friends | A list each person keeps. A story sent to it reaches only those people |
| Tray | The row of circles at the top of the app, one per person with a new story |
Delivery.
| Word | Meaning here |
|---|---|
| CDN | Content delivery network: servers in many cities that keep copies of files near viewers |
| Edge | A CDN server in a city near the viewer, such as Dallas |
| Shield | A bigger CDN site in front of our storage. Edges ask the shield, and only the shield asks storage |
| Signed URL | A web address for one file with an expiry time and a signature. The edge checks it without asking our services |
| Miss | A request for a file the CDN server does not hold yet |
| Tbit/s | Trillions of bits a second |
People and the feed.
| Word | Meaning here |
|---|---|
| Follower | A person who follows an account and sees its posts |
| Active follower | A follower who opened the app in the last 7 days |
| Private account | An account whose posts only approved followers see. A new follower must ask first |
| Block | One person stops another from seeing or reacting to anything they post |
| Feed | The list of posts from people one follows, ranked |
| Feed list | The IDs of recent posts kept for one viewer, ready to rank |
| Fan-out | Copying a new post's ID into each follower's feed list |
The system.
| Word | Meaning here |
|---|---|
| Region | One of our five groups of data centers: US East, US West, two in Europe and one in Asia |
| Zone | One building or group of buildings inside a region, with its own power |
| Shard | One slice of a store, holding some keys. Each shard has copies in three zones |
| p50, p99 | p50 is the time half of all requests finish within. p99 is the time 99 of every 100 finish within |
| API | Application programming interface: the calls the app makes to our servers |
| Lease | A claim that ends by itself after a set time unless it is renewed |
| Outbox | A table where a service writes an event in the same transaction as its own change. A relay then sends the event on, so the change and its event cannot disagree |
IDs in this post. Every ID below is made up.
| ID | What it names | Example from the story |
|---|---|---|
| u_4471 | A user ID | Maya Chen, @maya.trails |
| u_8812 | A user ID | Jake Rivera |
| p_8K41 | A post ID | Maya's carousel |
| m_9A3 | A media ID | The photo in Maya's Close Friends story |
| m_8K41a, m_8K41b, m_8K41c | A media ID: one item | Maya's two photos and her video |
| up_c3 | An upload ID | The upload of Maya's video |
| st_9A1, st_9A2, st_9A3 | A story ID | Maya's three Stories; st_9A3 is for Close Friends |
| p_R7V2 | A post ID | Nora's video |
| c_77X1 | A comment ID | Derek's rude comment |
1.3 Every kind of request and change
Walnut Snap handles more than the story shows. This table lists every kind. Each part it names is explained where it first appears in the design.
| Kind | What it is | How big or how often | Part that handles it | Outside company that takes part |
|---|---|---|---|---|
| Upload | Photos and videos sent in chunks | about 800 million items a day | Upload service, Media store | none |
| Create post | A caption and its items become a post | about 200 million a day | Post service, Post store | none |
| Process media | Photo variants and video renditions | every item | Media processors | none |
| Safety check | Check each item for harmful content | every item | Safety service | none |
| Feed page | A viewer opens or scrolls the feed | about 30 billion pages a day | Feed service, Feed store | none |
| Media fetch | A viewer's app loads a photo or a video segment | about 42 Tbit/s on average | CDN edges and shields | A CDN company, for some countries |
| Story post | A story to all followers or to Close Friends | about 500 million a day | Story service, Story store | none |
| Tray load | The row of story circles is built | about 15 billion a day | Story service, Story heads | none |
| Like and comment | A reaction to a post | about 10 billion likes and 1 billion comments a day | Engagement service, Counter job | none |
| Follow and block | Follow, ask to follow, approve, block | about 300 million a day | Graph service, Graph store | none |
| Privacy change | An account goes private | about 2 million a day | Graph service, Revocation list | none |
| Delete or report | A person deletes a post, or reports one | about 20 million a day | Post service, Safety service | none |
| Push notice | A like or a comment tells the author | billions a day | Notification service | Apple and Google send the push |
1.4 Functional requirements
- Post. Accept a post of 1 to 20 photos and videos. A video may be up to 20 minutes and 4 GB. An upload resumes after a dropped network.
- Process. Make the photo sizes and video versions each screen needs, and check each item for harmful content.
- Publish. A post appears only when every item is ready and checked. The author sees it at once.
- Feed. Show each person a ranked feed of posts from people they follow, with new posts within seconds.
- Media. Load photos and videos fast on any phone, anywhere, at the right size.
- Stories. Show a story for 24 hours, to all followers or to Close Friends only, and remember which stories each person has seen.
- React. Let people like and comment, and show counts that keep up, even on a very popular post.
- Privacy. Support private accounts with follow requests, and blocks that hide everything both ways.
- Remove. Delete or take down a post or a story everywhere, including the copies near viewers.
Out of scope: direct messages, search and ads. How the Reels and Explore recommendations are trained is out of scope too. Our news feed post covers feed ranking in depth; here the feed gets one stage.
1.5 Non-functional requirements
- Feed speed. The first feed page loads in 150 ms at p50 and 400 ms at p99.
- Publish time. A photo post is live within 10 seconds of its last byte at p99. A video post is live within 60 seconds, with its first renditions.
- Upload safety. A chunk is confirmed only after it is stored in three zones. Every item has a copy in a second region within 5 minutes.
- Freshness. A new post reaches followers' feeds within 10 seconds at p99, and within 60 seconds during a spike.
- The author's own post. The author sees a new post, like or comment at once, on every device.
- Privacy. A block or a change to private applies in our APIs within 60 seconds, and at the CDN edges within 5 minutes.
- Stories. A story leaves every tray at 24 hours. Its media stops loading within 5 minutes after that.
- Counts. A like count is at most 5 seconds behind, or 30 seconds on a post above 5,000 likes a second.
- Spike. At the New Year, 46,000 uploads a second for 15 minutes. No upload is lost.
- Availability. 99.95% of feed loads succeed in a month.
1.6 The numbers
These are rough sums, the kind a candidate does at a whiteboard in a few minutes. Every number is our own assumption.
Walnut Snap has 1.5 billion daily users. The evening is about twice the daily average. We keep capacity for 3 times the average, and call that the design peak.
| Number | How we get it | Result | What it decides |
|---|---|---|---|
| Feed pages | 1.5 billion people × 20 pages a day = 30 billion. ÷ 86,400 s = 347,000 a second. × 3 at the design peak | About 1 million pages a second | A page must be one read of a list prepared ahead, not a search over everyone a person follows |
| Uploads | 200 million posts × 1.5 items + 500 million stories = 800 million items a day. ÷ 86,400 = 9,300 a second; × 3 = 28,000; × 5 at the New Year = 46,000 | 28,000 a second, 46,000 in a spike | Bytes go straight to object storage in chunks, never through our app servers. Processing runs from a queue |
| New media | 250 million photos × 2 MB + 50 million videos × 50 MB + 350 million story photos × 1 MB + 150 million story videos × 10 MB | 4.85 PB a day, 82% of it video | Object storage, with video as the part to optimize |
| Media out | 1.5 billion people × 300 MB a day = 450 PB. ÷ 86,400 = 5.2 TB a second, which is 42 Tbit/s. × 2 in the evening | 42 Tbit/s on average, 84 in the evening | A CDN with edges and shields. Storage sends only the misses, about 5% of the bytes |
| Feed inserts | 200 million posts × 300 active followers = 60 billion a day. ÷ 86,400 = 694,000 a second; × 3 = 2.1 million | 2.1 million inserts a second | Copying a post ID into each follower's list works for most authors. Nora's 186 million active followers alone would take 89 seconds of all that capacity, so big accounts are read at view time |
| Likes | 10 billion likes a day ÷ 86,400 = 116,000 a second; × 3 = 350,000. Nora's video: 1.2 million in a minute = 20,000 a second on one post | 350,000 a second, 20,000 on one post | A like is a row on the liker's shard. The count of a hot post is split over several rows |
| Story trays | 1.5 billion people × 10 tray loads = 15 billion a day = 174,000 a second. Each reads the newest story of about 160 followed accounts, × 3 at the peak | 84 million small reads a second | Each account's newest story fits in 40 bytes: 300 million × 40 B = 12 GB. Every tray server keeps all of it in memory |
| Hot storage | Originals only: 4.85 PB a day × 30 days × 4 copies, three zones plus one in a second region. Sizes and renditions add about half again | About 600 PB for the last 30 days | After 30 days, files move to a cheaper form that stores about 2.1 times their size instead of 4 |
What these numbers tell us. The databases handle these numbers easily. The hard parts are the file bytes and a few very busy posts:
- 800 million files a day must arrive whole from phones that lose signal;
- 42 Tbit/s must come from servers near the viewer, with access checked at the edge;
- a few posts and stories are read or liked by millions at once.