Push vs. Pull Models 00:00:01 Is the train platform ready for a new notice? A commuter refreshes the departures board every few seconds. A notice that arrives just after a refresh waits until the next one. Polling makes that latency and the cost of empty checks easy to see. The client asks for anything after 0. The item is stored. The client does not know, because nobody tells it. The second poll finds it, one second late. Half a second late. The delay depends on luck: between 0 and one interval. For regularly spaced polls with random arrival times, the average wait is roughly half an interval before network and processing delay. Tighter intervals buy freshness by increasing traffic. 00:00:45 Let the conductor hold one question open With long polling the client asks once and the server holds the question until an update or timeout. After a response, the client immediately asks from its last known position. The request arrives and nothing is new. The server does not answer yet. The request stays open and nothing travels. The client immediately sends the next request with its new cursor. After 30 seconds without news the server answers empty, so that proxies do not cut the connection. Allow for proxy timeouts, reconnection gaps and server-side connection capacity. A durable cursor can bridge the short interval between one request finishing and the next one reaching the server. 00:01:31 The notice goes out while the phone is in a tunnel With a live connection the station can forward an update immediately without waiting for a new poll. A disconnected device can miss a transient notification if the system keeps no replayable history. The client opens a connection and names what it wants. The server writes it down. Nothing happens, so nothing is sent. The connection only uses some memory. Two more, one after the other. The client asked for none of them. The phone enters a tunnel. Item 4 is sent to nobody. Separate fast notification from durable delivery. A quiet connection still uses resources, and heartbeats or reconnects create work that is invisible if you count only business messages. 00:02:18 A bell says there is mail, a cursor collects it Store item forty-two first and send a lightweight notification. The phone asks for everything after forty-one. Even after a missed signal it can consult the same durable source on its next wake-up. Message 42 is saved first. The phone has everything up to 41. The phone asks for everything after 41. Message 42 arrives and the cursor moves. The next signal, or the pull every few minutes, asks after 42 and gets 43. Nothing was lost. Persist the cursor after applying the retrieved items. If that last save fails, replay may repeat an item. Choose identifiers and updates that safely handle the repeat. 00:03:05 One slow commuter cannot hold up the station The server can push faster than a phone can consume. An unbounded outgoing buffer makes one crowded platform everybody's memory problem. Watch the buffer grow at the difference between the two rates. The buffer is empty and the rush begins. 40 items a second stay behind: 400 are waiting. The slow client is disconnected. The memory is free and the other clients are not affected. It reconnects with its cursor and pulls the stored events in batches, as fast as it can handle them. Bound the buffer and specify how to reconnect and catch up. Use pull for controllable pace, push for prompt notice, and a combined design when both immediacy and recoverable history matter.