System Design
Message queues, RPC, gRPC, and system design.
9 questions
MiddleTheoryVery commonHow do you do capacity estimation for a system?
How do you do capacity estimation for a system?
Approximate data sizes (a char ~1 byte, metadata ~KBs, an image ~MBs) and traffic, then derive read/write RPS (daily counts ÷ 86,400), storage per day or month, and bandwidth — remembering peak traffic can be roughly 10× the steady average.
Common mistakes
- ✗Using total daily requests as
RPSinstead of dividing by 86,400 seconds - ✗Ignoring peak traffic and sizing only for the steady average load
- ✗Forgetting to estimate storage growth and bandwidth alongside request rate
Follow-up questions
- →How would you estimate storage for five years of growth with a safety margin?
- →Why size for peak
RPSrather than the average when provisioning servers?
MiddleTheoryVery commonVertical vs horizontal scaling: how do they differ and why is horizontal the main lever?
Vertical vs horizontal scaling: how do they differ and why is horizontal the main lever?
Vertical scaling buys a bigger single box and soon hits a ceiling; horizontal scaling adds nodes behind a load balancer and scales near-linearly, which is why it is the main lever for growth. It requires stateless services so any node can serve any request.
Common mistakes
- ✗Expecting a
load balancerto make stateful services scale without removing local session state - ✗Believing a single vertically-scaled box has no ceiling and scales like adding nodes
- ✗Confusing throughput gains from more nodes with lower latency for one request
Follow-up questions
- →Why must a service be stateless to scale horizontally behind a
load balancer? - →Where do you store session state once you remove it from the application nodes?
JuniorTheoryCommonWhat is a message queue, and why use one?
What is a message queue, and why use one?
A broker passing messages between producers and consumers, decoupling them: the producer enqueues and moves on while consumers process asynchronously at their own pace, giving buffering for spikes, retries, and loose-coupled scaling.
Common mistakes
- ✗Thinking a queue makes calls synchronous rather than decoupling producer and consumer
- ✗Assuming messages are lost when a consumer is temporarily down instead of buffered
- ✗Confusing a message queue with a plain database table that has no retry semantics
Follow-up questions
- →How does a queue handle a message a consumer fails to process — retries and dead-letter queues?
- →What is the difference between a point-to-point queue and a publish-subscribe topic?
MiddleTheoryCommonHow do you monitor a web application in production?
How do you monitor a web application in production?
Across three pillars: metrics (request rate, error rate, latency — the RED method — via Prometheus/Grafana), logs (structured, centralized), and traces (distributed request flow). Add health checks, alerting on SLO breaches, and error tracking like Sentry. Watch the golden signals, not just CPU.
Common mistakes
- ✗Equating monitoring with a simple uptime ping
- ✗Watching only host CPU/RAM and ignoring application golden signals
- ✗Being reactive (logs after complaints) instead of alerting on SLOs
Follow-up questions
- →What are the RED and USE methods, and when does each apply?
- →How do metrics, logs, and traces differ, and why do you need all three?
MiddleTheoryCommonWhat is database sharding, and what is the key decision?
What is database sharding, and what is the key decision?
Sharding horizontally partitions data across multiple databases so each holds a subset, spreading load and storage beyond one node. The critical choice is the shard key: it must spread data and traffic evenly and fit common queries.
Common mistakes
- ✗Confusing
sharding(splitting data) with replication (copying it whole) - ✗Picking a shard key that creates hotspots or forces cross-shard joins
- ✗Thinking
shardingis vertical scaling of one server'sCPUand memory
Follow-up questions
- →How do range-based, hash-based, and directory-based
shardingdiffer? - →What problems arise when a query must join data across multiple shards?
JuniorTheoryOccasionalWhat steps structure a system-design interview?
What steps structure a system-design interview?
Clarify requirements, make capacity estimates, define the API, sketch a high-level design of components and interactions, then detail it with trade-offs and bottlenecks and discuss scaling. Avoid naming concrete tech too early.
Common mistakes
- ✗Jumping to specific technologies before clarifying functional requirements
- ✗Skipping capacity estimation and never sizing traffic or storage
- ✗Designing in a vacuum without stating trade-offs and bottlenecks
Follow-up questions
- →Which functional and non-functional requirements would you clarify first and why?
- →How do you decide which component is the likely bottleneck before scaling it?
JuniorTheoryOccasionalWhat is RPC (Remote Procedure Call)?
What is RPC (Remote Procedure Call)?
A technique that lets a program call a procedure in another address space — process or machine — as if local. The framework handles the client-server protocol plus serialization of arguments and results; calls are typically synchronous.
Common mistakes
- ✗Believing
RPCworks only inside one process rather than across the network - ✗Forgetting that arguments and results must be serialized to cross the wire
- ✗Assuming all
RPCis asynchronous when classicRPCblocks for a reply
Follow-up questions
- →How does
RPCdiffer from aRESTcall overHTTP? - →What is an interface definition language (
IDL) and why doRPCframeworks use one?
MiddleTheoryOccasionalWhat is gRPC, and what is it built on?
What is gRPC, and what is it built on?
A high-performance RPC framework from Google over HTTP/2, using Protocol Buffers for compact binary serialization and typed contracts. Multiplexing, streaming, and protobuf make it fast for microservice calls.
Common mistakes
- ✗Confusing
gRPCwithREST/JSONinstead ofHTTP/2plusProtocol Buffers - ✗Forgetting that
gRPCsupports streaming over a multiplexedHTTP/2connection - ✗Not realizing protobuf gives a typed schema and generated client stubs
Follow-up questions
- →What four streaming modes does
gRPCsupport overHTTP/2? - →Why is
Protocol Buffersmore compact and faster to parse thanJSON?
SeniorTheoryRareHow do you scale toward a billion users?
How do you scale toward a billion users?
Layer the techniques: stateless services behind load balancers, caching and CDN, read replicas, a message queue and rate limits, NoSQL where relational scaling stalls, shard the database by a good key, and finally span regional data centers.
Common mistakes
- ✗Believing one vertically-scaled server can serve a billion users
- ✗Sharding the database before adding caches and
read replicas first - ✗Assuming multiple regional data centers reduce rather than raise availability
Follow-up questions
- →When does it make sense to introduce
NoSQLinstead of scaling a relational database? - →What new consistency problems appear once data spans multiple regional data centers?