Practice — System Design Basics (5 questions)
Horizontal vs Vertical Scaling
Explain the difference between horizontal scaling and vertical scaling. What are the key trade-offs, and why do large-scale web systems typically prefer horizontal scaling?
Latency vs Throughput
A web service has a latency of 500 ms per request and can handle 1,000 requests per second. An engineer proposes adding a cache in front of the database, which reduces latency to 20 ms for 80% of requests.
- How does caching affect throughput?
- What is the risk introduced by caching, and how would you mitigate it?
Availability Nines
A payment processing service has a monthly availability SLA of 99.95%.
- How many minutes of downtime is that per month (assume a 30-day month)?
- If the service is composed of two independent components each with 99.99% availability, what is the combined availability?
Stateless Services
What does it mean for an application server to be "stateless"? Why is statelessness a prerequisite for horizontal scaling? Give a concrete example of a stateful design and how you would refactor it to be stateless.
Message Queue Use Case
An e-commerce site sends a welcome email immediately after a user registers. The current implementation calls the email API synchronously inside the registration handler. The email API occasionally takes 3–5 seconds to respond, making registration feel slow.
Redesign this using a message queue. Draw the new request flow and explain the trade-offs.