Design a Photo Portfolio
A photographer shows their work online. Each gallery page is a few small records, such as titles and captions, and a lot of large photo files: about 9 in 10 requests are for a photo. The original photos are the only copies of the photographer's work, so they must never be lost. Now and then a gallery is featured on a popular site and far more people arrive than usual. Visitors should see photos quickly, and the monthly bill should stay modest.
Constraints
- A page must load within 300 ms on a normal day
- About 1,000 requests per second on a normal day, and about 9 in 10 are for a photo file
- When a gallery is featured, traffic can reach about 5 times that for a few hours
- The original photos must never be lost
- Keep infrastructure under $2,200 a month
Scenarios to survive
Normal day
Steady traffic, mostly photos.
Interviewer asks: Which requests on a normal day are for records and which are for files? Where does each kind get answered?
Gallery featured on a popular site (5x)
A gallery is linked from a big site and traffic jumps to five times normal for a few hours.
Interviewer asks: Most of the extra load is for the same few photos. What could answer those requests without bothering your servers or your storage?
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 gallery is featured
- Total monthly cost stays within $2,200
- The original photos are kept in storage built for files
- Popular photos are delivered from copies kept close to visitors
- The design explains why the copies near visitors are not where the originals are kept