Inkwell readers can now follow writers, and the home page shows the latest posts from everyone they follow. Building that page when it's opened is too slow, so each new post is copied into the feed of every one of its writer's followers, ahead of time. On average a post has 30 followers, so one post means 30 feed writes.
What it does
- Read: a reader opens their home feed.
- Write: a writer publishes a post, which is then written into its followers' feeds.
Workload
A steady 600 rps for 15 seconds, 70% reads / 30% posts, against 10 000 feeds. That's 180 posts a second, so 5 400 feed writes a second. Writing a feed entry takes a worker about 5 ms.
How to build it
The app servers and the queue's fan-out are fixed: each post becomes 30 jobs on the queue. You choose the database's tier and the workers' tier and instances.
- Build the path for reads: client, load balancer, app server, database.
- Send posts from the app server to a queue, connect the queue to a worker, and the worker to the database.
- Size the workers (and the database, if it needs it) so a post reaches its followers' feeds within a couple of seconds, for as little as you can.