$tcpinfo_rttvar

The $tcpinfo_rttvar variable returns the round-trip time variation for TCP connections in microseconds. — NGINX Core (HTTP)

$tcpinfo_rttvar NGINX Core (HTTP)

Description

The $tcpinfo_rttvar variable in NGINX provides diagnostics related to the latency stability of TCP connections by indicating the round-trip time (RTT) variation. This metric is derived from the TCP stack information, specifically measuring the variance of the RTT observed for packets sent over a TCP connection. When a client sends a request, NGINX captures the TCP information for that session, which includes the RTT values as reported by the underlying operating system's TCP stack. Typically, $tcpinfo_rttvar becomes available only after the TCP handshake is completed, and it is particularly useful in performance tuning and monitoring scenarios. Typical values can vary significantly based on the network conditions and the specific characteristics of the traffic; lower values indicate more stable and consistent network latency, while higher values reflect instability. Therefore, monitoring this variable can help in diagnosing network-related issues affecting application performance and user experience. This variable is mainly set whenever NGINX processes a request over a TCP connection in scenarios where TCP metrics are applicable. You can leverage its value in various contexts, such as logging or conditional configurations, to apply tailored optimizations depending on the RTT variance seen during a request.

Config Example

log_format my_logging_format '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $tcpinfo_rttvar';

access_log /var/log/nginx/access.log my_logging_format;

Subsystem

http

Cacheable

No

Contexts

http, server, location, if

$tcpinfo_rttvar is only available for TCP connections and will not work for UDP.

Make sure to enable TCP information retrieval in your OS settings if you are not seeing expected values.

Values are only available post TCP handshake; accessing this variable too early in the request processing may yield empty results.