ã¨ãããã¹ãã«ãTCPæ¥ç¶ãå¼µã£ã¦ã¯åãã¨ããå¦çãããããããç¹°ãè¿ããã³ããã¼ã¯çãªããã°ã©ã ãæ¸ãã¦åããã¾ããã
æåã®ãã¡ã¯æå¾ ããéãã®åä½ããã¦ããã§ãããéä¸ãã対åã®ãã¹ãã«TCPæ¥ç¶ã§ããªããªã£ã¦ã¨ã©ã¼åºã¾ããã
$ netstat -tna | grep TIME_WAIT | wc -l 28230
ãããåå ã½ãã
KERNEL_SOURCE/Documentation/networking/ip-sysctl.txt ã«ããã°ã
ip_local_port_range - 2 INTEGERS Defines the local port range that is used by TCP and UDP to choose the local port. The first number is the first, the second the last local port number. Default value depends on amount of memory available on the system: > 128Mb 32768-61000 < 128Mb 1024-4999 or even less. (snip)
ã¨ãããã¨ã§ãè¨ç®ãã¦ã¿ãã¨ã
$ cat /proc/sys/net/ipv4/ip_local_port_range | awk '{print $2-$1}' 28232
ãã£ãæ°ãã TIME_WAIT ã®æ°ã¨ã ãããä¸è´ãã¦ãã
ããã¡ãã£ã¨ãããµããªè¨æ¶ãªãã§ãããã³ãã¯ã·ã§ã³ãã¼ãã«ã®ç®¡çã¯ãSIP:SPORT:DIP:DPORTããã¼ã¨ãã¦ããã¯ããã§ãä»åã®ã±ã¼ã¹ã¯SIP, DIP, DPORTãåºå®ã§SPORTã ããå¤åãã¦ã£ã¦ã28232å使ãæããã¦ä¸ææ§ãä¿ã¦ãªããªã£ããã§ãã¨ã©ã¼ã«ãªã£ããã£ã¦ãã¨ã ã¨æãããå®éãä»ã®ãã¹ãã«ã¯æ¥ç¶å¼µãã¾ãããã
ã§ã§ã
æåã¯TIME_WAITã®æ»çæéãçãããã°ããã®ããªãã¨æã£ããããã©ãTIME_WAITã®ã³ãã¯ã·ã§ã³ãåå©ç¨ãããªãã·ã§ã³ããã£ããããªè¨æ¶ããã£ãããã£ãã®ã§ããã£ãã®ip-sysctl.txtãgrepããããç®å½ã¦ã®ãçºè¦ã
tcp_tw_recycle - BOOLEAN Enable fast recycling TIME-WAIT sockets. Default value is 0. It should not be changed without advice/request of technical experts. tcp_tw_reuse - BOOLEAN Allow to reuse TIME-WAIT sockets for new connections when it is safe from protocol viewpoint. Default value is 0. It should not be changed without advice/request of technical experts.
ããããã®2ã¤ã®å¤ãå¤ãã¦ã件ã®ãã³ããã¼ã¯çãªããã°ã©ã ãå®è¡ããçµæã¯ä»¥ä¸ã®éãã
recycle | reuse | netstat -tna | wc -l |
---|---|---|
0 | 0 | âãããããç¹ããªããªãã¨ã©ã¼ã«ãªãã |
0 | 1 | âãããããã¨ã©ã¼ã«ã¯ãªããªãã |
1 | 0 | âæ大ã§3000åãããã¾ã§å¢ãããã©ããã«æ¸ãã |
1 | 1 | âæ大ã§3000åãããã¾ã§å¢ãããã©ããã«æ¸ãã |
æåã®ã¨ã©ã¼ã«ãªãã±ã¼ã¹ãé¤ãã¦ã¯ãç§ãããã®æ¥ç¶æ°ã¯ã©ããåããããã
æåã ãè¦ãã¨recycle,reuseã1,0ã®å ´åã¨1,1ã®å ´åã®ã¯åãã½ããã§ãããrecycleã ãã1ã«ããã¹ããªã®ãã両æ¹1ã«ããã¹ããã¯ããããâ¦
âã®åèææ¸ã«ãæ¸ãã¦ã¾ããããã®è¨å®ã¯Webãµã¼ããªããã§ãæå¹ãªããããªããã¨æãã¾ããç¹ã«ãkeepaliveãOffã«ãã¦ããå ´åã¨ãã
以ä¸ãåèã
- http://www.linux.or.jp/JM/html/LDP_man-pages/man7/tcp.7.html
- IBM Redbooks | Tuning Red Hat Enterprise Linux on IBM eServer xSeries Serversã«ããPDFã®ã3.14.8 Advanced networking optionsã(65,66ãã¼ã¸)ã«tcp_tw_reuseã¨tcp_tw_recycleã«ã¤ãã¦ã®è¨åãããæå¹/ç¡å¹ãæ¯è¼ããã°ã©ããããããã以å¤ã«ããã®ææ¸ã¯ãã¥ã¼ãã³ã°ã®åèã«ãªãããã
è¿½è¨ 2009-05-09
tcp_tw_recycleã®å¼å®³ã«ã¤ãã¦ã
è¿½è¨ 2020-11-16
- net.ipv4.tcp_tw_recycle は廃止されました ― その危険性を理解する
- tcp_tw_recycle 㯠kernel 4.12 ã§å»æ¢