Hot-Reload Server Config With Copy-on-Write Snapshots and Lock-Free Reads
Last updated: November 29, 2026
Quick Overview
A frontend server reads configuration on every request and must pick up new config pushed at runtime. Design it so request threads never take a lock and never observe a half-applied update, while reloads are validated and serialized.
0
0
0 solved
A frontend server reads configuration on every request and must pick up new config pushed at runtime. Design it so request threads never take a lock and never observe a half-applied update, while reloads are validated and serialized.
Google servers receive flag and config pushes while serving heavy traffic, so per-request locking on config is unacceptable. The interviewer checks whether the candidate reaches for immutable snapshots plus an atomic reference swap, understands torn reads, and validates before publishing.
What the Interviewer Expects
- Identifies torn reads when a shared mutable dict is updated in place
- Publishes an immutable snapshot through a single reference assignment
- Keeps readers lock-free and serializes writers with one lock
- Validates new config before swapping so a bad push cannot take effect
- Notes that a request should capture one snapshot and use it throughout
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How do you know when old snapshots can be freed in a language without GC (RCU grace periods)?
- How would you roll out config to a fraction of servers first?
- How do you let components subscribe to changes of specific keys?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
snapshot()is called per request and must be cheap and lock-free.- A reader sees either the entire old config or the entire new one, never a mix.
reloadandpatchmay race with each other; ...
High-Level Design
If the server mutates one dict in place, a request can read a from the new config and b from the old one, a torn read. Instead, each config version is an immutable mapping. Writers build a fresh d...