Redis hard
How does the Redis background snapshotting process (`BGSAVE`) leverage the operating system's `fork()` mechanism to minimize memory overhead?
- A It copies all RAM pages immediately to a secondary buffer, using system swap to handle the resulting memory overflow.
- B It uses Copy-on-Write (CoW); parent and child share physical pages until a write triggers a page-level duplication.
- C It pauses all incoming command execution to allow the kernel to perform a synchronous bit-for-bit memory clone.
- D It compresses the parent's memory pages in place before the child process starts reading them to reduce the I/O footprint.
Answer: B. It uses Copy-on-Write (CoW); parent and child share physical pages until a write triggers a page-level duplication.
Forking is instant because of CoW. In a read-heavy app, the memory 'duplication' is negligible. In a write-heavy app, more pages are modified, leading to higher RAM usage during the snapshot as the OS must copy the modified pages.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- If the Redis memory limit is reached, what specific behavior is exhibited by the `allkeys-lru` eviction policy?
- What is the defining characteristic of a Redis 'Set' data type compared to a standard Redis 'List'?
- In the context of Redis messaging, what is the functional definition of the 'Pub/Sub' feature?
- Why does Redis proactively disconnect a Pub/Sub client that exhibits high 'output buffer' usage relative to its ingestion rate?
- How does a 'Sorted Set' (ZSET) manage its internal membership and ordering differently from a plain Set?
- Which basic Redis command is used to store or update a simple String value associated with a specific key?