System Design – X vs Y (Audio)

Read or tap ▶ to hear it spoken. Works fully offline.

Load Balancer vs API Gateway

Use a load balancer when your main concern is distributing traffic and keeping servers healthy. A load balancer operates at the network or HTTP level and routes requests to backend services.

Use an API gateway when you need request routing plus authentication, rate limiting, request transformation, and centralized policy enforcement. In many systems, the API gateway sits behind a load balancer.

Caching vs Database Indexing

Use caching when you want to avoid hitting the database entirely for repeated reads. Caches reduce latency and backend load but risk stale data.

Use database indexing when you need faster queries while still reading from the database. Indexes improve read speed but slow down writes and increase storage usage.

Sharding vs Replication

Use sharding when your data no longer fits on a single machine or write throughput is the bottleneck. Sharding splits data across nodes.

Use replication when availability and read scalability are the priority. Replication copies the same data across nodes but does not increase write capacity.

Strong Consistency vs Eventual Consistency

Use strong consistency when correctness matters more than latency or availability, such as banking or inventory systems.

Use eventual consistency when low latency and high availability are more important, such as social feeds or analytics. Eventual consistency assumes data will converge over time, not immediately.

Monolith vs Microservices

Use a monolith when the system is small, the team is small, or development speed matters most. Monoliths are easier to debug and deploy.

Use microservices when teams need independent scaling, deployments, and ownership. Microservices increase operational complexity and failure modes.

Message Queue vs Direct Synchronous Calls

Use message queues when you want asynchronous processing, resilience to spikes, or loose coupling between services. Queues improve reliability but add latency and complexity.

Use direct synchronous calls when you need immediate responses and simpler control flow.

Vertical Scaling vs Horizontal Scaling

Use vertical scaling when simplicity matters and limits are acceptable. Vertical scaling means upgrading a single machine.

Use horizontal scaling when you need fault tolerance and large scale. Horizontal scaling adds machines and requires distributed system design.

WebSockets vs Polling

Use WebSockets when you need real-time, bidirectional updates like chat or live dashboards. WebSockets maintain persistent connections.

Use polling when updates are infrequent or simplicity is more important. Polling is easier to scale but less efficient.