{
  "id": 4324120,
  "title": "HLD: Twitter / X",
  "url": "https://urgent.news/2026/08/30/hld-twitter-x",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-30T02:00:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gouranga-das-khulna/hld-twitter-x-41kc"
  },
  "original_language": "en",
  "account": "Twitter, now known as X, is a social media platform that allows users to post tweets, follow each other and view a timeline of tweets from accounts they follow. To design such a system, several functional and non-functional requirements must be considered.\n\nFunctional requirements include posting tweets which may contain text, images, or videos, following or unfollowing users, viewing a home timeline consisting of tweets from followed users in reverse chronological order, liking, retweeting and replying to tweets, viewing a user's profile with their tweet history, and searching for tweets.\n\nNon-functional requirements include ensuring high availability since Twitter is a utility, using eventual consistency allowing the timeline to be slightly stale (seconds), low latency for quick timeline load (200ms), a read-heavy design with a 100:1 read-to-write ratio, and the ability to handle 300 million daily active users and 500 million tweets per day.\n\nEstimating the scale of the platform, the average tweet is approximately 300 bytes with additional metadata. Therefore, 500 million tweets per day would require around 500 GB of storage per day. Media uploads could account for up to 100 TB per day. Timeline caching requires a sorted set for each user with a maximum of 800 tweets, and a TTL of 7 days.\n\nAPI design includes endpoints for posting a tweet, getting a user's timeline, getting a user's tweets, liking or unliking a tweet, following or unfollowing a user. The core problem lies in generating the home timeline. Initially, a push approach was used where the user's followers would receive the tweet, but this proved problematic with celebrities having hundreds of thousands of followers. A hybrid approach was adopted, combining fan-out on write for regular users with fan-out on read for celebrity users. Read requests are fulfilled by fetching pre-computed timelines from Redis and recent tweets from the celebrity accounts through fan-out reads.\n\nThe architecture consists of a CDN serving static assets and media, an API gateway and load balancer, tweet and timeline services, media service handling image uploads, resizing, and CDN storage, and a fan-out service using Apache Cassandra for write-heavy operations and Kafka for asynchronous fan-out. Redis is used for timeline caching with a sorted set of tweet IDs, and Elasticsearch is used for searching tweets.\n\nThe main challenge is the \"celebrity\" problem where hot accounts like Elon Musk, with millions of followers, pose a significant load on the system. To address this, the system avoids fan-out for these users, instead pre-calculating their timelines and caching recent tweets. This ensures the system remains scalable and performant, despite the popularity of certain accounts.",
  "summary": "Design a social media platform where users post tweets, follow each other, and see a timeline of tweets from accounts they follow. 1️⃣ Clarify Requirements Functional Requirements Post a tweet (text, images, videos) Follow / unfollow users View home timeline (tweets from followed users, newest first) Like, retweet, reply User profile with tweet history Search tweets Non-Functional Requirements…",
  "key_points": [
    "Twitter rebranded to X",
    "Home timeline generated via hybrid fan-out approach",
    "System designed to handle 500 million tweets daily"
  ],
  "editors_take": "The redesigned architecture combining fan-out on write and fan-out on read helps maintain scalability and performance, particularly for accounts with massive followings, by efficiently managing load and caching pre-computed timelines.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}