The customer who won’t hang up (polling, SSE and WebSockets)

Four famous designs worked in one sitting. This lesson opens up the first of them, chat, whose hardest part is not storing messages but getting each one to a person the instant it exists.
Before you start. From The Contract at the Counter (API design): two programs meet at a counter, and every exchange so far was one question, one answer. From TCP vs UDP, and the 3-way handshake and HTTP Keep-Alive: opening a connection (the open line between two computers) costs a round of “hello” messages, and keeping one open saves paying it again. From HTTP 07: Chunked Encoding: a server can send its answer in pieces as they happen. From The order slip rail (queues & the utilization cliff): work that arrives in a bunch hurts far more than the same work spread out.