Design Real-time Activity Feed
Serve home timeline feeds for 30,000 peak requests/sec (90% reads). Ensure p99 latency stays under 200ms with 99.9% availability.
| Category & Difficulty | Read-Heavy & Caching · MEDIUM |
|---|---|
| Traffic Profile | 30,000 RPS sustained, 42,000 RPS spike (90% reads / 10% writes) |
| Latency & Availability SLA | p99 < 200 ms · 99.9% availability |
| Monthly Infra Budget | $650/month |
Scale, traffic & SLA targets
To pass in the DesignTheSystem simulator, your architecture must hold all four targets simultaneously across a 60-second load run (spiking up to 42,000 RPS):
- Users (50M daily): Most follow a few hundred accounts; a few accounts have millions of followers.
Functional & non-functional requirements
Functional scope
- Publish a post.
- See a home feed of recent posts from people you follow, newest first.
Non-functional goals
- p99 latency under 200 ms at the spike.
- At least 99.9% of requests answered.
- Costs no more than $650 a month.
- Feed loads must be fast on mobile.
- Celebrity accounts must not slow everyone else down.
Core challenge: Build feeds before they are read
Reading a feed should not mean joining many tables on every page view. Prepare each user's feed ahead of time and keep it in a cache, so a page load is one quick read.
What breaks first?
Building it on open means joining posts with follows for every page view, which is far too slow at this volume. Instead, when someone posts, a worker adds the post id to each follower's feed list in Redis. Opening the app is then one read of a ready list.
Key architectural trade-offs
- A new post can take a moment to appear in followers' feeds.
- Storing a feed per user uses a lot of memory; capping the length keeps it bounded.
Starting architecture & how to practise
The simulator starts you with a baseline setup: Mobile App Users → Timeline Service → Posts & Follows DB. Run the baseline under 30,000 RPS to watch exactly which component saturates first, then add caching, queues, replicas, sharding or CDN until latency, availability and cost all turn green.
Common interview questions for Real-time Activity Feed
What are the target SLA and scale numbers for Real-time Activity Feed?
Design for 30,000 RPS sustained (spiking to 42,000 RPS) with a 90% read / 10% write mix, keeping p99 latency under 200 ms, availability at or above 99.9%, and infrastructure spend within $650/month.
What is the main architectural bottleneck in Real-time Activity Feed?
Reading a feed should not mean joining many tables on every page view. Prepare each user's feed ahead of time and keep it in a cache, so a page load is one quick read.
How can I verify my Real-time Activity Feed architecture works under load?
Open the live simulator to wire up load balancers, caches, queues, replicas, or shards and run a 60-second traffic simulation that grades latency, error rate, and monthly cost automatically.
Recommended lessons before you build
Real-time fan-out with pub/sub
Deliver one message to many connected users within a second.
Shared state every server can see
Keep fast-changing state in one shared place instead of inside each server.
Caching reads: cache-aside and hit rate
Put a cache in front of a database and work out how much load it really takes off.
Related Read-Heavy & Caching problems
High-Volume URL Shortener
Design a URL shortening service handling 20,000 peak requests/sec with a 99:1 Read/Write ratio. Keep p99 latency under 50ms with 99.99% availability.
E-Commerce Search & Catalog
Serve high-traffic product catalog queries for 15,000 peak RPS (95% reads). Maintain p99 latency under 80ms while protecting database IOPS.
Design Pastebin Text Sharing
Design a text-sharing service like Pastebin handling 15,000 read RPS and 1,500 write RPS. Store text payloads in Object Storage while querying metadata rapidly with low latency.
Design Key-Value Store
Design Key-Value Store: Architect a scalable, highly-available distributed system capable of sustaining 25,000 peak RPS (80% reads). Maintain p99 latency under 80ms with 99.9% availability while optimizing monthly infrastructure cost within $600/mo.