Scaling and Trade-offs in Design Interviews
Scaling and trade-offs are the part of a design interview where you explain how the design grows and what each choice costs. A good answer names the gain of a choice and its cost in the same breath.
Name the scaling moves
A short list of moves keeps the scaling part focused. Each move answers one growth problem.
options = ["add a cache", "split the data", "add more servers"]
for option in options:
print("-", option)Pair every gain with a cost
A trade-off table makes the cost visible. The interviewer can then judge the choice fairly.
choices = [("cache", "fast reads", "stale data risk"), ("split data", "more room", "harder queries")]
for name, gain, cost in choices:
print(name, "gains", gain, "costs", cost)Check the arithmetic before choosing
Small estimates test whether a move is even needed. A design that fits on few servers needs no bold scaling claim.
users = 10000
requests_each = 10
total = users * requests_each
print("total requests:", total)
print("per server:", total // 4)Example
options = [("cache first", 3, 1), ("split data", 2, 2)]
for name, gain, cost in options:
print(name, "score", gain - cost)
print("choice: cache first")Key points
- Scaling: changing a design so it keeps working as users and data grow.
- Trade-off: a choice that gains one quality while giving up another.
- Use a cache to serve repeated reads fast, and accept that cached data can go stale.
- Use data splitting to make room for growth, and accept that queries across parts get harder.
- The existing System Design courses are prerequisites for this lesson, and they cover each scaling technique in depth.
Each option gets a gain score minus a cost score. The cache option scores higher, so it is the stated choice. The numbers are a comparison aid, not measured results.
Note
name the cost of your own choice before the interviewer asks for it.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Python Playground
Exercise
An interviewer asks what a caching choice costs. Which answer shows a real trade-off?