Before you start. This series builds a small copy of Redis, a program that stores keys and values in memory and answers other programs over the network. So far the copy can take the raw characters arriving on a network connection (a socket) and split them into commands, using Redis’s own message format, RESP (Redis 02: RESP, The Wire Protocol). It also keeps every key in one shared table, and the last lesson found a crack in it: two things touching that table at once corrupt it (Redis: The Map (SET / GET / DEL)).
Lesson 7 of 117 in From Scratch
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.
Or start free: a free account opens lessons 2 and 3 of every track.
In this lesson
The naive fix: a waiter for every table
2009, Berlin: “this is all wrong”
Seven years old already
A promise not to freeze
The order that stopped the whole restaurant
Same trick, different clothes
Terms it explains: thread, blocks, epoll, non-blocking, event loop, Thread per client, Process per client, C10K problem, Kernel bookkeeping, Context switches, Cache destruction, Locks, Every socket is non-blocking, level-triggered, mandatory, edge-triggered, `SCAN`, Returning a huge collection, Deleting a huge key, `UNLINK`, Predictable ordering, netpoller, not an error, outages.