The two caches: what they store and why they matter
Cache 1 — Per-user feed lists (IDs)
- Purpose: store a precomputed, bounded list of post IDs per active user (the feed list).
- Typical list size: store up to 500 post IDs per user.
- ID size: approximately 8 bytes per post ID.
- 500 post IDs × 8 bytes = 4,000 bytes ≈ 4 KB per user.
- For 10,000,000 active users: 4 KB × 10,000,000 = 40 GB (estimate; overhead and metadata will increase this).
Cache 2 — Post content cache (payloads)
- Purpose: cache the actual post payloads (text, media pointers, metadata) so the app server can fetch content quickly after reading the per-user ID list.
- Example activity: if each active user posts on average 3 times per month, and there are 10M active users:
- 3 × 10,000,000 = 30,000,000 posts per month.
- If each post payload averages ~1 KB:
- 30,000,000 × 1 KB ≈ 30 GB for one month of posts.
Quick sizing summary

Active users only
- We typically only precompute feed lists for active users — for example, users who opened the app in the last 30 days (configurable).
- Avoid pushing updates into feed lists for users who haven’t used the app in months; this work is likely wasted and consumes cache capacity.
- If an inactive user returns, build their feed on read (generate the list when they open the app) rather than continuously updating their list while they are inactive.
Sizing numbers above are order-of-magnitude estimates to reason about capacity. In production measure actual post sizes, access patterns, and add overhead factors for cache metadata, replication, and other inefficiencies.
Database considerations: choose technology by data shape
Different tables and access patterns map better to different storage systems.
Growth and sharding
- At ~30M posts/month → ~360M posts/year. This growth requires planning for distributed storage.
- One machine cannot hold all posts at scale. Partition (shard) posts across multiple machines and design for rebalancing, replication, and index distribution.
- Consider read/write patterns, hotspots, and the cost of cross-shard joins when selecting a sharding key.
Summary / operational checklist
- Two caches are central:
- Per-user feed lists (IDs): small, per-user, low-latency read.
- Post content cache: holds payloads for hot reads; eviction (LRU) keeps memory bounded.
- Precompute lists only for active users to reduce wasted work and storage.
- Choose database technologies based on data shape (append-only vs relational) and plan for sharding/storage growth.
- Monitor actual post sizes, request patterns, cache hit rates, and re-evaluate cache sizing and eviction policies regularly.
- Least Recently Used (LRU): https://en.wikipedia.org/wiki/Least_recently_used
- Cassandra: https://cassandra.apache.org/