Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 02 · From Scratch · Redis · with code: Go · about 21 min to read

Play it as a journeyTutor comes with a plan

Redis: One Thread, Many Clients

One Thread Many Clients
One Thread Many Clients · Open board

The board behind this lesson. Sits under the project lesson Build Your Own Redis, From Scratch, and hands off to Keys That Die (Expiry).

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.

See plansAlready a member? Sign in

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.

Review From Scratch