Supplement · Nginx
Observability và performance tuning
Access log phải tách tổng request time khỏi upstream connect/header/response time, ghi upstream address/status và request ID. Một request có nhiều attempts nên biến upstream có thể là danh sách.
Đo trước khi chỉnh
- Golden signals: rate, error, duration, saturation; thêm active/waiting connections, FDs, CPU, memory, temp disk.
- Phân biệt client abort 499, Nginx-generated 502/504 và upstream status.
- Sampling log phải giữ error/tail; tránh log secret/token/PII.
- Tuning worker, keepalive, buffer, compression và sendfile bằng representative load; kiểm p50/p99 và resource curve.
- Stub status hữu ích nhưng không thay per-upstream/app telemetry.
Anti-pattern: benchmark static localhost rồi suy ra capacity reverse proxy production.