01A socket is readable, but the input buffer still does not contain a full RESP command. What should the event loop do next?introScenarioThe event loop's read callback has just drained a socket and found only half of a RESP command in the buffer.ABlock on the socket until the rest of the command arrives, since returning with a partial parse wastes the read and the kernel buffer already holds the bytes, so the wait would be short.BDiscard the partial bytes and let the client retransmit the whole command; RESP framing is designed for that.CThe loop should return to polling or other ready callbacks after preserving buffered bytes; readiness was useful even though no full command was produced.DClose the connection, because a read event that yields no complete command indicates a protocol violation.
02Why does one long command increase latency for unrelated clients in a mostly single-threaded command model?introScenarioA monitoring dashboard shows latency spikes for all clients whenever one analytics client runs a huge scan.AA long command monopolizes the single command execution thread, so unrelated clients wait until control returns to the event loop.BThe kernel stops accepting TCP packets for other clients while one command is running on the server.CLatency rises because the long command holds the global keyspace lock that every reader has to wait on.DIt only affects clients sharing that connection; other connections are handled by parallel loop iterations, each iteration picking up wherever the previous one left off.
03Which maintenance tasks belong in time events rather than command handlers?appliedScenarioYou are deciding where periodic work should live in a reactor-style server with file events and time events.ASnapshot triggers and AOF rewrites belong in time events, but timeout checks and rehash steps must run inside command handlers to stay accurate.BDeadline sampling, cron-style maintenance, timeout checks, incremental rehash steps, and background bookkeeping fit time events better than individual handlers.CTime events should take over command parsing for slow clients, freeing file events to serve the fast ones.DNothing belongs in time events in a single-threaded design, because periodic work would freeze the event loop.
04Compare thread-per-client and event-loop designs for a shared in-memory keyspace. Where does each design pay complexity?appliedScenarioYour team is debating thread-per-client versus a single-threaded reactor for a new in-memory store.AThread-per-client pays mostly in stack memory, while the event loop pays mostly in a higher system-call count.BThe event loop pays in locking because its callbacks share state, while threads avoid races since each owns its client, which is why reactor frameworks ship with so many mutex utilities.CBoth pay identical costs in practice, differing only in the portability of the polling API they sit on.DThread-per-client pays in locking and shared-state races, while an event loop pays in nonblocking IO, buffering, and avoiding long callbacks.
05What is the difference between file descriptor readiness and application-level progress?advancedScenarioA junior engineer assumes that epoll reporting a socket as ready means a command is ready to execute.AFile descriptor readiness means the OS says IO might proceed; application progress means the Redis layer actually parsed, executed, flushed, or completed work.BThey are the same thing, because epoll only reports readiness once a complete request is available to parse — that is what the level-triggered mode guarantees to applications.CReadiness describes writes and progress describes reads, tracked by the loop with separate descriptors.DProgress is the kernel's view of its socket queues, while readiness is the application's view of parsed commands.