Twitch 00:00:01 The streamer sees the goal before the audience A local tournament goes live and thousands of viewers hear the commentator a few seconds late. This illustrative Twitch-style design follows both the video and its chat, whose timing and delivery requirements differ. The program opens one lasting connection to a nearby ingest site and sends the stream key. Near matters: upload is the one part nothing can cache. The answer carries settings, such as the largest bitrate, and a lease with epoch 1. A second upload with this key is now refused. Compressed video and sound arrive with timestamps. The site smooths small network jitter. One decode and four encodes: 720p, 480p, 360p and 160p. The source is only repackaged. The packager publishes media parts and updates the corresponding playlist in a consistent order. Once the first key frame is stored, the session changes to live and the channel appears in lists. Authenticate the broadcaster, identify the stream session, transcode the incoming media and publish complete playable parts. A channel being marked live is not sufficient proof that a real viewer can decode its latest segment. 00:01:16 A new viewer has to find a decodable starting point A viewer joins halfway through the tournament. They need a playlist and a suitable segment near the live edge. Joining chat is a separate action and can succeed even if the video source is unhealthy. The app asks the API whether the channel is live. The answer is a signed playlist address with an end time, so it cannot be shared for long. The edge returns the list of renditions and their bitrates. The player selects an initial representation and timeline position using the applicable stream information. The edge has the newest part, or asks the origin once for all viewers who want it. At the same time, a WebSocket opens to a chat edge, which subscribes to the room if it has not yet. Choose a starting position that trades startup risk against end-to-end delay. Measure what the viewer actually sees. A healthy playlist endpoint cannot by itself vouch for every referenced media part. 00:02:11 Find the missing seconds in a live broadcast Trace the moment a player scores. Capture and upload, transcoding, packaging, delivery and playback buffering each add delay. The strongest improvement may be reducing a wait for a complete package rather than moving a server closer. Both start at the camera. Normal uses whole segments of two seconds. Low latency uses parts of 0.33 seconds. Encoding and upload belong to the broadcaster's computer and line. We shorten them only by being near. Half a second of work for the encoder. Traditional complete-segment delivery may wait for more media to accumulate before publishing it. Origin, shield and edge add about 0.2 seconds. Three segments are six seconds. In low-latency mode, 1.5 seconds. This is the safety margin against stalls. Shorter independently deliverable parts can lower delay, but they also raise request overhead and reduce buffering margin. Compare glass-to-glass latency and stalls under the same viewer network before choosing a mode. 00:03:16 Send one chat message to a hundred thousand screens The chat room receives one ordinary message. Asking one worker to write directly to every viewer makes that worker a fan-out bottleneck. Use a hierarchy of relays and regional edge connections in this example. If the room server wrote to every viewer, one message would be 100,000 writes, and 5,000 a second would be 500 million. The room owner sends one copy to each of five relays. Relays distribute the message to the selected pool of edge servers, which hold the viewer connections. Each edge has about 500 viewers of this room and writes to their sockets. Edges collect 250 ms of messages. Four frames a second to each viewer, however many messages are inside. One incoming message still implies substantial total delivery work. Batching reduces per-write overhead but deliberately delays messages. Choose a limit for slow viewers rather than retaining unbounded output for every socket. 00:04:18 A hundred viewers become fifty thousand A popular host sends its audience to the small tournament channel. Many edge requests suddenly need the same newest segment. Which work should be shared, and which must remain specific to each viewer? The edges have never heard of this channel. Every viewer asks for the same newest part. Each edge merges its waiting viewers into one request. The shield merges the edges. The origin sees one. The channel had source only. Crossing the line starts the ladder within seconds. The room moves to a larger server and slows new arrivals for a few minutes, so the small community is not drowned. Coalesce identical media misses at the edge, provision the processing path and control chat admission separately. After the surge, compare video startup delay with chat delivery lag. A single viewer count cannot explain both.