01Trace `SET a 1` through parser, dispatch, object storage, AOF, and output buffering. Which layer owns each decision?introScenarioYou are tracing one write command through every layer of the server you have built across this track.ADispatch owns bytes to argv, parsing owns command selection, and the SET handler owns logging and reply transport directly.BParsing owns bytes to argv, dispatch owns command selection, object storage owns typed state, AOF owns write logging, and output buffering owns reply bytes.CThe SET handler owns parsing its own arguments and writing its reply to the socket; AOF and object storage only observe the result.DObject storage owns logging the write, since it knows the final state; the AOF layer only stores periodic snapshots of the keyspace, which the rewrite process then compacts in the background.
02Trace `GET expired-key` after restart. Which systems must agree before the reply is produced?introScenarioA server has just restarted from disk and a client immediately asks for a key whose TTL passed during the downtime.AOnly the expiration system needs to know; recovery loads everything and lookup will find the TTL eventually.BOnly recovery and the AOF must agree, because once startup filtering runs, lookup needs no expiration logic at all, because offline deadlines were already handled before clients connected.CThe reply layer decides on its own, checking the TTL just before serializing and substituting a null reply.DRecovery, expiration metadata, shared lookup, object storage, and reply serialization must agree that the expired key is logically gone.
03Where should transaction state live, and why would putting it in the global database be wrong?appliedScenarioYou are deciding where MULTI state should live in a server that already has clients, a dispatcher, and a shared keyspace.ATransaction state belongs on the client because it is per-connection command-building state; putting it in the global DB would leak across clients and keys.BTransaction state belongs in the global database so that EXEC from any connection can resume a transaction after a reconnect.CTransaction state belongs in the command table, since MULTI changes how subsequent commands are dispatched.DTransaction state belongs in a dedicated transactions database, so queued commands survive a crash and replay during recovery.
04Which single distributed feature would add the most pressure to your current architecture: full sync, partial sync, failover, or slot routing?appliedScenarioYour single-node server works, and you are planning which distributed feature to attempt first.AFull sync, because transferring a snapshot requires pausing the event loop for the entire duration of the transfer, since a forked child cannot share pages with a parent that keeps serving traffic.BPartial sync, because the backlog must record the slot of every key alongside its bytes.CSlot routing usually adds the broadest pressure because it changes key ownership, client routing, multi-key validity, and redirects across the architecture.DFailover, because promotion rewrites the entire keyspace into the new primary's storage format.
05What is the smallest set of invariants that would make the server safe to extend?advancedScenarioYou are writing down the rules a new contributor must never break when extending your finished server.AServer-owned keyspace mutation, complete command execution before reply, type checks before handlers, durable writes recorded in order, and clients owning connection-local state.BReplies flushed to the socket before the keyspace mutates, so clients never observe state that was not yet acknowledged.CEach handler validates its own bytes and manages its own socket, so no cross-layer rules are needed at all.DSingle-threaded execution alone, since serialized commands make ordering, ownership, and type rules automatic — every other rule on the list simply restates what serial execution already guarantees.