May 06, 2023
- HTTP Request & Response Phases
The most misunderstanding of nginx is that you thought nginx will read the whole response body from upstream before it sends the body to the downstream, as well as the request body, so the
$upstream_response_timeis the pure upstream traffic time-cost. It’s completely wrong! In fact, the traffic pipe between upstream and downstream is done dynamically and incrementally. Moreover, nginx will not read the request body from the downstream by default. Instead, when the headers are read, it triggers the phase handlers to handle this request, and after the balancer phase chooses an upstream node, it starts to read the request body and send it to the upstream gradually.