$tcpinfo_rcv_space
The $tcpinfo_rcv_space variable returns the amount of memory allocated for the incoming TCP buffer space. — NGINX Core (HTTP)
Description
The $tcpinfo_rcv_space variable in NGINX provides information about the size of the TCP receive buffer, which is critical for managing incoming connections over TCP. This variable reflects the current value of the receive space allocated by the TCP stack for handling incoming data packets. It is set when the TCP layer establishes a connection and is configured based on system and application-level parameters, such as the TCP_MAX_RCV_SPACE value which can limit the maximum receive buffer size. When a connection is established, the TCP kernel allocates a portion of memory for incoming data packets which will be filled up until it reaches the specified limit. As data is received, the available receive space decreases, impacting the flow of incoming connections. This variable can be particularly useful in identifying network performance issues or monitoring application behavior under load, as it can indicate whether the application is appropriately utilizing the available resources. Typical values for $tcpinfo_rcv_space can vary widely depending on the underlying system configurations and network conditions but will often reflect standard TCP buffer sizes, which might range from a few kilobytes to several megabytes based on system settings and load. Proper tuning of these values can lead to optimized performance and reduced latency in data transmission.
Config Example
server {
listen 80;
location /status {
add_header X-TCP-Receive-Space "$tcpinfo_rcv_space";
# Additional status logic...
}
}Subsystem
httpCacheable
NoContexts
http, server, locationEnsure that the TCP stack is configured to allow large receive buffer sizes; otherwise, the variable may return lower than expected values.
Not all operating systems may expose the TCP receive buffer size through the $tcpinfo_rcv_space variable, leading to inconsistencies in behavior across platforms.
This variable is only applicable in contexts where TCP connections are managed, such as `http` and `stream`. For other contexts, it may not return meaningful data.