500M tweets/day * 500B on tweet = 250GB/day = 90TB/year = 3MB/s
The each tweet is copied to the followers timeline, so there are 3MB/s*300 - 900MB/s.
Also it's 500M * 300 = 150B timeline insterts/day and 1.7M inserts.
Timeline reads: ~1M/s (each DAU reads ~5 timelines/day → 1B reads/day) Likes: ~50k/s · Follows: ~20k/s
There is also graph of followers - 300 * 1B = 300B edges. About 50B per edge so it sums to 15TB
Likes 1B/day.
User loads app by reaching Frontend cached by CDN.
Using loaded app, User sends request to fetch timeline.
User is unauthenticated due to logout.
When user passes authentication, the timeline is fetched.
General requests schema:
Frontend sends request to LoadBalancer/Reverse Proxy. It's responsible for ssl-termination, load-balancing Then request is routed to Api-gateway is an entrypoint does rate-limiting, authorization (if neccessary reaching Auth Service to process authentication), and routing requests to services.
Timeline:
Tweet creation:
Following:
Unfollowing:
Likes/Unlikes:
Main Database - Mysql (replicated):
Redis as a timeline cache (sharding)
RabbitMQ as message broker (sharded):
Common path:
Tweet Creation path:
Timeline retrieval:
The TTL for Tweets on timeline is 7 days from creation.
Edge cases: