Nginx 00:00:01 A browser reaches the shop A shopper opens a product page. NGINX accepts the connection, chooses how to handle the request, and may serve a cached page or forward to an upstream application. Trace this read before considering writes. A worker accepts the connection and ends TLS. The Host header picks the server block and the URL picks the location. Limits are checked. App server 1 refuses the connection. The try counts as a failure. The same GET goes to app server 2, which answers. The answer goes into the cache and to the client at the client's speed. Retrying the illustrated safe read can help when a connection fails. Retrying an operation with external side effects requires a separate policy and evidence about what the first attempt did. 00:00:49 Three slow connections share a worker Connections A, B and C spend much of their lives waiting for network events. NGINX workers can service ready sockets without dedicating a thread to every idle connection. Connection A has a readable request. B and C are waiting, so the worker spends its current turn on A. A now waits for the app. B sent its request. The upstream reply for A and new input for C become ready. The worker can make progress on both in this turn. A is done, B gets its answer, C waits for a file. An idle connection still consumes descriptors and memory. An event loop works well when its own work stays short and potentially blocking operations are handled appropriately. 00:01:30 A slow phone should not occupy the application One customer's phone takes thirty-two seconds to download a page. Compare the upstream application's occupancy with and without response buffering under the assumptions of this example. The app worker feeds the phone for 32 seconds. With buffering enabled and enough room, NGINX reads the upstream response in about eight milliseconds in this illustration. The application connection can finish much earlier. NGINX feeds the phone. One small connection record waits, not an app worker. The proxy takes on the burden of delivering to the slow client. Choose suitable buffer limits and disable buffering where the application genuinely needs a low-latency streaming response. 00:02:07 Share a one-second public response During a launch, many buyers ask for exactly the same public product page. A very short cache lifetime and a configured cache lock can collapse bursts into fewer requests to the shop. The first request is a MISS and goes to the app. The others wait at the lock. Everyone who waited gets the new copy. With the illustrated stale-while-updating policy, one request refreshes an expired response while eligible readers can use the old copy. With use_stale error, the old copy is still served. Keep private and personalized responses outside an inappropriate cache key. Serving stale on failure protects availability only within the freshness policy that the product can accept. 00:02:47 Reload while a connection is still open The operator deploys a configuration change while buyers are connected. A graceful reload can put new connections on new workers and allow previous workers to finish existing connections. The old workers serve everyone. The master starts workers with the new files. They take new connections. A WebSocket can keep an older worker alive alongside the newer generation. Resource use can overlap during that interval. worker_shutdown_timeout closes what is left. The client reconnects to a new worker. A long-lived socket changes the drain time. Define a shutdown deadline and reconnection behavior, then measure successful completed requests across the transition.