Skip to content


What is tcp_moderate_rcvbuf?

tcp_moderate_rcvbuf is a feature in the Linux kernel that dynamically adjusts the receive buffer size of a TCP connection. The receive buffer is a portion of memory used by the operating system to temporarily store incoming data before it is processed by the receiving application. By default, the receive buffer size is set to a fixed value, which may not be optimal for all network conditions.

tcp_moderate_rcvbuf is designed to improve network performance by dynamically adjusting the receive buffer size based on the available memory and network conditions. When enabled, the kernel will monitor the amount of available memory and adjust the receive buffer size accordingly. If there is plenty of free memory, the kernel will increase the buffer size to improve throughput. On the other hand, if memory is scarce, the kernel will decrease the buffer size to prevent excessive memory usage.

How to Enable tcp_moderate_rcvbuf

tcp_moderate_rcvbuf is disabled by default in most Linux distributions. To enable it, you need to set the appropriate kernel parameter. The easiest way to do this is to add the following line to the /etc/sysctl.conf file:


This will enable tcp_moderate_rcvbuf for all TCP connections. You can also enable it for a specific connection by setting the SO_MODERATE_RCVBUF socket option.

Benefits of tcp_moderate_rcvbuf

tcp_moderate_rcvbuf can provide several benefits, including:

  • Improved network performance: By dynamically adjusting the receive buffer size, tcp_moderate_rcvbuf can improve network throughput and reduce latency.
  • Reduced memory usage: tcp_moderate_rcvbuf prevents excessive memory usage by adjusting the receive buffer size based on the available memory.
  • Automatic tuning: tcp_moderate_rcvbuf automatically adjusts the receive buffer size based on the network conditions, eliminating the need for manual tuning.

Overall, tcp_moderate_rcvbuf is a useful feature that can help optimize network performance in certain situations. By enabling it, you can take advantage of automatic tuning to improve your network throughput and reduce latency.

Tips of tcp_moderate_rcvbuf

This parameter is enabled by default and will automatically adjust the TCP buffer size to achieve maximum throughput (not exceeding the tcp_rmem setting).

However, this can conflict with the HTTP2 protocol, as HTTP2 has its own flow control agreement. If your Nginx speed is problematic, it is recommended to disable it.