🌐 Distributed Systems — interview questions

12 questions. Filter by what the role asks for; open one for the six layers of the answer. The course is where the answers come from.

12 of 12

01A teammate says "let's just make the payment queue exactly-once so we don't need to worry about duplicate charges." What's wrong with that plan, and what do you build instead?Idempotencyeasy0-2y02A retry-backoff implementation computes the delay as `Instant.now().minus(startedAt)`. What can go wrong with that specifically, and what should it use instead?Clockseasy0-2y03A leader holds a lease, checks it (valid), then pauses for eight seconds in a stop-the-world GC, resumes, and writes. During the pause, the lease expired and a new leader was elected and also wrote. Both writes land. Whose fault is this, and what actually fixes it?Leader electionmedium3-5y04You need to merge log lines from three services into one consistent, replayable sequence, and someone proposes attaching a Lamport clock to every event and sorting by it. Does that give you what you need, and what does the resulting order actually guarantee?Clocksmedium3-5y05A client calls `POST /transfer` with no idempotency key. The call times out after four seconds with no response. Should the client retry automatically, and what would actually make automatic retry safe?Failure modesmedium3-5y06A service replaces `Executors.newFixedThreadPool(20)` — which was silently queueing unboundedly in front of the pool — with a `ThreadPoolExecutor` backed by an `ArrayBlockingQueue` of 200. What's the actual difference between having the queue block the caller versus reject when full, and which do you pick for an HTTP request handler?Backpressuremedium3-5y07Two nodes have identical 2,200ms silences: node A's heartbeats normally arrive every 1,000ms ± 20ms, node B's arrive every 1,000ms ± 400ms. A fixed 2-second timeout has already fired identically for both. Explain exactly what a phi-accrual failure detector computes differently for them, and why treating them the same would be the actual bug.Failure detectionhard5-8y08Design isolation for a service that calls three downstream dependencies, one of which (a third-party pricing API) is known to be flaky. Compare a dedicated thread-pool bulkhead per dependency against a semaphore bulkhead on a shared pool, and say which actually contains a slow — not just failing — pricing API.Resiliencehard5-8y09A team migrates a blocking REST client to Spring WebFlux's reactive `WebClient` to "get backpressure for free." Is that a safe assumption, and where does the Reactive Streams protocol's `request(n)` actually prevent overload that a bounded buffer inside the same pipeline would not?Backpressurehard5-8y10Two replicas of a shopping cart both accept a write to the same cart while partitioned from each other — one adds an item, the other removes a different item — and the partition heals. Walk through what a vector clock comparison of the two resulting versions actually returns, and why that outcome is correct rather than a bug.Clockshard5-8y11Design a distributed lock for a 5-node cluster where the lock protects writes to a shared storage service. A partition splits the cluster 2-3. Walk through, in order of strength, every defence that prevents both sides from believing they hold the lock and both actually writing.Leader electionsenior8+y12A cache node restarts. Every request now misses, hits the database, the database slows under the new load, requests time out, clients retry, and the cache can never refill because the database is too slow to answer the fills either. An hour later, restarting the cache node again doesn't help — the system stays overloaded at a load level it handled fine yesterday. What's actually going on, and why doesn't removing the original trigger fix it?Resiliencesenior8+y