High-Level Design — 50 Q&A

All 50 HLD interview questions in question-and-answer form · architecture, scalability, availability, data management, distributed systems, and networking.
In self-test mode, tap a question to reveal its answer.

How to use: Click Hide answers to enter self-test mode — each question collapses, and you tap it to check yourself after answering aloud. Toggle back to read straight through, or Print for a paper copy. Anything you can’t reconstruct from memory is a weak spot to revisit.

Part 2 · High-Level Design (50 Questions)

Architecture & design choices

H1What are the key components of a High-Level Design?

HLD defines the overall architecture — the major modules, how they interact, and cross-cutting concerns like scalability, security, and technology choices. Typical components: clients, a load balancer, application services, one or more databases, a cache, a message queue, and a CDN, plus the communication paths between them.

An e-commerce HLD lays out a User Service, Product Service, and Payment Gateway plus a database, cache, and load balancer, showing how they talk.
H2Monolithic vs microservices — how do you decide?

It depends on application size, expected scale, complexity, and team structure. A monolith is easier to build and deploy but harder to scale as it grows; microservices allow independent scaling, deployment, and tech choices but add operational and communication complexity. Start monolithic if the app is small and refactor toward microservices as you grow.

A startup MVP ships as a monolith; Netflix and Amazon run microservices to scale services independently.
H3Relational vs NoSQL — the trade-offs?

Relational (SQL) offers ACID, strong consistency, complex joins, and structured schemas; NoSQL offers flexible schemas, horizontal scalability, and high performance on large distributed workloads, usually with eventual consistency. Many systems use both.

Banking uses MySQL/PostgreSQL for consistency; social media uses MongoDB/Cassandra for scale.
H6What are the key considerations for a scalable system?

Handling growing users, traffic, and data without degradation via horizontal scaling, caching, partitioning, database replication, asynchronous processing, and distributed infrastructure.

A video platform uses CDNs for static content, Redis for caching, and many app servers behind a load balancer.
H9What are the steps to design an API?

Define resources and endpoints, request/response formats, and communication standards, then add authentication, rate limiting, versioning, and documentation.

E-commerce APIs expose /users, /products, and /orders with JSON, JWT auth, and /api/v1/ versioning.
H16What are the principles of RESTful API design?

Resource-oriented URIs, standard HTTP methods and status codes, statelessness, versioning, and content negotiation — yielding scalable, standardized, maintainable APIs.

GET /users/1, POST /users, and DELETE /users/1 treat users as resources acted on by the correct verbs.
H25Horizontal vs vertical scaling?

Horizontal (scale out) adds machines for scalability and fault tolerance and needs a load balancer; vertical (scale up) upgrades one machine’s CPU/RAM, simple but limited by a hardware ceiling and a SPOF.

A social platform adds app servers behind a load balancer (horizontal); a small app upgrades its server’s RAM (vertical).
H34How would you design an API Gateway?

As a single entry point for client requests: it routes to backend services and centralizes cross-cutting concerns — authentication, rate limiting, logging, request aggregation, and monitoring — giving clients one unified interface.

An e-commerce gateway takes web/mobile requests, validates JWTs, applies rate limits, and forwards to the user, product, and payment services.
H38What is a reverse proxy?

A server that receives client requests and forwards them to backends on their behalf, adding load balancing, caching, security, and routing while hiding backend details. An API gateway is a specialized reverse proxy.

Nginx forwarding requests across multiple app servers.
H41Stateful vs stateless systems?

A stateful system stores session/client state, so requests depend on prior ones, making it harder to scale. A stateless system keeps no client state on the server, so every request is independent — easy to scale and load-balance.

Traditional login sessions are stateful; REST APIs are stateless, each request carrying a JWT.

Scalability, availability & reliability

H4How do you ensure high availability?

Keep the system operational during failures and heavy load by eliminating single points of failure — through redundancy, replication, load balancing, failover, monitoring, and disaster recovery.

Traffic is spread by a load balancer, and if one server fails, requests auto-redirect to healthy instances with no downtime.
H5What is load balancing in HLD?

Distributing incoming traffic across servers for optimal utilization, high availability, and performance — preventing overload and removing single points of failure.

Nginx or AWS ELB spreads user requests across app servers during peak load.
H7How do you handle security concerns in HLD?

Build protection into every layer: authentication, authorization, encryption, and secure APIs, plus monitoring, logging, input validation, and a zero-trust posture.

A banking app uses OAuth 2.0 with MFA, HTTPS/TLS everywhere, and role-based access control.
H11What is the role of fault tolerance?

Keeping the system functioning even when components fail, via redundancy, replication, failure isolation, and graceful degradation.

If the recommendation service dies, the app still works by temporarily hiding recommendations.
H12How do you design for disaster recovery?

Ensure quick recovery from major failures with backups, geo-replication, and automated failover, guided by a defined RPO (max acceptable data loss) and RTO (max acceptable downtime).

A database replicated across regions means that if one data center fails, traffic redirects with minimal loss.
H19What makes a fault-tolerant network infrastructure?

Redundant network paths, load balancing, and dynamic routing so there’s no single point of failure, plus isolation, security, and disaster recovery.

If one data center or route goes down, traffic reroutes through backup routes and standby servers.
H27Latency, throughput, and availability — define them.

Latency is the response delay for a single request; throughput is requests handled per unit time; availability is the percentage of uptime.

A streaming platform wants low latency (fast start), high throughput (millions at once), and high availability (never down).
H50How does auto-scaling work?

It automatically adds or removes servers based on live metrics — CPU, memory, request count — to maintain performance while optimizing cost.

During a festival sale, an e-commerce platform launches extra app servers, then removes them as traffic drops.
H51What is a sticky session?

Session persistence routing a user’s requests to the same backend server for the session (via cookie, IP, or session id), so session data stays available without cross-server sharing. The trade-off is that it undermines even load distribution.

A shopping cart stays consistent because the user keeps hitting the same server through checkout.
H52How does a load balancer detect a failed server?

Through continuous health checks/heartbeats at fixed intervals; a server that stops responding or errors repeatedly is marked failed and removed from rotation.

On four servers, if one crashes the LB stops routing to it and users continue via the healthy three.

Data management

H8What is database indexing?

A structure that speeds retrieval so the database locates records without scanning the whole table — a big query speedup at the cost of extra storage and slightly slower writes.

An index on account_number finds accounts instantly during transactions.
H10How do you ensure data consistency across distributed systems?

With distributed transactions, idempotent operations, and conflict resolution, choosing strong vs eventual consistency per business need in line with CAP.

Online banking uses strong consistency for balances; a social feed uses eventual consistency for scale.
H15How do you handle concurrency control in HLD?

Ensure multiple users/processes safely access shared data via locking, isolation levels, and MVCC — preventing dirty reads, lost updates, and inconsistent state.

Two simultaneous fund transfers can’t corrupt the same account balance.
H18What is database replication?

Copying and maintaining the same data across servers for high availability, fault tolerance, and read scalability.

The primary handles writes while replicas serve product searches and order history.
H23How do you ensure data integrity in HLD?

Keep data accurate and reliable through constraints, validation, and ACID transactions, plus checksums, encryption, logging, and error handling.

A transfer deducts and credits atomically, preventing partial updates.
H24How does the CAP theorem affect distributed DB design?

A distributed system guarantees only two of Consistency, Availability, and Partition tolerance; since partitions are unavoidable, you effectively choose CP or AP.

Banking prefers CP; social media prefers AP to stay accessible during network issues.
H28Sharding vs partitioning?

Both split large datasets. Partitioning divides data within a single database instance; sharding distributes data across multiple servers for scale.

Partition customers by region inside one DB, but shard user data across servers for a global platform.
H36What is consistent hashing?

A distributed hashing technique spreading data across servers on a ring while minimizing data movement when servers change — only about 1/N of keys move.

Redis Cluster distributes cached keys across nodes using it.
H39ACID vs BASE?

ACID (relational) means strong consistency and strict transactions, prioritizing accuracy. BASE (NoSQL) means Basically Available, Soft state, Eventual consistency, prioritizing availability and scale.

PostgreSQL (ACID) for banking; Cassandra (BASE) for social scale.
H47What happens during a cache miss?

The requested data isn’t in the cache, so the system fetches it from the slower backend and usually stores it for next time — a temporary latency increase that improves future reads.

A product not in Redis is fetched from the DB and cached for subsequent requests.
H48What is cache invalidation?

Removing or updating stale cache entries so users get current data, via TTL, write-through updates, or manual invalidation — famously one of the two hard things in computer science.

When a product’s price changes, its cached entry is invalidated or updated.

Caching & content delivery

H14How does a cache know it’s full, and what does it evict?

It tracks memory usage on every add/update, and when the total exceeds the configured limit it triggers an eviction policy (LRU/LFU) to free space.

Redis capped at 1GB using 950MB receives a 100MB object → 1.05GB exceeds the limit → it evicts least-used entries until under 1GB.
H22What is a distributed cache and its advantages?

A cache stored across multiple nodes rather than one machine, giving faster, scalable access, reduced database load, and fault tolerance through replication.

Frequently accessed product details in a Redis Cluster serve quickly even during high traffic.
H29What are cache update strategies?

Caching stores hot data in fast memory to cut response time and DB load, updated via write-through, write-back, cache-aside, or write-around — chosen by consistency needs and read/write pattern.

Update a product cache immediately (write-through), or refresh it only when next read (cache-aside).
H30What is a CDN?

A distributed network of edge servers that cache and deliver content near users, lowering latency, reducing origin load, and speeding global delivery — typically static content.

A streaming platform serves video from the nearest edge server, not the origin.

Distributed systems & communication

H13What is event-driven architecture?

Components communicate through events rather than direct synchronous calls, making the system loosely coupled, asynchronous, scalable, and resilient; producers emit events and consumers process them via a broker.

Placing an order publishes an event to Kafka, and payment, inventory, and notification services each consume it independently.
H17What is the role of a message broker?

Middleware enabling asynchronous communication — receiving, storing, and forwarding messages — decoupling services for scalability, reliability, and fault isolation through buffering.

An order event flows through Kafka or RabbitMQ to the inventory, payment, and notification services.
H31What is leader election?

A mechanism by which distributed nodes select one leader/coordinator to handle centralized tasks — writes, scheduling, synchronization — to avoid conflicts.

In a database cluster, one server is elected leader for writes while others replicate.
H32How do Kafka/RabbitMQ improve system design?

They enable asynchronous communication so services exchange data without direct dependencies, reducing coupling and bottlenecks and improving scalability and reliability by buffering messages and absorbing spikes.

A food-delivery order sends events separately to payment, notification, and delivery, each processed independently.
H33Synchronous vs asynchronous communication?

Synchronous: the sender waits for a reply (tighter coupling, possible delays). Asynchronous: the sender continues without blocking (better scalability and responsiveness).

Payment verification is synchronous; email notifications are asynchronous.
H35What is the circuit breaker pattern?

A fault-tolerance pattern that stops repeated calls to a failing service to prevent cascades and allow recovery, cycling Closed (normal) → Open (fail fast) → Half-Open (test) → Closed.

If the payment service is down, the breaker blocks requests and returns a fallback instead of retrying endlessly.
H37What is service discovery?

A mechanism letting services find and communicate with each other dynamically without hardcoded addresses, automatically tracking changing instances.

Kubernetes services discover each other via internal DNS and a service registry.
H49What happens if the leader node fails?

The remaining nodes detect the failure through heartbeats/timeouts and run a leader election (e.g. Raft or Paxos) to promote a new leader, restoring operation without manual intervention.

A replica is automatically promoted to primary when the primary crashes.
H26What is rate limiting?

Controlling how many requests a client can send in a time window to prevent abuse, overload, and DoS and ensure fair usage; a common algorithm is the token bucket, often enforced at the API gateway.

A public API allows 100 requests per minute per user.
H20What is the role of containerization?

Packaging apps with dependencies into isolated containers for consistent execution across environments, resource efficiency, easy scaling (via Kubernetes), and fault isolation between microservices.

Auth, payment, and notification each run in separate Docker containers, deployed and scaled independently.
H21How do you design for data privacy and protection?

Secure sensitive data across its lifecycle with encryption, access control, and data masking, plus compliance, auditing, and regular assessments.

A healthcare app encrypts patient records (AES), restricts access by role, and logs all access to meet HIPAA.

Networking fundamentals

H42What is the OSI model?

A seven-layer conceptual framework standardizing network communication, each layer with a specific function, simplifying interoperability and troubleshooting: Application, Presentation, Session, Transport, Network, Data Link, Physical.

Opening a website, data flows from the Application layer (HTTP) down to the Physical layer.
H43What is the TCP/IP model?

The practical four-layer model behind the internet — Application, Transport, Internet, Network Access — using protocols like TCP, IP, HTTP, and UDP.

Sending email, SMTP rides on TCP/IP to transfer data reliably.
H44HTTP vs HTTPS?

HTTP is plaintext on port 80 and less secure; HTTPS is encrypted via SSL/TLS on port 443 and secure for sensitive data.

Online banking uses HTTPS to encrypt credentials and payment information.
H45TCP vs UDP?

TCP is connection-oriented, reliable, and ordered but slower (acknowledgments, error-checking) — for accuracy (web, file transfer). UDP is connectionless, faster, and low-overhead with no delivery guarantee — for speed (gaming, live video).

Banking uses TCP; live streaming and online games use UDP.
H46What is DNS and why is it important?

The Domain Name System translates human-readable domain names into IP addresses so machines can locate each other — the phonebook of the internet.

Typing “youtube.com” makes DNS return the server’s IP so the browser can connect.
H40HLD vs LLD — the summary?

HLD is the overall architecture — modules, databases, APIs, scalability — from the planning phase, architecture-oriented. LLD is the detailed implementation — classes, methods, object interactions — just before coding, code-oriented.

In a food-delivery app, HLD defines the User and Payment services; LLD designs the User, Order, and PaymentProcessor classes.