Distributed System Design, Scalability, And Reliability
Asked of: Software Engineer
Last updated

What's being tested
These designs test whether you can decompose a distributed product into clear services, APIs, data models, and failure boundaries while reasoning about scale, latency, consistency, and recovery. The interviewer is probing for practical use of replication, partitioning, caching, queues, idempotency, conflict resolution, and backpressure—not a list of fashionable technologies. General cares because customer-facing insurance and financial workflows must remain available during traffic spikes while preserving correctness, auditability, and safe degradation.
Core knowledge
-
Requirements framing separates functional requirements from non-functional targets: define operations, read/write ratios, expected concurrency, durability, availability, latency percentiles, retention, and failure assumptions before choosing components. Ask whether stale reads, dropped events, or temporary unavailability are acceptable.
-
Capacity planning converts users into load: , then size for peak and headroom. Estimate bandwidth as streams or records per second times payload size; calculate storage from retention, replication factor, and growth.
-
Partitioning distributes load by a stable key such as
user_id,document_id, or stream ID. Hash partitioning balances traffic, while range partitioning supports ordered scans; both can create hot keys, so use logical shards, adaptive splitting, or salted keys where necessary. -
Replication improves availability and read throughput but introduces lag and failover complexity. A leader–follower database simplifies writes and ordering; multi-leader or leaderless designs improve write locality but require conflict resolution and careful quorum reasoning.
-
Consistency must match the operation. Strong consistency is appropriate for wallet balances and committed document versions; eventual consistency is often acceptable for viewer counts, presence, or cache reads. State the invariant explicitly—for example, debits must never make an account balance incorrect.
-
Idempotency makes retries safe when clients or queues resend requests. Accept an idempotency key, persist the key with the resulting status and response, and enforce a uniqueness constraint in the same transaction as the side effect; never rely only on an in-memory deduplication set.
-
Ordering and delivery require explicit guarantees.
Kafka-style partitions preserve order only within a partition, while at-least-once delivery means consumers must tolerate duplicates. Use sequence numbers, transactional state updates, or an inbox/outbox pattern rather than claiming global exactly-once behavior casually. -
Caching reduces database load but creates staleness and invalidation problems. A distributed cache such as
Rediscan use consistent hashing, replication, TTLs, LRU eviction, request coalescing, and stale-while-revalidate; protect against cache stampedes with jittered TTLs and per-key locking. -
Real-time synchronization needs a connection layer, usually WebSockets or server-sent events, plus durable state behind it. Presence is ephemeral and can use heartbeats with expiry; document edits need operation IDs, version numbers, and either Operational Transformation or CRDTs for concurrent updates.
-
Backpressure prevents overload from cascading across services. Bound queues, limit concurrency, reject or shed low-priority work, apply exponential backoff with jitter, and expose queue age; an unbounded queue merely converts immediate failure into delayed failure and memory exhaustion.
-
Failure handling should cover timeouts, retries, circuit breakers, health checks, leader loss, partial network partitions, and regional outages. Retries must be bounded and used only for retryable errors; otherwise synchronized clients can create a retry storm that worsens the incident.
-
Durability and recovery require write-ahead logging, snapshots, backups, and tested restore procedures. Define
RPO(maximum acceptable data loss) andRTO(maximum recovery time), then verify them with failover drills rather than treating replication as a backup. -
Observability connects behavior to cause through metrics, structured logs, and distributed traces. Track
p50,p95, andp99latency, error rate, saturation, replication lag, queue depth, cache hit rate, and dropped or duplicated events; alerts should reflect user-visible symptoms and important invariants.
Worked example: Design a Digital Wallet (Venmo, Cash App)
A strong opening would clarify whether the wallet supports peer transfers only or also bank rails, the expected transaction volume, settlement latency, currencies, fraud-review states, and the required balance correctness and availability targets. I would declare that financial correctness and auditability take priority over accepting writes during an unavailable dependency, and organize the design around APIs, a double-entry ledger, transfer orchestration, and reconciliation. The ledger would be append-only, with immutable debit and credit entries whose sum explains every balance change; a materialized balance can accelerate reads but must be rebuilt from the ledger. Each transfer would carry an idempotency key and move through an explicit state machine such as pending, posted, failed, or reversed. A database transaction would enforce uniqueness and atomically create the transfer record plus ledger entries, while an outbox would publish downstream notifications reliably. I would call out the tradeoff between a single strongly consistent ledger database and a horizontally partitioned ledger: partitioning scales further but makes cross-account transfers and atomic invariants substantially harder. External bank calls would be asynchronous, retryable, and reconciled against provider statements rather than assumed successful after a timeout. If I had more time, I would detail authorization, fraud holds, multi-region failover, backup restoration, and operational repair tools.
A second angle: Design a Collaborative Document Editor
The same decomposition applies to a collaborative editor, but the central constraint shifts from financial invariants to low-latency convergence under concurrent writes. I would separate durable document operations and snapshots from the WebSocket fanout and ephemeral presence service. Every edit needs a client or server operation ID, an ordering/version model, and a reconnect protocol so offline clients can replay safely. The key choice is Operational Transformation versus CRDTs: transformation can be efficient with a central sequencing service, while CRDTs simplify decentralized/offline merging at the cost of metadata and implementation complexity. I would also define snapshot compaction and bounded history so replay time does not grow without limit.
Common pitfalls
Pitfall: Saying “use eventual consistency everywhere” ignores correctness boundaries. A stronger answer classifies state explicitly: wallet postings and committed document versions require strict coordination, while viewer counts, presence, and cache values can tolerate staleness.
Pitfall: Jumping directly to
Kafka,Redis, or microservices without first stating traffic, latency, and failure assumptions makes the design sound arbitrary. Explain which bottleneck or guarantee each component addresses, and name what happens when it is unavailable.
Pitfall: Claiming “exactly-once delivery” or “no data loss” without defining scope is a depth mistake. Describe the actual mechanism—idempotent consumers, transactional outbox, durable acknowledgments, backups—and state the remaining failure window or operational limitation.
Connections
An interviewer may pivot to CAP tradeoffs, quorum reads and writes, and multi-region consistency, or to API versioning, schema evolution, and zero-downtime migrations. They may also probe load testing, chaos testing, incident response, and security controls such as authentication, authorization, encryption, and audit logs.
Further reading
- Designing Data-Intensive Applications — Martin Kleppmann’s practical treatment of replication, partitioning, transactions, streams, and consistency.
- Amazon Dynamo — seminal paper on highly available key-value storage, quorum techniques, and eventual consistency.
- Stripe: Designing robust and predictable APIs with idempotency — concrete treatment of safe retries for payment-like operations.
Practice questions
- Design a messaging app like WhatsApp: 1-1 chats, groups of up to 150, media and presenceGeneral · Software Engineer · Other · medium
- Design an extensible notification system for email, SMS, iOS and Android pushGeneral · Software Engineer · Other · medium
- Design a Yelp-style proximity service with nearby search and reviewsGeneral · Software Engineer · Other · medium
- Design a Social Media Platform Like Instagram: Uploads, Feeds and Hashtag SearchGeneral · Software Engineer · Other · medium
- Design a Stock Exchange (NASDAQ, NYSE)General · Software Engineer · Other · hard
- Design a Digital Wallet (Venmo, Cash App)General · Software Engineer · Other · hard
- Design a distributed in-memory key-value cacheGeneral · Software Engineer · Other · hard
- Design a payment gateway like Stripe with refunds and merchant webhooksGeneral · Software Engineer · Other · hard
- Choose Between a Monolith, Microservices, and a Modular ArchitectureGeneralmotors · Software Engineer · Technical Screen · medium
- 4.2 Design a Collaborative Document EditorGeneral · Software Engineer · Onsite · medium
- 4.1 Design a Live Streaming PlatformGeneral · Software Engineer · Onsite · medium
Related concepts
- Distributed Systems Reliability And StorageSystem Design
- Distributed Systems Design At ScaleSystem Design
- Scalable Distributed System ArchitectureSystem Design
- Scalable Service And Distributed System DesignSystem Design
- Distributed Storage, Caching And ConsistencySystem Design
- Distributed Systems Reliability And ConcurrencySystem Design