RETURN TO SYSTEM DESIGN VAULT (55)BLUEPRINT #33 // Medium
#33MediumHigh-Concurrency Feeds & Social

Count Facebook Likes, Especially for High-Profile Users

ASKED IN INTERVIEWS AT:MetaAmazonTwitter

EXECUTIVE SUMMARY & PROBLEM STATEMENT

Design a high-volume like counting service that prevents database write contention when a celebrity post receives tens of thousands of concurrent likes per second.

SCALE ESTIMATION & TRAFFIC ENVELOPE

DAILY ACTIVE USERS / TPS1 Billion daily likes across millions of posts
READ / WRITE TRAFFIC RATIOHeavy concurrent writes on hot viral posts
5-YEAR STORAGE CAPACITYDistributed counter shards in Redis memory

FUNCTIONAL REQUIREMENTS

  • [1]Like and unlike posts
  • [2]Display real-time aggregated like counter on UI

NON-FUNCTIONAL REQUIREMENTS

  • •Handle 50K likes/sec on a single post without row locking
  • •Eventual consistency within 1-2 seconds
  • •Accurate non-duplicative counts per user

CORE ARCHITECTURAL COMPONENTS

Like Ingestion Gateway
Sharded Redis Counter Cluster
Message Bus (Kafka)
Batch Flusher to Database
WebSocket Live Count Emitter

DATA SCHEMA & PERSISTENCE

UserLikes (post_id, user_id) for deduplication; Redis Counter: `post_likes:{post_id}:{shard_0..15}`

DISTRIBUTED TRADE-OFFS & FAILURE MODES

  • ⟡Distributing a single counter across 16 random Redis keys eliminates hot-key CPU saturation; reading sums across the 16 keys.