🏗️

System Design MCQ

Test your System Design knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.

100 Questions 40 Beginner 40 Intermediate 20 Advanced

How This Practice Test Works

Every question below expands right on this page — click a question to reveal its four options, pick the one you think is correct, and you'll get instant feedback along with the correct answer and a short explanation of the reasoning. Questions are grouped by difficulty, so start with the 40 beginner questions to confirm your fundamentals, work through the 40 intermediate ones, and finish with the 20 advanced questions that mirror what exams and technical screenings actually ask. There's no sign-up, no timer, and no limit — retake the test as often as you like.

Curated by Tech Baithak Editorial Team  ·  Last updated: June 2026

1

What is the primary goal of system design in software engineering?

A

Correct Answer

To define the architecture, components, and interactions of a system to meet functional and non-functional requirements

Explanation

System design focuses on high-level structure — how components interact, scale, and meet requirements like performance, reliability, and availability — before or alongside implementation.

2

What is the difference between "functional" and "non-functional" requirements?

A

Correct Answer

Functional requirements describe what the system should do; non-functional requirements describe qualities like performance, scalability, and reliability

Explanation

Functional requirements specify features and behaviors (e.g., "users can log in"), while non-functional requirements specify system qualities (e.g., "must handle 10,000 requests/sec").

3

What does "scalability" mean for a system?

A

Correct Answer

The ability of a system to handle increasing load (users, data, traffic) by adding resources

Explanation

Scalability describes how well a system can grow to handle more load, either by adding more powerful machines (vertical) or more machines (horizontal).

4

What is the difference between "vertical scaling" and "horizontal scaling"?

A

Correct Answer

Vertical scaling adds more power (CPU/RAM) to an existing machine; horizontal scaling adds more machines to the system

Explanation

Vertical scaling ("scale up") increases a single server's capacity, while horizontal scaling ("scale out") distributes load across multiple servers, often offering better fault tolerance.

5

What is a "load balancer" used for?

A

Correct Answer

Distributing incoming network traffic across multiple servers to improve availability and performance

Explanation

A load balancer sits in front of multiple servers and distributes incoming requests among them, preventing any single server from becoming a bottleneck or single point of failure.

6

What is "caching" in system design?

A

Correct Answer

Temporarily storing frequently accessed data in a fast-access location to reduce latency and load on the primary data source

Explanation

Caching stores copies of data (e.g., in memory) closer to where it's needed, reducing repeated expensive computations or database queries and improving response times.

7

What is a "database index" used for?

A

Correct Answer

To speed up data retrieval operations by providing a faster lookup structure, at the cost of additional storage and slower writes

Explanation

Indexes (often B-trees) allow the database to find rows matching a query without scanning the entire table, significantly speeding up reads at some cost to write performance.

8

What is the difference between a SQL (relational) database and a NoSQL database?

A

Correct Answer

SQL databases use structured tables with fixed schemas and relationships; NoSQL databases offer flexible schemas and are often optimized for specific data models like documents or key-value pairs

Explanation

SQL databases (like PostgreSQL, MySQL) enforce schemas and relationships with ACID guarantees, while NoSQL databases (like MongoDB, Cassandra, Redis) trade some consistency or structure for flexibility and horizontal scalability.

9

What is an "API" in the context of system design?

A

Correct Answer

A defined set of rules and protocols that allows different software components or systems to communicate with each other

Explanation

An API (Application Programming Interface) defines how different software components interact, specifying requests, responses, and data formats, enabling modular and decoupled systems.

10

What does "latency" mean in the context of system performance?

A

Correct Answer

The time it takes for a request to travel and receive a response, often measured in milliseconds

Explanation

Latency measures delay — how long it takes for an operation (like a network request) to complete — and is a key performance metric users directly experience.

11

What does "throughput" measure in a system?

A

Correct Answer

The amount of work or number of requests a system can process in a given period of time

Explanation

Throughput is often measured in requests per second (RPS) or transactions per second (TPS), reflecting a system's overall processing capacity.

12

What is the purpose of a CDN (Content Delivery Network)?

A

Correct Answer

To cache and serve content from servers geographically closer to users, reducing latency for static assets

Explanation

CDNs distribute copies of static content (images, scripts, videos) across edge servers worldwide, so users are served from a nearby location, reducing latency and origin server load.

13

What does "availability" mean for a system?

A

Correct Answer

The proportion of time a system is operational and able to respond to requests

Explanation

Availability is often expressed as a percentage of uptime (e.g., "99.9% availability"), indicating how reliably a system is accessible to users.

14

What is meant by a "single point of failure" (SPOF)?

A

Correct Answer

A component whose failure would cause the entire system to stop working, with no redundancy

Explanation

Identifying and eliminating SPOFs (e.g., via redundancy, replication, failover) is a key goal in designing reliable systems, since a single failure shouldn't bring down the whole system.

15

What is "redundancy" in system design?

A

Correct Answer

Duplicating critical components or data so that if one fails, another can take over, improving reliability

Explanation

Redundant components (extra servers, replicated data) provide failover options, increasing a system's overall reliability and availability when individual parts fail.

16

What is the role of a reverse proxy (e.g., Nginx) in a web architecture?

A

Correct Answer

It sits between clients and backend servers, forwarding requests and often handling tasks like load balancing, SSL termination, and caching

Explanation

A reverse proxy receives client requests on behalf of backend servers, providing benefits like load balancing, caching, compression, and centralized SSL handling.

17

What is "replication" in the context of databases?

A

Correct Answer

Copying data from one database server to one or more other servers to improve availability and read performance

Explanation

Replication maintains copies of data across multiple servers (e.g., primary-replica setups), enabling read scaling, failover, and protection against data loss.

18

What is the difference between "synchronous" and "asynchronous" communication between services?

A

Correct Answer

In synchronous communication, the caller waits for a response before continuing; in asynchronous communication, the caller continues without waiting for an immediate response

Explanation

Synchronous calls (like typical HTTP requests) block until a response arrives, while asynchronous communication (like message queues) lets the caller proceed and handle the result later.

19

What is a "message queue" (e.g., RabbitMQ, SQS) used for?

A

Correct Answer

To allow services to communicate asynchronously by sending messages that are stored and processed independently, decoupling producers and consumers

Explanation

Message queues decouple the sender and receiver in time, allowing producers to send messages without waiting for consumers to process them immediately, improving resilience and scalability.

20

What does "fault tolerance" mean for a system?

A

Correct Answer

The ability of a system to continue operating properly even when some of its components fail

Explanation

Fault-tolerant systems are designed with redundancy and failure-handling mechanisms so that individual component failures do not cause overall system outages.

21

What is the purpose of a "health check" endpoint in a microservice?

A

Correct Answer

To allow monitoring systems or load balancers to verify that a service is running correctly and able to handle requests

Explanation

Health check endpoints (e.g., /health) report whether a service and its dependencies are functioning, enabling automated systems to route traffic away from unhealthy instances.

22

What is a "monolithic" application architecture?

A

Correct Answer

An architecture where all components of an application are built and deployed as a single, tightly coupled unit

Explanation

Monolithic applications package all functionality into one deployable unit, which can be simpler to develop initially but harder to scale or update independently as it grows.

23

What is a "microservices" architecture?

A

Correct Answer

An architectural style where an application is composed of small, independently deployable services that communicate over a network

Explanation

Microservices break an application into smaller, independently deployable services, each focused on a specific capability, communicating via APIs or messaging.

24

Why might a system use "rate limiting"?

A

Correct Answer

To control the number of requests a client can make in a given time period, protecting the system from overload or abuse

Explanation

Rate limiting protects services from being overwhelmed by too many requests (whether accidental or malicious), ensuring fair usage and system stability.

25

What is "DNS" (Domain Name System) responsible for?

A

Correct Answer

Translating human-readable domain names (like example.com) into IP addresses that computers use to locate servers

Explanation

DNS acts like a phonebook for the internet, mapping domain names to IP addresses so browsers know which server to connect to.

26

What is the difference between "HTTP" and "HTTPS"?

A

Correct Answer

HTTPS is HTTP with an added layer of encryption (TLS/SSL) to secure data transmitted between client and server

Explanation

HTTPS encrypts the communication channel using TLS, protecting data from eavesdropping and tampering, while HTTP transmits data in plaintext.

27

What is "data partitioning" (sharding) in a database?

A

Correct Answer

Splitting a large dataset across multiple database instances based on some key, to distribute load and storage

Explanation

Sharding divides data across multiple database instances (shards) based on a partition key, allowing a system to scale beyond what a single database server can handle.

28

What is the purpose of a "queue" in a producer-consumer system?

A

Correct Answer

It temporarily holds tasks or messages produced by one part of the system until they are processed by consumers, smoothing out load

Explanation

Queues buffer work between producers and consumers, allowing each to operate at their own pace and absorbing spikes in load without overwhelming downstream systems.

29

What does it mean for an API to be "stateless"?

A

Correct Answer

Each request from a client contains all the information needed to process it, and the server does not store session state between requests

Explanation

Stateless APIs (a core REST principle) treat each request independently, simplifying scaling since any server instance can handle any request without needing shared session state.

30

What is "vertical partitioning" of a database table?

A

Correct Answer

Splitting a table by columns, storing different groups of columns in separate tables or databases

Explanation

Vertical partitioning separates columns (e.g., frequently accessed vs. rarely accessed) into different tables, which can improve performance for queries that only need a subset of columns.

31

What is the purpose of "logging" in a production system?

A

Correct Answer

To record events, errors, and system behavior over time, helping with debugging, monitoring, and auditing

Explanation

Logs provide a historical record of what a system did, which is essential for diagnosing issues, understanding usage patterns, and auditing security events.

32

What is "monitoring" in the context of running systems in production?

A

Correct Answer

Continuously observing system metrics (CPU, memory, error rates, latency) to detect issues and ensure healthy operation

Explanation

Monitoring tools track key metrics and alert teams to anomalies (e.g., high error rates or latency spikes), enabling proactive issue detection before users are significantly impacted.

33

What is an "SLA" (Service Level Agreement)?

A

Correct Answer

A formal commitment between a service provider and a client defining expected service quality, such as uptime guarantees

Explanation

SLAs define measurable targets (like "99.9% uptime") and often consequences for not meeting them, setting expectations between providers and customers.

34

What is the role of an "object storage" service (e.g., Amazon S3) in system design?

A

Correct Answer

To store and retrieve large amounts of unstructured data, such as files, images, and backups, at scale

Explanation

Object storage services provide scalable, durable storage for files and blobs (images, videos, backups), accessed via simple APIs, separate from compute or relational databases.

35

What is the difference between "read-heavy" and "write-heavy" systems, and why does it matter for design?

A

Correct Answer

Read-heavy systems perform far more reads than writes (favoring caching and replicas); write-heavy systems perform far more writes (favoring write optimization and sharding)

Explanation

Understanding read/write ratios guides design choices — read-heavy systems benefit from caching and read replicas, while write-heavy systems may need optimized storage engines, batching, or sharding.

36

What is "polling" as a communication technique between a client and server?

A

Correct Answer

The client repeatedly sends requests to the server at intervals to check for new data or updates

Explanation

Polling involves repeated requests to check for changes, which is simple to implement but can be inefficient compared to push-based mechanisms like WebSockets for real-time updates.

37

What is a "WebSocket" used for?

A

Correct Answer

To establish a persistent, full-duplex communication channel between client and server, enabling real-time data exchange

Explanation

WebSockets keep a connection open, allowing the server to push data to the client (and vice versa) without repeated request/response cycles, ideal for chat apps or live updates.

38

What is the purpose of a "rate of growth" estimation (capacity planning) in system design interviews?

A

Correct Answer

To estimate future traffic, storage, and resource needs so the system can be designed to handle expected scale

Explanation

Capacity estimation (users, requests/sec, storage growth) helps justify design decisions like the need for caching, sharding, or specific database choices.

39

What is the purpose of "load testing" a system before launch?

A

Correct Answer

To simulate high traffic and measure how the system performs under expected or peak load conditions

Explanation

Load testing helps identify bottlenecks and ensures a system can handle anticipated traffic before real users are affected, informing capacity planning decisions.

40

What is the difference between a "session" and a "token" (e.g., JWT) for authentication?

A

Correct Answer

Sessions typically store state on the server and reference it with an ID; tokens like JWTs carry the data themselves and can be verified without server-side storage

Explanation

Session-based auth stores state server-side (e.g., in Redis), while token-based auth (JWT) embeds claims in a signed token the client holds, enabling stateless verification across servers.

1

What is the CAP theorem, and what trade-off does it describe for distributed systems?

A

Correct Answer

A distributed system can provide at most two of Consistency, Availability, and Partition tolerance simultaneously during a network partition

Explanation

During a network partition, a system must choose between staying consistent (rejecting some requests) or remaining available (potentially serving stale data), while always being partition tolerant in distributed systems.

2

What is the difference between "strong consistency" and "eventual consistency"?

A

Correct Answer

Strong consistency guarantees that all reads return the most recent write immediately; eventual consistency allows reads to return stale data temporarily, converging over time

Explanation

Strong consistency requires synchronous coordination (often at a latency cost), while eventually consistent systems prioritize availability/performance and allow temporary divergence between replicas.

3

What is "database sharding" and what is a common challenge it introduces?

A

Correct Answer

Sharding splits data across multiple database instances by a key; a common challenge is performing queries or joins that span multiple shards

Explanation

While sharding enables horizontal scaling of storage and write throughput, cross-shard joins, transactions, and rebalancing data when adding/removing shards become significantly more complex.

4

What is the difference between "read replicas" and "sharding"?

A

Correct Answer

Read replicas are full copies of the same data used to scale reads; sharding splits data into distinct subsets across servers to scale both reads and writes

Explanation

Read replicas duplicate the entire dataset to handle more read traffic, while sharding partitions the dataset itself, allowing the system to scale storage and write capacity beyond a single node.

5

What is a "cache eviction policy", and what does "LRU" stand for?

A

Correct Answer

A cache eviction policy determines which items to remove when the cache is full; LRU (Least Recently Used) evicts the item that hasn't been accessed for the longest time

Explanation

When a cache reaches capacity, an eviction policy like LRU, LFU (Least Frequently Used), or FIFO decides which entries to remove to make room for new data.

6

What is "cache invalidation" and why is it considered a hard problem?

A

Correct Answer

It is the process of removing or updating stale cached data when the underlying source changes, which is hard to do correctly and consistently across distributed caches

Explanation

Keeping caches in sync with the source of truth is notoriously tricky — stale data can be served if invalidation is missed, while overly aggressive invalidation reduces caching benefits.

7

What is the difference between "write-through" and "write-back" (write-behind) caching strategies?

A

Correct Answer

Write-through writes to the cache and the underlying store synchronously; write-back writes to the cache first and updates the underlying store later, asynchronously

Explanation

Write-through ensures consistency at the cost of higher write latency; write-back improves write performance but risks data loss if the cache fails before the data is persisted.

8

What is the purpose of a "message broker" like Kafka or RabbitMQ in a microservices architecture?

A

Correct Answer

To decouple producers and consumers by reliably routing, storing, and delivering messages between services, enabling asynchronous communication

Explanation

Message brokers enable services to communicate without direct, synchronous coupling, improving resilience — if a consumer is down, messages can wait in the broker until it recovers.

9

What is "idempotency" in the context of API design, and why is it important for retries?

A

Correct Answer

An idempotent operation produces the same result no matter how many times it is performed, so retries after network failures don't cause unintended duplicate effects

Explanation

Network failures may cause clients to retry requests; idempotent endpoints (e.g., using a unique request ID or PUT semantics) ensure retries don't create duplicate orders, charges, etc.

10

What is the difference between "horizontal" and "vertical" partitioning, and which generally scales better for very large systems?

A

Correct Answer

Horizontal partitioning (sharding) splits rows across servers and generally scales better for large systems since it distributes both data and load

Explanation

Horizontal partitioning (sharding by row) distributes both storage and query load across many servers, which is typically more effective for scaling very large datasets than vertical (column-based) partitioning alone.

11

What is the purpose of "consistent hashing" in distributed systems?

A

Correct Answer

It minimizes the number of keys that need to be remapped when nodes are added or removed from a distributed cache or database

Explanation

Consistent hashing maps keys and nodes onto a hash ring such that adding/removing a node only affects a small fraction of keys, minimizing reshuffling compared to simple modulo hashing.

12

What is the role of an "API Gateway" in a microservices architecture?

A

Correct Answer

It acts as a single entry point for client requests, routing them to appropriate backend services and often handling cross-cutting concerns like authentication, rate limiting, and logging

Explanation

An API Gateway centralizes common functionality (auth, rate limiting, routing, monitoring) so individual microservices don't each need to implement it, simplifying client interactions.

13

What is "service discovery" and why is it needed in a dynamic microservices environment?

A

Correct Answer

It is a mechanism that allows services to find the network locations of other services dynamically, since instances may scale up/down or change addresses frequently

Explanation

In dynamic environments (containers, auto-scaling), service instances' IPs change frequently; service discovery (e.g., via a registry like Consul or Kubernetes DNS) lets services find each other automatically.

14

What is the "circuit breaker" pattern used for in distributed systems?

A

Correct Answer

To detect repeated failures when calling a dependent service and temporarily stop sending requests to it, preventing cascading failures and allowing recovery

Explanation

Circuit breakers monitor failure rates to a dependency; after exceeding a threshold, they "open" and fail fast for a period, preventing resource exhaustion from waiting on a failing dependency, then periodically test recovery.

15

What is the purpose of "rate limiting" algorithms like the "token bucket" or "leaky bucket"?

A

Correct Answer

They control the rate at which requests are processed or allowed, smoothing bursts and enforcing limits over time

Explanation

Token bucket and leaky bucket algorithms manage request rates by allowing tokens to accumulate up to a limit (token bucket) or processing requests at a fixed rate while queuing excess (leaky bucket).

16

What is the difference between "pessimistic locking" and "optimistic locking" in databases?

A

Correct Answer

Pessimistic locking locks a resource before reading/modifying it to prevent conflicts; optimistic locking allows concurrent access and checks for conflicts (e.g., via a version number) before committing

Explanation

Pessimistic locking avoids conflicts by blocking other transactions but can reduce concurrency; optimistic locking allows higher concurrency by detecting conflicts at commit time (e.g., using a version/timestamp column) and retrying if needed.

17

What is a "leader-follower" (master-slave) replication model in databases?

A

Correct Answer

One node (leader) accepts writes and propagates changes to one or more follower nodes, which typically serve read traffic

Explanation

Leader-follower replication centralizes writes on the leader (simplifying consistency) while followers replicate data and can serve reads, improving read scalability and providing failover candidates.

18

What is "multi-leader" (multi-master) replication, and what challenge does it introduce?

A

Correct Answer

Multiple nodes can accept writes independently, which can lead to write conflicts that must be detected and resolved

Explanation

Allowing writes on multiple nodes (useful for multi-region setups) can lead to concurrent conflicting writes to the same data, requiring conflict resolution strategies like last-write-wins or merging.

19

What is the purpose of "database connection pooling"?

A

Correct Answer

To reuse a limited set of database connections across requests, avoiding the overhead of repeatedly opening and closing connections

Explanation

Opening database connections is relatively expensive; pooling maintains a set of reusable connections, reducing latency and resource usage under high request volume.

20

What is "blue-green deployment"?

A

Correct Answer

A deployment strategy that maintains two identical environments (blue and green), routing traffic to one while deploying updates to the other, then switching over with minimal downtime

Explanation

Blue-green deployments reduce risk by keeping the old version (blue) running while the new version (green) is deployed and tested, then switching traffic, with the option to roll back quickly.

21

What is a "canary release"?

A

Correct Answer

A deployment strategy where a new version is rolled out to a small subset of users or servers first, to detect issues before a full rollout

Explanation

Canary releases limit exposure to a new version, allowing teams to monitor for problems on a small scale before gradually increasing traffic, minimizing the impact of potential issues.

22

What is the role of a "bloom filter" in system design, and what is its key limitation?

A

Correct Answer

A bloom filter is a space-efficient probabilistic structure that quickly tests whether an element might be in a set, but it can produce false positives (never false negatives)

Explanation

Bloom filters use a bit array and hash functions to compactly represent set membership; they can say "definitely not present" with certainty, or "possibly present" (which could be a false positive), useful for quickly avoiding unnecessary lookups.

23

What is the purpose of "database denormalization" in high-read systems, and what trade-off does it introduce?

A

Correct Answer

Denormalization duplicates data to reduce expensive joins and speed up reads, at the cost of increased storage and more complex updates to keep duplicated data consistent

Explanation

By storing redundant copies of related data together, denormalization avoids costly joins for reads, but requires extra care to keep all copies in sync during writes.

24

What is "horizontal scaling" of stateless services typically paired with, to distribute incoming requests?

A

Correct Answer

A load balancer that distributes requests across the available service instances

Explanation

Stateless services can be replicated easily; a load balancer distributes incoming traffic across these replicas, enabling horizontal scaling to handle increased load.

25

What is "event-driven architecture"?

A

Correct Answer

An architecture where components communicate by producing and consuming events, often via a message broker, enabling loose coupling and asynchronous processing

Explanation

In event-driven systems, services react to events (e.g., "OrderPlaced") published to a broker, allowing independent services to process them asynchronously without tight coupling.

26

What is the purpose of "database normalization" versus "denormalization" trade-off in system design?

A

Correct Answer

Normalization reduces redundancy and improves write consistency at the cost of more complex reads (joins); denormalization improves read performance at the cost of redundancy and write complexity

Explanation

Choosing between normalization and denormalization depends on the read/write profile of the application — OLTP systems often favor normalization, while read-heavy analytical systems may favor denormalization.

27

What is the difference between "vertical" and "horizontal" autoscaling in cloud environments?

A

Correct Answer

Vertical autoscaling resizes an existing instance's resources (CPU/memory); horizontal autoscaling adds or removes instances based on demand

Explanation

Horizontal autoscaling (adding/removing instances) is generally preferred for stateless services due to easier load distribution, while vertical autoscaling resizes a single instance, often requiring a restart.

28

What is a "thundering herd" problem, and how can it be mitigated?

A

Correct Answer

A scenario where many clients simultaneously request the same resource (e.g., after a cache expires), overwhelming the backend; mitigations include staggered expiration, locks, or request coalescing

Explanation

When a popular cached item expires, many simultaneous requests can hit the database at once; techniques like jittered expiration times or "locking" the regeneration to one request help avoid overload.

29

What is the purpose of "database transactions" with ACID properties?

A

Correct Answer

To ensure a group of operations either all succeed (commit) or all fail (rollback) together, while maintaining Atomicity, Consistency, Isolation, and Durability

Explanation

ACID transactions provide strong guarantees: all-or-nothing execution (Atomicity), valid state transitions (Consistency), no interference between concurrent transactions (Isolation), and persistence after commit (Durability).

30

What is the difference between "horizontal sharding by range" and "sharding by hash"?

A

Correct Answer

Range sharding assigns contiguous ranges of a key to each shard (good for range queries but risks uneven load); hash sharding distributes keys more evenly via a hash function but makes range queries harder

Explanation

Range-based sharding preserves ordering and supports efficient range scans but can cause "hot spots" if data isn't evenly distributed; hash-based sharding distributes load more evenly but scatters related/ordered data across shards.

31

What is the purpose of a "dead letter queue" (DLQ) in a messaging system?

A

Correct Answer

To store messages that could not be processed successfully after repeated attempts, so they can be inspected or retried separately without blocking the main queue

Explanation

DLQs isolate problematic messages (e.g., due to malformed data or persistent errors) so the main processing pipeline isn't blocked, while allowing engineers to investigate failures separately.

32

What is "graceful degradation" in system design?

A

Correct Answer

Designing a system to maintain partial functionality during failures or high load, rather than failing completely

Explanation

For example, if a recommendation service is down, a site might still show products without personalized recommendations rather than failing the whole page — preserving core functionality.

33

What is the difference between "push" and "pull" models for delivering updates (e.g., notifications)?

A

Correct Answer

In a push model, the server proactively sends updates to clients as they happen; in a pull model, clients periodically request updates from the server

Explanation

Push models (e.g., WebSockets, push notifications) reduce latency for real-time updates but require maintaining connections or delivery infrastructure; pull models (polling) are simpler but less timely and can waste resources on unnecessary checks.

34

What is the purpose of "feature flags" (feature toggles) in system design and deployment?

A

Correct Answer

To enable or disable features at runtime without deploying new code, supporting gradual rollouts, A/B testing, and quick rollback of problematic features

Explanation

Feature flags decouple deployment from release, letting teams enable features for specific users/percentages or quickly disable a problematic feature without rolling back code.

35

What is a "hot partition" (hot key) problem in a sharded or partitioned system?

A

Correct Answer

A situation where one partition or key receives a disproportionately large share of traffic, becoming a bottleneck while other partitions are underutilized

Explanation

Uneven access patterns (e.g., a celebrity user's data, or a popular product) can overload a single shard; mitigations include better key design, splitting hot keys, or adding caching layers.

36

What is the purpose of "data sharding by tenant" in a multi-tenant SaaS application?

A

Correct Answer

Isolating each customer's (tenant's) data into separate shards or schemas, improving data isolation, scalability, and the ability to migrate or scale individual tenants

Explanation

Sharding by tenant provides strong data isolation and lets large tenants be moved to dedicated infrastructure, though it can complicate cross-tenant queries and analytics.

37

What is the difference between "synchronous replication" and "asynchronous replication" for databases?

A

Correct Answer

Synchronous replication waits for replicas to acknowledge a write before confirming it to the client, ensuring stronger consistency at the cost of latency; asynchronous replication confirms writes before replicas catch up, risking data loss on failover

Explanation

Synchronous replication trades latency for durability guarantees, while asynchronous replication improves write latency but can lose recently committed data if the primary fails before replicas catch up.

38

Why might a system use "pagination" or "cursor-based pagination" for large result sets, and what advantage does cursor-based pagination have over offset-based?

A

Correct Answer

Pagination avoids returning huge datasets at once; cursor-based pagination uses a reference point (like a last-seen ID) avoiding the performance degradation and consistency issues that offset-based pagination has on large, changing datasets

Explanation

Offset-based pagination (LIMIT/OFFSET) becomes slow on large offsets and can show duplicates/gaps if data changes between pages; cursor-based pagination uses a stable reference point for consistent, efficient paging.

39

What is the purpose of "request tracing" (distributed tracing) in a microservices system?

A

Correct Answer

To track a single request as it flows across multiple services, helping identify latency bottlenecks and failures in complex distributed call chains

Explanation

Tools like Jaeger or Zipkin propagate a trace ID across service calls, allowing engineers to visualize the full path and timing of a request through a distributed system to pinpoint where issues occur.

40

What is the trade-off of using a "single shared database" versus "database per service" in a microservices architecture?

A

Correct Answer

A shared database simplifies cross-service queries and transactions but couples services together and can become a bottleneck; database per service improves independence and scalability but complicates cross-service data consistency and queries

Explanation

Database-per-service aligns with microservice independence and bounded contexts but requires patterns like sagas or eventual consistency for cross-service operations that a shared database would handle with simple transactions.

1

When designing a globally distributed system requiring strong consistency for certain operations, what is a common architectural approach?

A

Correct Answer

Use consensus protocols (e.g., Raft or Paxos) to coordinate a quorum of replicas, often accepting higher write latency for operations requiring strong consistency, while allowing eventual consistency elsewhere

Explanation

Consensus algorithms like Raft/Paxos allow a majority of nodes to agree on operations despite failures, providing strong consistency guarantees at the cost of latency from cross-node coordination — often applied selectively to critical data.

2

In designing a URL shortener (like bit.ly) at scale, what is a key consideration for generating unique short codes across distributed servers?

A

Correct Answer

Using techniques like pre-generated unique ID ranges per server, distributed ID generators (e.g., Snowflake-style IDs), or base62 encoding of a globally unique counter to avoid collisions without a central bottleneck

Explanation

Distributed ID generation schemes (e.g., assigning ID ranges to each server, or time-based IDs like Snowflake) avoid collisions and central bottlenecks that a single shared counter or naive random generation would create at scale.

3

When designing a news feed system (like Twitter/Facebook) for users with millions of followers, what is the trade-off between "fan-out on write" and "fan-out on read"?

A

Correct Answer

Fan-out on write pre-computes and stores feeds for each follower at post time (fast reads, expensive writes for popular accounts); fan-out on read computes the feed at request time by querying followed users' posts (cheaper writes, slower reads)

Explanation

Systems often use a hybrid: fan-out on write for most users (fast feed reads), but fan-out on read for celebrities with huge follower counts, avoiding massive write amplification when they post.

4

In a distributed system using the Raft consensus algorithm, what happens if the current leader becomes unreachable?

A

Correct Answer

Followers that stop receiving heartbeats from the leader will time out and initiate a new leader election, with a candidate becoming the new leader if it receives votes from a majority

Explanation

Raft uses randomized election timeouts; when followers stop hearing from the leader, one becomes a candidate, requests votes, and becomes leader if it secures a majority, ensuring the cluster can continue operating.

5

When designing a rate limiter for a distributed API gateway with multiple instances, why is a centralized store like Redis often used instead of in-memory counters on each instance?

A

Correct Answer

In-memory counters on each instance would only track requests handled by that instance, allowing a client to exceed the global limit by spreading requests across instances; a shared store provides a consistent global count

Explanation

A shared, fast data store (like Redis) lets all gateway instances check and increment a common counter, ensuring rate limits are enforced globally rather than per-instance, though it introduces a dependency and potential latency/contention point.

6

What is "write amplification" in the context of LSM-tree-based storage engines (e.g., used in Cassandra, RocksDB)?

A

Correct Answer

A single logical write can result in multiple physical writes over time due to compaction processes that rewrite data across levels to maintain read efficiency

Explanation

LSM-trees write data sequentially to immutable files (SSTables) and periodically compact/merge them; this background compaction causes data to be rewritten multiple times, increasing total disk I/O relative to the logical data written.

7

In designing a globally distributed key-value store, what does "quorum-based" reads and writes (e.g., R + W > N) achieve?

A

Correct Answer

By requiring a minimum number of replicas to acknowledge a read (R) or write (W) out of N total replicas, the system can balance consistency, availability, and latency, ensuring overlapping read/write sets help maintain consistency

Explanation

Systems like Dynamo-style databases use tunable quorum parameters (N, R, W) to trade off consistency and availability — e.g., R + W > N ensures read and write quorums overlap, increasing the likelihood reads see the latest write.

8

When designing a notification system that must guarantee "at-least-once" delivery, what complexity does this push onto downstream consumers?

A

Correct Answer

Consumers must be idempotent or implement deduplication logic, since the same notification may be delivered more than once due to retries

Explanation

At-least-once delivery prioritizes not losing messages, accepting the possibility of duplicates during retries; consumers must therefore handle duplicates gracefully, e.g., via idempotency keys.

9

In a large-scale search system, what is the purpose of an "inverted index", and why is it central to search performance?

A

Correct Answer

An inverted index maps terms/words to the documents (and positions) where they appear, allowing fast lookups of which documents contain a given term instead of scanning every document

Explanation

Search engines build inverted indexes so that a query for a term can directly retrieve the list of matching documents (postings list), avoiding a full scan of all documents — foundational to systems like Elasticsearch.

10

What design challenge does "clock skew" introduce in distributed systems, and how do logical clocks (e.g., Lamport timestamps) help?

A

Correct Answer

Physical clocks on different machines can drift, making it unreliable to order events by wall-clock time alone; logical clocks provide a way to establish a consistent partial ordering of events based on causality rather than physical time

Explanation

Because physical clocks can drift between nodes, relying on timestamps for ordering events can produce incorrect results; logical clocks (Lamport, vector clocks) capture causal relationships ("happened-before") independent of physical time.

11

When designing a system for processing financial transactions that must never lose data, what role does a "write-ahead log" (WAL) play?

A

Correct Answer

Changes are first recorded in a durable, sequential log before being applied to the main data structures, allowing recovery to a consistent state after a crash by replaying the log

Explanation

WALs provide durability and crash recovery by ensuring that any change is durably recorded before being considered committed, so the system can replay the log to recover state after a failure.

12

In designing a chat application supporting millions of concurrent users, why might "sticky sessions" with WebSocket connections create challenges for horizontal scaling?

A

Correct Answer

Because a client keeps a persistent connection to one server instance, scaling must route messages to the instance holding that connection, often via a message broker or presence service

Explanation

Since WebSocket connections are stateful and tied to a specific server, delivering a message to a user requires knowing which instance holds their connection — often solved with a pub/sub layer (e.g., Redis Pub/Sub) so any instance can publish to the right one.

13

What is the significance of "idempotency keys" when designing a payment processing API?

A

Correct Answer

A client-generated unique key included with a request allows the server to detect and safely ignore duplicate requests (e.g., from network retries), preventing duplicate charges

Explanation

If a client retries a payment request after a timeout (not knowing if it succeeded), including the same idempotency key lets the server recognize the retry and return the original result instead of processing the payment again.

14

When designing a globally distributed file storage system (like Google Drive or Dropbox), what is a key challenge in handling concurrent edits to the same file from multiple devices?

A

Correct Answer

The system needs conflict detection and resolution strategies (e.g., versioning, operational transforms, or CRDTs) since simultaneous edits from different devices may conflict and need merging

Explanation

Offline edits and concurrent changes from multiple devices require strategies like versioning, last-write-wins with conflict copies, or more sophisticated approaches like Conflict-free Replicated Data Types (CRDTs) for real-time collaborative editing.

15

What is the purpose of "backpressure" mechanisms in a streaming data pipeline, and what can happen if they are absent?

A

Correct Answer

Backpressure signals upstream producers to slow down when downstream consumers can't keep up; without it, queues can grow unbounded, leading to memory exhaustion or dropped data

Explanation

Backpressure mechanisms (bounded queues, flow control protocols) prevent fast producers from overwhelming slower consumers; without them, unbounded buffering can crash systems or force data loss when buffers overflow.

16

In a microservices architecture, what is the "saga pattern" used for, and how does it differ from a traditional distributed transaction?

A

Correct Answer

A saga coordinates a sequence of local transactions across services, using compensating transactions to undo prior steps if a later step fails, rather than relying on a single atomic distributed transaction (e.g., two-phase commit)

Explanation

Distributed transactions (2PC) are often impractical at scale due to blocking and coordinator failure risks; sagas instead break a business process into a series of local transactions with compensating actions to maintain eventual consistency if something fails partway through.

17

When scaling a relational database vertically reaches its limits, and sharding introduces too much complexity for a team, what is a common intermediate strategy?

A

Correct Answer

Introducing read replicas for read-heavy workloads, caching frequently accessed data, and optimizing queries/indexes before resorting to full sharding

Explanation

Before the operational complexity of sharding, teams often exhaust simpler scaling levers: read replicas for read scaling, caching layers (Redis/Memcached) to reduce database load, and query/index optimization.

18

What is the role of "vector clocks" in detecting conflicting concurrent updates in a distributed system?

A

Correct Answer

Each node maintains a vector of counters representing its view of update counts across all nodes, allowing the system to determine whether two versions of data are causally related or concurrent (conflicting)

Explanation

By comparing vector clock values attached to different versions of data, a system can determine if one version causally descends from another (no conflict) or if they were updated independently (concurrent, requiring conflict resolution).

19

When designing a system to handle "hot spots" in a sharded database where one shard receives disproportionate traffic, what is an effective mitigation beyond simply re-sharding?

A

Correct Answer

Adding a caching layer in front of the hot shard, or splitting the hot key's data further (e.g., by appending a sub-key/salt) to spread its load across multiple shards

Explanation

In addition to rebalancing shards, caching absorbs read load for hot keys, and techniques like key salting can split a single hot key's writes across multiple underlying partitions, reducing pressure on any one shard.

20

In a system using event sourcing, what is the trade-off of storing every state change as an immutable event rather than just the current state?

A

Correct Answer

Event sourcing provides a complete audit trail and the ability to reconstruct past states or replay events, but requires additional complexity for querying current state efficiently (often via snapshots or read models/CQRS)

Explanation

Event sourcing offers strong auditability and time-travel capabilities, but reconstructing current state from a long event log can be slow, so systems often combine it with periodic snapshots and separate read-optimized views (CQRS).