Course contentsShow
← System Design
Lesson 1663 of 1,91940. Real-World System: Social Media FeedFree lesson

Hot and Cold Timeline Data

Separating recent timeline data in fast storage from older data that can be archived or stored in slower, cheaper systems.

Hot and Cold Timeline Data

What You'll Learn

You'll learn why and how social media systems separate recent timeline data in fast storage from older data in slower, cheaper storage to optimize cost and performance.


The Core Idea

In a social media feed, users overwhelmingly interact with recent content. Posts from the last few hours or days get the vast majority of views, while older posts are rarely accessed. This creates a natural opportunity to treat timeline data differently based on age.

Hot data is recent timeline content (e.g., last 7–30 days) that gets frequent access. It should live in fast, expensive storage like in-memory caches (Redis), SSDs, or primary database instances.

Cold data is older timeline content that users rarely view. It can be moved to slower, cheaper storage like HDD-based databases, object storage (S3), or dedicated archival systems.


Why Separate Hot and Cold?

Think of your closet: you keep everyday clothes at eye level (hot data) and seasonal items in boxes on high shelves (cold data). You optimize access based on frequency.

For a system serving 500 million users, storing all timeline entries in premium SSD storage would be prohibitively expensive. By keeping only the last 30 days in fast storage and archiving the rest, you might reduce storage costs by 80% while maintaining 99%+ of access performance.


Implementation Strategy

  • Hot tier: Timeline entries from the last 7–30 days stored in Redis, Cassandra SSD nodes, or partitioned PostgreSQL
  • Cold tier: Older entries moved to object storage, compressed archives, or lower-tier database partitions
  • Access pattern: Query hot tier first; only fetch from cold tier on explicit user request (like "view older posts")

Key Takeaway: Separating hot (recent, frequently accessed) and cold (old, rarely accessed) timeline data dramatically reduces storage costs while maintaining excellent performance for typical user access patterns.