You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Kernel fine-tuning
Modifying net.ipv4.tcp_mem parameter in Linux operating system
Copy page
Download PDF
Modifying net.ipv4.tcp_mem parameter in Linux operating system
Modifying the net.ipv4.tcp_mem parameter allows you to specify the memory available to the TCP stack for processing network data, thereby controlling memory allocation and release in TCP network connections.​
About the net.ipv4.tcp_mem parameter​
net.ipv4.tcp_mem is an array of three integers in the format [min pressure max]. These values represent the memory usage limits of the TCP protocol stack in different states. These three values define memory thresholds, with the unit set to Page (kernel page; one kernel page is normally 4 KiB). Their definitions are as follows:​
  • min: The threshold at which the kernel starts reclaiming memory. When the TCP memory usage of the system reaches this value, the kernel starts reclaiming memory to prevent overuse.​
  • pressure: The soft limit for kernel memory usage. When this value is exceeded, TCP adjusts its memory consumption and enters memory pressure mode. When memory consumption drops below the value specified by min, TCP exits memory pressure mode.​
  • max: The hard limit for kernel memory usage. That is, the maximum number of pages allowed for all TCP sockets to queue. When this value is exceeded, the system refuses to allocate new sockets.​
Applicable scenario​
  • Scenarios with heavy network load​
  • In high-traffic scenarios that require handling large numbers of concurrent HTTP requests, such as high-load web servers, streaming media servers, and big data transmission services, servers may encounter TCP connection bottlenecks or excessive memory usage. In such cases, you can use the following recommendations:​
  • min: Set this parameter to a relatively high value to reduce the impact of frequent memory reclamation on high-traffic requests.​
  • pressure: Set this parameter to 4/3 times the value of the min parameter.​
  • max: Set this parameter to twice the value of the pressure parameter.​
  • Scenarios with light network load​
  • In low-traffic scenarios, such as file sharing or basic web services, servers may use memory unnecessarily because of a high memory reclamation threshold. In such cases, you can use the following recommendations:​
  • min: Set this parameter to a relatively low value to lower the threshold for triggering memory reclamation and avoid unnecessary memory usage.​
  • pressure: Set this parameter to 4/3 times the value of the min parameter.​
  • max: Set this parameter to twice the value of the pressure parameter.​
Procedure​
​
Configuration by using the proc interface
Configuration by using the net_tcp.conf file
​
You can use this method to temporarily modify the parameter value while the operating system is running. Each time the instance restarts, you need to configure the parameter again.​
  1. Log in to the target instance. For more information, see Logging in to Linux instances.​
  1. Execute the following command on the target Linux instance to view the current value of the net.ipv4.tcp_mem parameter.​
  • ​
    cat /proc/sys/net/ipv4/tcp_mem​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to configure the net.ipv4.tcp_mem parameter.​
  • ​
    echo "21198 28265 42396" > /proc/sys/net/ipv4/tcp_mem​
    ​
tip​
Replace 21198 28265 42396 with the actual value required for your business. For more information, see About the net-ipv4-tcp-mem parameter.​
​
​
Last updated: 2026.06.18 17:49:52