{"id":82711,"date":"2026-07-25T11:19:50","date_gmt":"2026-07-25T03:19:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/82711.html"},"modified":"2026-07-25T11:19:50","modified_gmt":"2026-07-25T03:19:50","slug":"linux-%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%94%af%e6%8c%81%e7%9a%84-tcp-%e8%bf%9e%e6%8e%a5%e6%95%b0%e4%b8%8a%e9%99%90%e5%8f%8a%e9%85%8d%e7%bd%ae%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/82711.html","title":{"rendered":"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316"},"content":{"rendered":"<h2>linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u6700\u5927\u4e3a\u591a\u5c11\u53ca\u914d\u7f6e\u4f18\u5316<\/h2>\n<p>\u4e00\u53f0\u670d\u52a1\u5668\u7684 TCP \u8fde\u63a5\u6570\u6ca1\u6709\u56fa\u5b9a\u4e0a\u9650&#xff0c;\u7406\u8bba\u4e0a\u53ef\u8fbe 2\u2074\u2078&#xff08;\u7ea6 2.8\u00d710\u00b9\u2074&#xff09;&#xff0c;\u4f46\u5b9e\u9645\u5de5\u7a0b\u4e2d\u53d7\u786c\u4ef6\u4e0e\u7cfb\u7edf\u914d\u7f6e\u5236\u7ea6\u3002<\/p>\n<h4>&#x1f310; \u7406\u8bba\u4e0a\u9650<\/h4>\n<p>TCP \u8fde\u63a5\u7531\u56db\u5143\u7ec4&#xff08;\u6e90 IP\u3001\u6e90\u7aef\u53e3\u3001\u76ee\u7684 IP\u3001\u76ee\u7684\u7aef\u53e3&#xff09;\u552f\u4e00\u6807\u8bc6&#xff1b;\u670d\u52a1\u7aef\u901a\u5e38\u56fa\u5b9a\u76d1\u542c\u67d0\u7aef\u53e3&#xff0c;\u53ef\u53d8\u7684\u662f\u5ba2\u6237\u7aef IP \u4e0e\u7aef\u53e3&#xff0c;\u6545\u7406\u8bba\u6700\u5927\u8fde\u63a5\u6570\u4e3a 2\u00b3\u00b2&#xff08;IP \u6570&#xff09;\u00d72\u00b9\u2076&#xff08;\u7aef\u53e3\u6570&#xff09;&#061;2\u2074\u2078\u3002<\/p>\n<h4>\u26a0\ufe0f \u5b9e\u9645\u5236\u7ea6\u56e0\u7d20<\/h4>\n<ul>\n<li>\n<p>\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1a;\u6bcf\u4e2a\u8fde\u63a5\u5bf9\u5e94\u4e00\u4e2a fd&#xff0c;\u7cfb\u7edf\/\u8fdb\u7a0b\u7ea7\u6709\u9650\u5236&#xff0c;\u9ed8\u8ba4\u4ec5 1024&#xff0c;\u9700\u8c03\u81f3 10 \u4e07&#043;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5185\u5b58&#xff1a;\u6bcf\u4e2a\u8fde\u63a5\u7ea6\u5360 3.3\u20138KB \u5185\u6838\u5185\u5b58&#xff08;\u542b\u7f13\u51b2\u533a&#xff09;&#xff0c;8GB \u5185\u5b58\u5e38\u89c1\u573a\u666f\u7ea6 10\u201350 \u4e07&#xff0c;64GB&#043; \u53ef\u5230\u767e\u4e07\u7ea7\u3002<\/p>\n<\/li>\n<li>\n<p>\u7aef\u53e3\u8303\u56f4&#xff1a;\u672c\u5730\u7aef\u53e3\u9ed8\u8ba4\u7ea6 2.8 \u4e07&#xff0c;\u53ef\u6269\u81f3 1024\u201365535&#xff0c;\u591a IP \u53ef\u8fdb\u4e00\u6b65\u63d0\u5347\u3002<\/p>\n<\/li>\n<li>\n<p>CPU\/\u7f51\u7edc&#xff1a;\u9ad8\u5e76\u53d1\u4e0b\u4e2d\u65ad\u4e0e\u534f\u8bae\u6808\u5f00\u9500\u5927&#xff0c;10Gbps \u5e26\u5bbd\u6309\u5c0f\u5305\u4f30\u7b97\u53ef\u652f\u6491\u7ea6 70 \u4e07\u8fde\u63a5\u3002<\/p>\n<\/li>\n<li>\n<p>TIME_WAIT&#xff1a;\u77ed\u8fde\u63a5\u6613\u5806\u79ef&#xff0c;\u9700\u542f\u7528 tw_reuse \u5e76\u8c03 FIN \u8d85\u65f6\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>&#x1f4ca; \u5de5\u7a0b\u5b9e\u8df5\u53c2\u8003<\/h4>\n<ul>\n<li>\n<p>4\u68388G&#xff1a;\u7ea6 1\u20133 \u4e07&#xff1b;<\/p>\n<\/li>\n<li>\n<p>16\u683864G&#xff1a;\u7ea6 5\u201320 \u4e07&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f18\u5316\u540e&#xff08;\u5927\u5185\u5b58&#043;\u9ad8\u5e26\u5bbd&#xff09;&#xff1a;\u767e\u4e07\u7ea7\u5e38\u89c1&#xff0c;\u6781\u7aef\u573a\u666f\u53ef\u5230\u5343\u4e07\u7ea7\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>&#x1f6e0;\ufe0f \u5feb\u901f\u8c03\u4f18&#xff08;Linux&#xff09;<\/h4>\n<p># \u4e34\u65f6\u63d0\u5347\u8fdb\u7a0b\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26<br \/>\nulimit -n 200000<br \/>\n# \u6269\u5927\u672c\u5730\u7aef\u53e3\u8303\u56f4<br \/>\nsysctl -w net.ipv4.ip_local_port_range&#061;&#034;1024 65535&#034;<br \/>\n# \u4f18\u5316\u961f\u5217\u4e0eTIME_WAIT<br \/>\nsysctl -w net.core.somaxconn&#061;65535<br \/>\nsysctl -w net.ipv4.tcp_tw_reuse&#061;1<\/p>\n<h4>&#x1f3af; \u57fa\u4e8e16\u683864G\u4e07\u5146CentOS 7.9\u7684\u7cbe\u51c6\u5206\u6790<\/h4>\n<p>\u670d\u52a1\u5668\u914d\u7f6e&#xff08;16\u6838CPU\u300164GB\u5185\u5b58\u3001\u4e07\u5146\u5e26\u5bbd\u3001CentOS 7.9\u7cfb\u7edf&#xff09;&#xff0c;\u7ed3\u5408\u884c\u4e1a\u5b9e\u8df5\u7ecf\u9a8c\u4e0e\u7cfb\u7edf\u7279\u6027&#xff0c;\u5bf9TCP\u8fde\u63a5\u6570\u652f\u6491\u80fd\u529b\u53ca\u8c03\u4f18\u65b9\u6848\u5206\u6790\u5982\u4e0b&#xff1a;<\/p>\n<h5>\u4e00\u3001\u53ef\u652f\u6491TCP\u8fde\u63a5\u6570\u8303\u56f4\u4f30\u7b97<\/h5>\n<p>\u7efc\u5408\u786c\u4ef6\u6027\u80fd\u3001\u7cfb\u7edf\u9650\u5236\u53ca\u4e07\u5146\u5e26\u5bbd\u627f\u8f7d\u80fd\u529b&#xff0c;\u8be5\u670d\u52a1\u5668\u5728\u4e0d\u540c\u4e1a\u52a1\u573a\u666f\u4e0b\u7684\u5408\u7406TCP\u8fde\u63a5\u6570\u8303\u56f4\u4e3a&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u77ed\u8fde\u63a5\u573a\u666f&#xff08;\u5982HTTP\u63a5\u53e3\u8c03\u7528&#xff09;&#xff1a;\u4f18\u5316\u524d\u7ea65-8\u4e07\u5e76\u53d1\u8fde\u63a5&#xff1b;\u4f18\u5316\u540e\u53ef\u7a33\u5b9a\u652f\u649115-20\u4e07\u5e76\u53d1\u8fde\u63a5&#xff0c;\u5cf0\u503c\u53ef\u77ed\u6682\u627f\u8f7d25\u4e07\u8fde\u63a5&#xff08;\u9700\u914d\u5408TIME_WAIT\u4f18\u5316&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u957f\u8fde\u63a5\u573a\u666f&#xff08;\u5982WebSocket\u3001MQTT&#xff09;&#xff1a;\u4f18\u5316\u540e\u53ef\u7a33\u5b9a\u652f\u649120-30\u4e07\u5e76\u53d1\u8fde\u63a5&#xff0c;\u6838\u5fc3\u5236\u7ea6\u56e0\u7d20\u4e3a\u5185\u5b58&#xff08;64GB\u5185\u5b58\u53ef\u6ee1\u8db3\u8be5\u8fde\u63a5\u6570\u7684\u5185\u6838\u5185\u5b58\u5360\u7528\u9700\u6c42&#xff09;\u4e0e\u4e07\u5146\u5e26\u5bbd&#xff08;\u6309\u5e73\u5747\u6bcf\u4e2a\u8fde\u63a5\u5360\u752810KB\/s\u5e26\u5bbd\u8ba1\u7b97&#xff0c;\u4e07\u5146\u5e26\u5bbd\u53ef\u652f\u6491\u7ea6100\u4e07\u8fde\u63a5&#xff0c;\u4f46\u5b9e\u9645\u53d7CPU\u534f\u8bae\u6808\u5904\u7406\u80fd\u529b\u9650\u5236&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5173\u952e\u4f30\u7b97\u4f9d\u636e&#xff1a;64GB\u5185\u5b58\u4e2d&#xff0c;\u9884\u755920GB\u7ed9\u7cfb\u7edf\u53ca\u5176\u4ed6\u8fdb\u7a0b&#xff0c;\u5269\u4f5944GB\u53ef\u7528\u4e8eTCP\u8fde\u63a5\u5185\u6838\u5185\u5b58\u5360\u7528&#xff0c;\u6309\u6bcf\u4e2a\u8fde\u63a5\u5e73\u57476KB\u5185\u6838\u5185\u5b58\u8ba1\u7b97&#xff0c;\u4ec5\u5185\u5b58\u5373\u53ef\u652f\u6491\u7ea6730\u4e07\u8fde\u63a5&#xff1b;\u4f4616\u6838CPU\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u7684\u534f\u8bae\u6808\u5904\u7406\u80fd\u529b\u3001\u4e07\u5146\u5e26\u5bbd\u7684\u5b9e\u9645\u6570\u636e\u4f20\u8f93\u80fd\u529b&#xff0c;\u5171\u540c\u5c06\u5408\u7406\u8fde\u63a5\u6570\u9650\u5236\u572820-30\u4e07&#xff08;\u957f\u8fde\u63a5&#xff09;\u300115-20\u4e07&#xff08;\u77ed\u8fde\u63a5&#xff09;\u8303\u56f4&#xff0c;\u907f\u514d\u56e0CPU\u8fc7\u8f7d\u6216\u5e26\u5bbd\u62e5\u5835\u5bfc\u81f4\u8fde\u63a5\u7a33\u5b9a\u6027\u4e0b\u964d\u3002<\/p>\n<h5>\u4e8c\u3001\u9488\u5bf9\u6027\u6c38\u4e45\u8c03\u4f18\u65b9\u6848&#xff08;CentOS 7.9&#xff09;<\/h5>\n<p>CentOS 7.9\u9ed8\u8ba4\u914d\u7f6e\u5bf9\u9ad8\u5e76\u53d1TCP\u8fde\u63a5\u652f\u6491\u6709\u9650&#xff0c;\u9700\u901a\u8fc7\u4fee\u6539\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6\u5b9e\u73b0\u6c38\u4e45\u4f18\u5316&#xff08;\u4e34\u65f6\u914d\u7f6e\u91cd\u542f\u540e\u5931\u6548&#xff0c;\u4ee5\u4e0b\u65b9\u6848\u4e3a\u6c38\u4e45\u751f\u6548\u914d\u7f6e&#xff09;&#xff0c;\u5177\u4f53\u6b65\u9aa4\u53ca\u53c2\u6570\u8bf4\u660e\u5982\u4e0b&#xff1a;<\/p>\n<h6>1. \u4f18\u5316\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236&#xff08;\u89e3\u51b3\u6700\u5927\u6253\u5f00\u6587\u4ef6\u6570\u9650\u5236&#xff09;<\/h6>\n<p>\u6bcf\u4e2aTCP\u8fde\u63a5\u5bf9\u5e94\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff08;fd&#xff09;&#xff0c;CentOS 7.9\u9ed8\u8ba4\u8fdb\u7a0b\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e3a1024&#xff0c;\u9700\u63d0\u5347\u81f330\u4e07\u4ee5\u4e0a&#xff1a;<\/p>\n<p>\u4fee\u6539limits.conf\u6587\u4ef6# \u7f16\u8f91\u7cfb\u7edf\u7ea7\u6587\u4ef6\u63cf\u8ff0\u7b26\u914d\u7f6e<br \/>\nvi \/etc\/security\/limits.conf<br \/>\n# \u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9<br \/>\n* soft nofile 300000<br \/>\n* hard nofile 300000<br \/>\nroot soft nofile 300000<br \/>\nroot hard nofile 300000<\/p>\n<p># \u9a8c\u8bc1\u914d\u7f6e&#xff08;\u9700\u91cd\u65b0\u767b\u5f55\u7ec8\u7aef&#xff09;<br \/>\nulimit -n  # \u8f93\u51fa300000\u5373\u4e3a\u751f\u6548<\/p>\n<p>\u8bf4\u660e&#xff1a;\u201c*\u201d\u8868\u793a\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548&#xff0c;root\u7528\u6237\u5355\u72ec\u6307\u5b9a\u786e\u4fdd\u7ba1\u7406\u5458\u8fdb\u7a0b\u4e0d\u53d7\u9650&#xff0c;300000\u7684\u914d\u7f6e\u53ef\u6ee1\u8db320-30\u4e07\u5e76\u53d1\u8fde\u63a5\u7684\u9700\u6c42&#xff08;\u9884\u7559\u90e8\u5206\u5197\u4f59&#xff09;\u3002<\/p>\n<h6>2. \u4f18\u5316\u5185\u6838\u7f51\u7edc\u53c2\u6570&#xff08;\/etc\/sysctl.conf&#xff09;<\/h6>\n<p>\u7f16\u8f91\u5185\u6838\u7f51\u7edc\u914d\u7f6e\u6587\u4ef6&#xff0c;\u8c03\u6574TCP\u534f\u8bae\u6808\u53c2\u6570&#xff0c;\u63d0\u5347\u5e76\u53d1\u8fde\u63a5\u652f\u6491\u80fd\u529b&#xff1a;<\/p>\n<p>\u4fee\u6539sysctl.conf\u6587\u4ef6# \u7f16\u8f91\u5185\u6838\u914d\u7f6e\u6587\u4ef6<br \/>\nvi \/etc\/sysctl.conf<br \/>\n# \u6dfb\u52a0\/\u4fee\u6539\u4ee5\u4e0b\u53c2\u6570<br \/>\nnet.core.somaxconn &#061; 65535  # \u76d1\u542c\u961f\u5217\u6700\u5927\u957f\u5ea6&#xff0c;\u9ed8\u8ba4128&#xff0c;\u63d0\u5347\u81f365535\u907f\u514d\u8fde\u63a5\u6392\u961f\u6ea2\u51fa<br \/>\nnet.core.netdev_max_backlog &#061; 65535  # \u7f51\u5361\u63a5\u6536\u961f\u5217\u6700\u5927\u957f\u5ea6&#xff0c;\u63d0\u5347\u9ad8\u5e76\u53d1\u4e0b\u7684\u6570\u636e\u5305\u63a5\u6536\u80fd\u529b<br \/>\nnet.ipv4.tcp_max_syn_backlog &#061; 65535  # TCP\u4e09\u6b21\u63e1\u624bSYN\u961f\u5217\u957f\u5ea6&#xff0c;\u9ed8\u8ba41024&#xff0c;\u907f\u514dSYN\u6d2a\u6c34\u4e22\u5f03\u8fde\u63a5<br \/>\nnet.ipv4.tcp_syncookies &#061; 1  # \u542f\u7528SYN Cookie&#xff0c;\u9632\u8303SYN\u6d2a\u6c34\u653b\u51fb&#xff0c;\u4fdd\u969c\u9ad8\u5e76\u53d1\u4e0b\u8fde\u63a5\u5efa\u7acb\u7a33\u5b9a\u6027<br \/>\nnet.ipv4.tcp_tw_reuse &#061; 1  # \u5141\u8bb8\u91cd\u7528TIME_WAIT\u72b6\u6001\u7684\u7aef\u53e3&#xff0c;\u9002\u5408\u77ed\u8fde\u63a5\u573a\u666f&#xff0c;\u51cf\u5c11\u7aef\u53e3\u5360\u7528<br \/>\nnet.ipv4.tcp_tw_recycle &#061; 0  # CentOS 7.9\u4e2d\u5efa\u8bae\u5173\u95ed&#xff0c;\u907f\u514dNAT\u73af\u5883\u4e0b\u8fde\u63a5\u5f02\u5e38&#xff08;\u5f00\u542f\u53ef\u80fd\u5bfc\u81f4\u5185\u7f51\u7528\u6237\u8fde\u63a5\u5931\u8d25&#xff09;<br \/>\nnet.ipv4.tcp_fin_timeout &#061; 30  # TIME_WAIT\u72b6\u6001\u8d85\u65f6\u65f6\u95f4&#xff0c;\u9ed8\u8ba460\u79d2&#xff0c;\u7f29\u77ed\u81f330\u79d2\u91ca\u653e\u7aef\u53e3<br \/>\nnet.ipv4.ip_local_port_range &#061; 1024 65535  # \u672c\u5730\u7aef\u53e3\u8303\u56f4&#xff0c;\u9ed8\u8ba41024-32000&#xff0c;\u6269\u5c55\u81f3\u5168\u7aef\u53e3\u8303\u56f4&#xff08;65535\u4e2a\u7aef\u53e3&#xff09;<br \/>\nnet.ipv4.tcp_max_tw_buckets &#061; 5000  # TIME_WAIT\u72b6\u6001\u8fde\u63a5\u6700\u5927\u6570\u91cf&#xff0c;\u9ed8\u8ba4180000&#xff0c;\u9650\u5236\u4e3a5000\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u9ad8<br \/>\nnet.ipv4.tcp_max_orphans &#061; 3276800  # \u6700\u5927\u5b64\u513f\u8fde\u63a5\u6570&#xff08;\u65e0\u8fdb\u7a0b\u5173\u8054\u7684\u8fde\u63a5&#xff09;&#xff0c;\u63d0\u5347\u81f33276800\u907f\u514d\u8fde\u63a5\u88ab\u5185\u6838\u4e3b\u52a8\u5173\u95ed<br \/>\nnet.ipv4.tcp_slow_start_after_idle &#061; 0  # \u5173\u95ed\u7a7a\u95f2\u540e\u7684\u6162\u542f\u52a8&#xff0c;\u4e07\u5146\u5e26\u5bbd\u4e0b\u63d0\u5347\u6570\u636e\u4f20\u8f93\u6548\u7387<br \/>\nnet.ipv4.tcp_keepalive_time &#061; 600  # TCP\u4fdd\u6d3b\u65f6\u95f4&#xff0c;\u9ed8\u8ba47200\u79d2&#xff0c;\u7f29\u77ed\u81f310\u5206\u949f&#xff0c;\u53ca\u65f6\u91ca\u653e\u65e0\u6548\u957f\u8fde\u63a5<br \/>\nnet.ipv4.tcp_keepalive_intvl &#061; 30  # \u4fdd\u6d3b\u63a2\u6d4b\u95f4\u9694\u65f6\u95f4<br \/>\nnet.ipv4.tcp_keepalive_probes &#061; 3  # \u4fdd\u6d3b\u63a2\u6d4b\u6b21\u6570&#xff0c;3\u6b21\u65e0\u54cd\u5e94\u5219\u5173\u95ed\u8fde\u63a5<\/p>\n<p># \u4f7f\u914d\u7f6e\u751f\u6548&#xff08;\u65e0\u9700\u91cd\u542f&#xff09;<br \/>\nsysctl -p<\/p>\n<p>\u8bf4\u660e&#xff1a;\u4e0a\u8ff0\u53c2\u6570\u9488\u5bf916\u683864G\u4e07\u5146\u914d\u7f6e\u5b9a\u5236&#xff0c;\u517c\u987e\u8fde\u63a5\u7a33\u5b9a\u6027\u4e0e\u8d44\u6e90\u5360\u7528&#xff0c;\u5176\u4e2dtcp_tw_reuse\u5f00\u542f\u3001fin_timeout\u7f29\u77ed\u91cd\u70b9\u4f18\u5316\u77ed\u8fde\u63a5\u573a\u666f\u7684\u7aef\u53e3\u590d\u7528&#xff0c;somaxconn\u3001netdev_max_backlog\u63d0\u5347\u961f\u5217\u627f\u8f7d\u80fd\u529b&#xff0c;\u9002\u914d\u4e07\u5146\u5e26\u5bbd\u4e0b\u7684\u9ad8\u6570\u636e\u5305\u541e\u5410\u91cf\u3002<\/p>\n<h6>3. \u4f18\u5316\u8fdb\u7a0b\u7ea7\u914d\u7f6e&#xff08;\u4ee5Nginx\u4e3a\u4f8b&#xff0c;\u82e5\u4f7f\u7528\u5176\u4ed6\u670d\u52a1\u9700\u9002\u914d&#xff09;<\/h6>\n<p>\u82e5\u670d\u52a1\u5668\u8fd0\u884cNginx\u3001Tomcat\u7b49\u670d\u52a1&#xff0c;\u9700\u5728\u670d\u52a1\u914d\u7f6e\u4e2d\u63d0\u5347\u6700\u5927\u8fde\u63a5\u6570&#xff0c;\u5339\u914d\u7cfb\u7edf\u7ea7\u4f18\u5316&#xff1a;<\/p>\n<p>Nginx\u914d\u7f6e\u4f18\u5316&#xff08;\/etc\/nginx\/nginx.conf&#xff09;# \u7f16\u8f91Nginx\u914d\u7f6e<br \/>\nvi \/etc\/nginx\/nginx.conf<br \/>\n# \u5728http\u5757\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9<br \/>\nworker_processes 16;  # \u5de5\u4f5c\u8fdb\u7a0b\u6570&#xff0c;\u4e0eCPU\u6838\u5fc3\u6570\u4e00\u81f4&#xff08;16\u6838&#xff09;<br \/>\nworker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000 0000000100000000 0000001000000000 0000010000000000 0000100000000000 0001000000000000 0010000000000000 0100000000000000 1000000000000000;  # \u8fdb\u7a0b\u7ed1\u5b9aCPU\u6838\u5fc3&#xff0c;\u63d0\u5347\u6027\u80fd<br \/>\nworker_rlimit_nofile 300000;  # Nginx\u8fdb\u7a0b\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u4e0e\u7cfb\u7edf\u7ea7\u9650\u5236\u4e00\u81f4<\/p>\n<p>events {<br \/>\n    use epoll;  # \u4f7f\u7528epoll\u6a21\u578b&#xff0c;\u9ad8\u6548\u5904\u7406\u9ad8\u5e76\u53d1\u8fde\u63a5<br \/>\n    worker_connections 20000;  # \u6bcf\u4e2a\u5de5\u4f5c\u8fdb\u7a0b\u6700\u5927\u8fde\u63a5\u6570&#xff0c;16\u00d720000&#061;320000&#xff0c;\u5339\u914d\u7cfb\u7edf\u9650\u5236<br \/>\n    multi_accept on;  # \u5141\u8bb8\u4e00\u4e2a\u5de5\u4f5c\u8fdb\u7a0b\u540c\u65f6\u63a5\u6536\u591a\u4e2a\u65b0\u8fde\u63a5<br \/>\n}<\/p>\n<p># \u91cd\u542fNginx\u4f7f\u914d\u7f6e\u751f\u6548<br \/>\nsystemctl restart nginx<br \/>\n# \u9a8c\u8bc1\u914d\u7f6e<br \/>\nnginx -t<\/p>\n<p>\u8bf4\u660e&#xff1a;\u82e5\u4f7f\u7528Tomcat&#xff0c;\u9700\u4fee\u6539conf\/server.xml\u4e2d\u7684maxThreads&#xff08;\u6700\u5927\u7ebf\u7a0b\u6570&#xff09;\u3001maxConnections&#xff08;\u6700\u5927\u8fde\u63a5\u6570&#xff09;&#xff0c;\u5efa\u8baemaxConnections\u8bbe\u7f6e\u4e3a20000-30000&#xff0c;\u5339\u914d\u7cfb\u7edf\u7ea7\u4f18\u5316\u540e\u7684\u627f\u8f7d\u80fd\u529b\u3002<\/p>\n<h6>4. \u9a8c\u8bc1\u4e0e\u76d1\u63a7<\/h6>\n<p>\u4f18\u5316\u540e\u9700\u901a\u8fc7\u5de5\u5177\u76d1\u63a7\u8fde\u63a5\u6570\u3001CPU\u3001\u5185\u5b58\u53ca\u5e26\u5bbd\u4f7f\u7528\u60c5\u51b5&#xff0c;\u786e\u4fdd\u914d\u7f6e\u751f\u6548&#xff1a;<\/p>\n<p>\u5e38\u7528\u76d1\u63a7\u547d\u4ee4# \u67e5\u770b\u5f53\u524dTCP\u8fde\u63a5\u6570&#xff08;\u6309\u72b6\u6001\u7edf\u8ba1&#xff09;<br \/>\nnetstat -n | awk &#039;\/^tcp\/ {&#043;&#043;S[$NF]} END {for(a in S) print a, S[a]}&#039;<br \/>\n# \u6216\u4f7f\u7528ss\u547d\u4ee4&#xff08;\u66f4\u9ad8\u6548&#xff09;<br \/>\nss -s<\/p>\n<p># \u67e5\u770bCPU\u4f7f\u7528\u60c5\u51b5<br \/>\ntop  # \u5173\u6ce8%us&#xff08;\u7528\u6237\u6001CPU&#xff09;\u3001%sy&#xff08;\u7cfb\u7edf\u6001CPU&#xff09;&#xff0c;\u9ad8\u5e76\u53d1\u4e0b\u5efa\u8bae\u4e0d\u8d85\u8fc780%<\/p>\n<p># \u67e5\u770b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<br \/>\nfree -h  # \u5173\u6ce8\u5185\u6838\u5360\u7528\u5185\u5b58&#xff08;buff\/cache&#xff09;&#xff0c;\u907f\u514d\u5185\u5b58\u6ea2\u51fa<\/p>\n<p># \u67e5\u770b\u5e26\u5bbd\u4f7f\u7528\u60c5\u51b5<br \/>\niftop  # \u76d1\u63a7\u4e07\u5146\u7f51\u5361&#xff08;\u5982eth0&#xff09;\u7684\u51fa\u5165\u5e26\u5bbd&#xff0c;\u786e\u4fdd\u4e0d\u8d85\u8fc7\u5e26\u5bbd\u4e0a\u9650\u768480%<\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b&#xff0c;\u7a33\u5b9a\u8fd0\u884c\u65f6SYN_RECV\u3001TIME_WAIT\u72b6\u6001\u8fde\u63a5\u6570\u8f83\u5c11&#xff0c;ESTABLISHED&#xff08;\u5df2\u5efa\u7acb&#xff09;\u8fde\u63a5\u6570\u53ef\u7a33\u5b9a\u5728\u4f30\u7b97\u8303\u56f4\u5185&#xff0c;CPU\u3001\u5185\u5b58\u3001\u5e26\u5bbd\u65e0\u660e\u663e\u74f6\u9888\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u6700\u5927\u4e3a\u591a\u5c11\u53ca\u914d\u7f6e\u4f18\u5316<br \/>\n\u4e00\u53f0\u670d\u52a1\u5668\u7684 TCP \u8fde\u63a5\u6570\u6ca1\u6709\u56fa\u5b9a\u4e0a\u9650&#xff0c;\u7406\u8bba\u4e0a\u53ef\u8fbe 2\u2074\u2078&#xff08;\u7ea6 2.8\u00d710\u00b9\u2074&#xff09;&#xff0c;\u4f46\u5b9e\u9645\u5de5\u7a0b\u4e2d\u53d7\u786c\u4ef6\u4e0e\u7cfb\u7edf\u914d\u7f6e\u5236\u7ea6\u3002<br \/>\n&#x1f310; \u7406\u8bba\u4e0a\u9650<br \/>\nTCP \u8fde\u63a5\u7531\u56db\u5143\u7ec4&#xff08;\u6e90 IP\u3001\u6e90\u7aef\u53e3\u3001\u76ee\u7684 IP\u3001\u76ee\u7684\u7aef\u53e3&#xff09;\u552f\u4e00\u6807\u8bc6&#xff1b;\u670d\u52a1\u7aef\u901a\u5e38\u56fa\u5b9a\u76d1\u542c\u67d0\u7aef\u53e3&#xff0c;\u53ef\u53d8\u7684\u662f\u5ba2\u6237\u7aef IP \u4e0e\u7aef\u53e3&#xff0c;\u6545\u7406\u8bba\u6700\u5927\u8fde<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,205,43],"topic":[],"class_list":["post-82711","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-tcp-ip","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/82711.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u6700\u5927\u4e3a\u591a\u5c11\u53ca\u914d\u7f6e\u4f18\u5316 \u4e00\u53f0\u670d\u52a1\u5668\u7684 TCP \u8fde\u63a5\u6570\u6ca1\u6709\u56fa\u5b9a\u4e0a\u9650&#xff0c;\u7406\u8bba\u4e0a\u53ef\u8fbe 2\u2074\u2078&#xff08;\u7ea6 2.8\u00d710\u00b9\u2074&#xff09;&#xff0c;\u4f46\u5b9e\u9645\u5de5\u7a0b\u4e2d\u53d7\u786c\u4ef6\u4e0e\u7cfb\u7edf\u914d\u7f6e\u5236\u7ea6\u3002 &#x1f310; \u7406\u8bba\u4e0a\u9650 TCP \u8fde\u63a5\u7531\u56db\u5143\u7ec4&#xff08;\u6e90 IP\u3001\u6e90\u7aef\u53e3\u3001\u76ee\u7684 IP\u3001\u76ee\u7684\u7aef\u53e3&#xff09;\u552f\u4e00\u6807\u8bc6&#xff1b;\u670d\u52a1\u7aef\u901a\u5e38\u56fa\u5b9a\u76d1\u542c\u67d0\u7aef\u53e3&#xff0c;\u53ef\u53d8\u7684\u662f\u5ba2\u6237\u7aef IP \u4e0e\u7aef\u53e3&#xff0c;\u6545\u7406\u8bba\u6700\u5927\u8fde\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/82711.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-25T03:19:50+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/82711.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/82711.html\",\"name\":\"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-25T03:19:50+00:00\",\"dateModified\":\"2026-07-25T03:19:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/82711.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/82711.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/82711.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/82711.html","og_locale":"zh_CN","og_type":"article","og_title":"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u6700\u5927\u4e3a\u591a\u5c11\u53ca\u914d\u7f6e\u4f18\u5316 \u4e00\u53f0\u670d\u52a1\u5668\u7684 TCP \u8fde\u63a5\u6570\u6ca1\u6709\u56fa\u5b9a\u4e0a\u9650&#xff0c;\u7406\u8bba\u4e0a\u53ef\u8fbe 2\u2074\u2078&#xff08;\u7ea6 2.8\u00d710\u00b9\u2074&#xff09;&#xff0c;\u4f46\u5b9e\u9645\u5de5\u7a0b\u4e2d\u53d7\u786c\u4ef6\u4e0e\u7cfb\u7edf\u914d\u7f6e\u5236\u7ea6\u3002 &#x1f310; \u7406\u8bba\u4e0a\u9650 TCP \u8fde\u63a5\u7531\u56db\u5143\u7ec4&#xff08;\u6e90 IP\u3001\u6e90\u7aef\u53e3\u3001\u76ee\u7684 IP\u3001\u76ee\u7684\u7aef\u53e3&#xff09;\u552f\u4e00\u6807\u8bc6&#xff1b;\u670d\u52a1\u7aef\u901a\u5e38\u56fa\u5b9a\u76d1\u542c\u67d0\u7aef\u53e3&#xff0c;\u53ef\u53d8\u7684\u662f\u5ba2\u6237\u7aef IP \u4e0e\u7aef\u53e3&#xff0c;\u6545\u7406\u8bba\u6700\u5927\u8fde","og_url":"https:\/\/www.wsisp.com\/helps\/82711.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-25T03:19:50+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/82711.html","url":"https:\/\/www.wsisp.com\/helps\/82711.html","name":"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-25T03:19:50+00:00","dateModified":"2026-07-25T03:19:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/82711.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/82711.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/82711.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"linux \u670d\u52a1\u5668\u652f\u6301\u7684 TCP \u8fde\u63a5\u6570\u4e0a\u9650\u53ca\u914d\u7f6e\u4f18\u5316"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/82711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=82711"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/82711\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=82711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=82711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=82711"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=82711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}