BLOG

๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐——๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ฎ ๐—ก๐—ฒ๐˜„๐˜€ ๐—™๐—ฒ๐—ฒ๐—ฑ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ (๐—œ๐—ป๐˜€๐˜๐—ฎ๐—ด๐—ฟ๐—ฎ๐—บ)

Design a ๐—ต๐—ถ๐—ด๐—ต๐—น๐˜† ๐—ฝ๐—ฒ๐—ฟ๐˜€๐—ผ๐—ป๐—ฎ๐—น๐—ถ๐˜‡๐—ฒ๐—ฑ, ๐—น๐—ผ๐˜„-๐—น๐—ฎ๐˜๐—ฒ๐—ป๐—ฐ๐˜† ๐—ป๐—ฒ๐˜„๐˜€ ๐—ณ๐—ฒ๐—ฒ๐—ฑ ๐˜€๐˜†๐˜€๐˜๐—ฒ๐—บ that aggregates content from followed users and recommended sources, ranks it by relevance using machine learning, and delivers it in a paginated, infinitely scrolling format to millions of concurrent users.

April 15, 2026ยท3 min readยท34 views
๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐——๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ฎ ๐—ก๐—ฒ๐˜„๐˜€ ๐—™๐—ฒ๐—ฒ๐—ฑ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ (๐—œ๐—ป๐˜€๐˜๐—ฎ๐—ด๐—ฟ๐—ฎ๐—บ)

The system operates on a ๐—ฝ๐˜‚๐˜€๐—ต-๐—ฝ๐˜‚๐—น๐—น ๐—ต๐˜†๐—ฏ๐—ฟ๐—ถ๐—ฑ ๐—ฎ๐—ฟ๐—ฐ๐—ต๐—ถ๐˜๐—ฒ๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ that balances write amplification with read latency. When a user posts content, it is "fanned out" (pushed) to the feeds of active followers via a Feed Write Service. For users with millions of followers (celebrities), the system switches to a pull-based model where the feed is generated on-demand, avoiding the massive write overhead.

When a user opens the app, a Feed Read Service retrieves their personalized feed from a distributed cache. The feed is a pre-computed list of post IDs, ranked by the Ranking Service based on factors like recency, engagement, relationship with the author, and machine learning signals. Thumbnails and media are then fetched from a CDN for fast rendering.

The platform's core consists of ๐—ต๐—ถ๐—ด๐—ต๐—น๐˜† ๐—ผ๐—ฝ๐˜๐—ถ๐—บ๐—ถ๐˜‡๐—ฒ๐—ฑ, ๐—ฒ๐˜ƒ๐—ฒ๐—ป๐˜-๐—ฑ๐—ฟ๐—ถ๐˜ƒ๐—ฒ๐—ป ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ๐˜€:

  • Feed Write Service: Handles fan-out of new posts to follower feed caches.
  • Feed Read Service: Retrieves and paginates the ranked feed for users.
  • Ranking Service: The ML-powered brain that scores and orders posts for personalization.
  • Post Storage Service: Manages post metadata, captions, and comments.
  • Media Service: Handles image/video upload, processing, and CDN delivery.
  • Timeline Cache**: Distributed in-memory store (Redis) holding the pre-computed feed for each user.

Behind the scenes, an ๐—ฎ๐˜€๐˜†๐—ป๐—ฐ๐—ต๐—ฟ๐—ผ๐—ป๐—ผ๐˜‚๐˜€ ๐—ฒ๐˜ƒ๐—ฒ๐—ป๐˜-๐˜€๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ๐—ถ๐—ป๐—ด ๐—ฝ๐—ถ๐—ฝ๐—ฒ๐—น๐—ถ๐—ป๐—ฒ powers personalization. Every view, like, and follow generates an event consumed by the Ranking Service, which continuously updates user embeddings and refines scoring models offline. Batch jobs pre-compute recommendations for cold-start users and generate the "Explore" feed.

This scale demands ๐—ฎ๐—ด๐—ด๐—ฟ๐—ฒ๐˜€๐˜€๐—ถ๐˜ƒ๐—ฒ ๐—ฐ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ด ๐—ฎ๐—ป๐—ฑ ๐—ถ๐—ป๐˜๐—ฒ๐—น๐—น๐—ถ๐—ด๐—ฒ๐—ป๐˜ ๐—ณ๐—ฎ๐—ป๐—ผ๐˜‚๐˜ ๐˜€๐˜๐—ฟ๐—ฎ๐˜๐—ฒ๐—ด๐—ถ๐—ฒ๐˜€. Active users have their feed pre-computed and cached. Inactive users have their feed generated on-demand. The fan-out process is sharded by follower ID and processed asynchronously via message queues to absorb write spikes.

๐—–๐—ฟ๐—ถ๐˜๐—ถ๐—ฐ๐—ฎ๐—น ๐——๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ฃ๐—ฟ๐—ถ๐—ป๐—ฐ๐—ถ๐—ฝ๐—น๐—ฒ๐˜€: ๐Ÿญ) ๐—›๐˜†๐—ฏ๐—ฟ๐—ถ๐—ฑ ๐—ฃ๐˜‚๐˜€๐—ต/๐—ฃ๐˜‚๐—น๐—น ๐—”๐—ฟ๐—ฐ๐—ต๐—ถ๐˜๐—ฒ๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ to handle celebrity users, ๐Ÿฎ) ๐— ๐—Ÿ-๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ฑ ๐—ฅ๐—ฎ๐—ป๐—ธ๐—ถ๐—ป๐—ด for personalization, ๐Ÿฏ) ๐— ๐˜‚๐—น๐˜๐—ถ-๐—ง๐—ถ๐—ฒ๐—ฟ ๐—–๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ด (feed IDs โ†’ post metadata โ†’ media), ๐Ÿฐ) ๐—”๐˜€๐˜†๐—ป๐—ฐ๐—ต๐—ฟ๐—ผ๐—ป๐—ผ๐˜‚๐˜€ ๐—™๐—ฎ๐—ป๐—ผ๐˜‚๐˜ with queue-based processing, ๐Ÿฑ) ๐—˜๐˜ƒ๐—ฒ๐—ป๐˜-๐——๐—ฟ๐—ถ๐˜ƒ๐—ฒ๐—ป ๐—ฃ๐—ฒ๐—ฟ๐˜€๐—ผ๐—ป๐—ฎ๐—น๐—ถ๐˜‡๐—ฎ๐˜๐—ถ๐—ผ๐—ป for continuous model updates.

๐—ง๐—ฒ๐—ฐ๐—ต๐—ป๐—ถ๐—ฐ๐—ฎ๐—น ๐—”๐—ฟ๐—ฐ๐—ต๐—ถ๐˜๐—ฒ๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ ๐—ฆ๐˜๐—ฎ๐—ฐ๐—ธ:

  • ๐—™๐—ฟ๐—ผ๐—ป๐˜๐—ฒ๐—ป๐—ฑ: React, React Native, Swift (iOS), Kotlin (Android)
  • ๐—•๐—ฎ๐—ฐ๐—ธ๐—ฒ๐—ป๐—ฑ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ๐˜€: Python (Django), Java, Go, Node.js
  • ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ๐˜€: PostgreSQL, Cassandra, DynamoDB
  • ๐—™๐—ฒ๐—ฒ๐—ฑ ๐—–๐—ฎ๐—ฐ๐—ต๐—ฒ: Redis, Memcached (for pre-computed timeline IDs)
  • ๐— ๐—ฒ๐—ฑ๐—ถ๐—ฎ ๐—ฆ๐˜๐—ผ๐—ฟ๐—ฎ๐—ด๐—ฒ: AWS S3 + Global CDN (CloudFront, Akamai)
  • ๐— ๐—ฒ๐˜€๐˜€๐—ฎ๐—ด๐—ถ๐—ป๐—ด & ๐—ฆ๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ๐˜€: Apache Kafka, AWS Kinesis
  • ๐— ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด: PyTorch, TensorFlow (for ranking and recommendation models)
  • ๐—ข๐—ฟ๐—ฐ๐—ต๐—ฒ๐˜€๐˜๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป: Kubernetes, Docker, AWS EKS
  • ๐— ๐—ผ๐—ป๐—ถ๐˜๐—ผ๐—ฟ๐—ถ๐—ป๐—ด: Prometheus, Grafana, ELK Stack

๐Ÿ‘‰ Learn more in The Modern System Design Handbook: codewithdhanian.gumroad.com/l/ntmcf
๐Ÿ‘‰ Grab the Master System Design Case Studies: codewithdhanian.gumroad.com/l/oytfng

MORE ARTICLES

Enjoyed this? There's more where that came from.

Browse all posts