When the backend interface timeout, sometimes the response of 404 and sometimes the response of 504
1. When the front-end interface response timeout of the current page request timeout, sometimes the response is 504 (in line with expectations), and sometimes the response is 404 (not in line with expectations). as shown in Figure 1
{
"_request_time": "60.004",
"_status": "404"
}
2. Based on _request_id:004c4f55c16c0904759fdb580d7c5df9 query ingress-nginx The log, ingress-nginx-controller exists a record (10-14 16:01:33), response 404. as shown in Figure 2
3. Query the log of the Frontend service based on _request_id:004c4f55c16c0904759fdb580d7c5df9 query the frontend service There is a record (10-14 16:01:33), request /50x.html, response 404, _upstream_status:504, indicating that the backend service response 504. as shown in Figure 3
4, based on _request_id:004c4f55c16c0904759fdb580d7c5df9 query the backend service log, backend service There is a record (10-14 16:01:33), the response is 504, and the actual response of the record is 499 due to the active disconnection of the Frontend Service. as shown in Figure 4
5. Check the Nginx configuration of the Frontend Service. Since the page 50x.html does not exist, it causes a response 404. It is finally decided to comment out the relevant configuration items. as shown in Figure 5
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
6. Analysis conclusion: if the frontend service (FRONTEND-SVC-80) is waiting for the response of backend-svc-80, and the backend-svc-80 response is too slow, the client will be responding After 404, the connection is actively closed, resulting in the Backend Service Nginx record 499 status code.
7. Detailed flowchart of the current front-end interface request: 1. Client request → 2. Ingress controller (ingress-nginx-controller) → 3. frontend service (Frontend-SVC-80) → 4. Backend Service (backend-SVC-80) → Timeout (504|499) → 5. Frontend service Return 404 → 6. Ingress Controller returns 404
8. After adjusting through step 5, when the back-end interface responds to the timeout, no longer responds 404, which is in line with expectations. as shown in Figure 6





