This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host1 ~]# tail -f /var/log/messages | |
Jan 22 15:05:39 ztm-n08 kernel: [12624150.315458] Out of socket memory |
- The server is running out of TCP memory
- There are too many orphaned sockets on the system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host1 ~]# cat /proc/sys/net/ipv4/tcp_mem | |
3480768 4641024 6961536 |
- min : below this number of pages TCP is not bothered about its memory consumption.
- pressure: when the amount of memory allocated to TCP by the kernel exceeds this threshold, the kernel starts to moderate the memory consumption. This mode is exited when memory consumption falls under min.
- max : the max number of pages allowed for queuing by all TCP sockets. When the system goes above this threshold, the kernel will start throwing the "Out of socket memory" error in the logs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host1 ~]# cat /proc/net/sockstat | |
sockets: used 48476 | |
TCP: inuse 174950 orphan 126800 tw 153787 alloc 174954 mem 102910 | |
UDP: inuse 34 mem 3 | |
UDPLITE: inuse 0 | |
RAW: inuse 1 | |
FRAG: inuse 3 memory 4968 |
To examine if the server has too many orphan sockets run the following:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host1 ~]# cat /proc/sys/net/ipv4/tcp_max_orphans | |
524288 |
Now that we know what the limit of orphaned sockets on a system can be, let's see the current number of orphaned sockets:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host1 ~]# cat /proc/net/sockstat | |
sockets: used 48476 | |
TCP: inuse 174950 orphan 126800 tw 153787 alloc 174954 mem 102910 | |
UDP: inuse 34 mem 3 | |
UDPLITE: inuse 0 | |
RAW: inuse 1 | |
FRAG: inuse 3 memory 4968 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host1 ~]# echo 400000 > /proc/sys/net/ipv4/tcp_max_orphans |
To account for that get the number of orphaned sockets during peak server utilization and multiple that by 4 to be safe. That should be the value you set in tcp_max_orphans.
In some cases if there are many TCP short lived connections on the system the number of orphaned sockets such as TIME_WAIT will be pretty big. To fix this situation you might need to increase the TIME_WAIT timeout (MSL) and experiment with tcp_tw_reuse /tcp_tw_recycle kernel tunable as describe in my other article on TCP Tuning.