Design a Personal Blog
A hobbyist writes a blog about hiking trips. Each visit is a request: a server builds the page from posts kept in a database. On most days the blog is quiet. Now and then a post is shared on a big news site and, for a few hours, far more people arrive than usual. Visitors should still get their page, even if one of your servers has a bad day, and the monthly bill should stay small.
Constraints
- A page must load within 300 ms on a normal day
- About 100 page views per second on a normal day
- When a post is shared, traffic can reach about 12 times that for a few hours
- The blog keeps working if one server fails
- Keep infrastructure under $1,800 a month
Scenarios to survive
Normal day
Steady, quiet traffic.
Interviewer asks: Follow one page view from the visitor to the database and back. Which block is busiest on a normal day, and how do you know?
Shared on a news site (12x)
A post is shared and traffic jumps to twelve times normal for a few hours.
Interviewer asks: Traffic is twelve times higher. Which block fills up first, and what are your two options for coping?
A server fails
One of the servers stops working on an ordinary day.
Interviewer asks: One server stops at an ordinary moment. What does a visitor see in your design?
What a good design must do
- Pages load within the latency target on a normal day
- At least 98% of visitors are served when a post is shared
- The blog keeps working when one server fails
- Total monthly cost stays within $1,800
- A server builds each page from posts kept in a database