Distributed Systems Reliability And Concurrency
Asked of: Software Engineer
Last updated

What's being tested
These problems test whether you can turn vague reliability requirements into explicit invariants, failure semantics, and concurrency-safe interfaces. You must reason about durable state, retries, leases, idempotency, ordering, backpressure, and what happens when processes crash at the worst possible moment. Bloomberg cares because software supporting market data, analytics, and internal workflows must remain correct under high concurrency and partial failure—not merely appear available. The interviewer is probing whether you can explain tradeoffs precisely and build a design whose behavior is observable and testable.
Core knowledge
-
At-least-once delivery is the practical default when acknowledgments can be lost; make handlers idempotent with request IDs, deduplication records, or conditional writes. “Exactly once” usually means exactly-once effects, not exactly-once network delivery.
-
Model each resource with a state machine rather than scattered booleans:
PENDING → CLAIMED → RUNNING → SUCCEEDED, with explicitFAILED,EXPIRED, and retry transitions. Define legal transitions and the actor permitted to perform each one. -
A lease is time-bounded ownership: a worker claims work until
lease_expiry; it must renew periodically. Every completion must verify a fencing token or lease version so a delayed old worker cannot overwrite a newer owner’s result. -
Idempotency keys prevent duplicate effects across client retries. Store the key with the operation result atomically; distinguish “same key, same payload” from “same key, conflicting payload,” and return the original result for the former.
-
Use compare-and-swap or transactional conditional updates for claims:
UPDATE jobs SET owner=?, version=version+1 WHERE id=? AND state='READY'. Check the affected-row count; a read-then-write sequence is unsafe under races. -
Fair scheduling needs a declared policy. Weighted round-robin is simple for fixed classes; Deficit Round Robin handles variable job sizes using credits. With unknown runtimes, use observed runtime estimates, aging, or bounded execution quanta to reduce starvation.
-
Separate durability from visibility. A job acknowledged after an in-memory enqueue can disappear on process failure; persist the job before acknowledging, and define whether “accepted,” “started,” and “completed” each have durable evidence.
-
Retries require classification: retry transient timeouts, lease loss, or overloaded dependencies; avoid retrying deterministic validation errors. Use exponential backoff with jitter, a maximum attempt count, and a dead-letter or manual-repair path.
-
For concurrent in-memory structures, choose ownership deliberately: a single event loop can avoid locks but may bottleneck; sharded locks scale across independent keys; lock-free structures improve throughput only when their memory-ordering and reclamation costs are justified.
-
Backpressure protects the system when arrival rate exceeds service rate. Bound queues, reject or defer work explicitly, and expose queue depth and age. Unbounded buffering converts overload into latency growth or an eventual out-of-memory crash.
-
End-to-end integrity requires a cryptographic checksum such as
SHA-256computed from the bytes at ingestion and verified after retrieval. Replication protects availability, but only independent verification, scrubbing, and repair detect silent corruption. -
For packet or stream reassembly, maintain per-message state keyed by an identifier, validate offsets and lengths, reject overlaps unless the protocol defines them, and enforce memory/time limits. Completion requires all expected ranges, not merely receiving the final fragment.
Worked example: Design a Fair Distributed Job Scheduler with Unknown Runtimes
A strong candidate first clarifies job volume, priority classes, maximum acceptable queue age, persistence requirements, whether jobs may run more than once, and what “fair” means—equal job count, weighted share, or bounded waiting time. They might assume modest scale, durable metadata in Postgres, a dispatcher, and stateless workers communicating through a durable queue. The answer can be organized around four pillars: durable job state and idempotent submission, fair dispatch, lease-based worker ownership, and retry/recovery observability. They should describe a claim transaction that atomically selects eligible work, increments a fencing version, and records the lease owner. A worker heartbeat extends the lease, while completion succeeds only if its version still matches, preventing a paused worker from completing after reassignment. The explicit tradeoff is between strict fairness and throughput: weighted or deficit scheduling improves fairness, but tracking runtime estimates and per-tenant credits adds state and dispatcher complexity. Unknown runtimes also make FIFO unfair, so the candidate should discuss aging, time quanta, or runtime caps for jobs that monopolize workers. They can close by saying, “If I had more time, I’d specify the schema, failure-injection tests, queue-age dashboards, and recovery behavior when the metadata store is unavailable.”
A second angle
In Design an in-memory trade subscription processor, the durable lease problem becomes a low-latency ownership and ordering problem. The candidate should clarify whether subscriptions are keyed by instrument, whether callbacks may block, and whether updates must preserve per-instrument order. Sharding instruments across worker threads can eliminate global locking, while copy-on-write subscriber lists make reads cheap but make subscription churn more expensive. The key tradeoff is lock granularity: a global lock simplifies correctness but harms throughput, whereas per-shard or per-key locks require careful ordering and lifecycle management. The answer should also define behavior for a callback failure—usually isolate it, record the error, and avoid blocking unrelated subscribers.
Common pitfalls
Pitfall: Analytical mistake. Saying “use a distributed lock” without defining lock expiry, renewal, fencing, and crash behavior is incomplete; a delayed process can still act after its lock appears to have expired. Explain the state transition and the conditional write that makes stale ownership harmless.
Pitfall: Communication mistake. Jumping directly into
Kafka,Redis, orPostgresbefore stating scale, consistency, and failure assumptions makes the design sound arbitrary. Start with requirements, name the invariant, then introduce each component as a consequence of that requirement.
Pitfall: Depth mistake. Claiming “exactly once” or “the checksum guarantees durability” confuses different properties. Separate delivery semantics, effect idempotency, availability through redundancy, and corruption detection; identify what remains possible during crashes and partitions.
Connections
The interviewer may pivot to CAP tradeoffs, linearizability, transaction isolation, consistent hashing, backpressure, or observability through queue age, retry rate, lease expiry, and p99 latency. Be ready to connect the design to failure-injection testing and Jepsen-style reasoning about histories.
Further reading
- Designing Data-Intensive Applications —
Martin Kleppmann’s practical treatment of replication, transactions, stream processing, and failure semantics. - Time, Clocks, and the Ordering of Events in a Distributed System —
Leslie Lamport’s foundational discussion of ordering and causality. - The Tail at Scale — explains why rare slow components dominate distributed request latency and motivates hedging, isolation, and deadlines.
Practice questions
- Thread-Safe Shared Counter with Compare-and-SetBloomberg · Software Engineer · Other · easy
- Design a File Archive System With End-to-End Data Integrity GuaranteesBloomberg · Software Engineer · Technical Screen · medium
- Design a Fair Distributed Job Scheduler with Unknown RuntimesBloomberg · Software Engineer · Technical Screen · medium
- Design in-memory trade subscription processorBloomberg · Software Engineer · Onsite · medium
- Design a packet reassembler APIBloomberg · Software Engineer · Technical Screen · medium
- Design auth, session security, and top-N usersBloomberg · Software Engineer · Onsite · hard
- Explain Kafka partitions and delivery semanticsBloomberg · Software Engineer · Technical Screen · hard
Related concepts
- Distributed Systems Reliability And StorageSystem Design
- Distributed Systems Consistency And Low-Latency DesignSystem Design
- Reliable Distributed Systems And IdempotencySystem Design
- Distributed Systems Correctness And IdempotencySystem Design
- Distributed Systems Reliability For Rippling Services
- Distributed Systems Consistency, Reliability, And ObservabilitySystem Design