{"id":30902,"date":"2025-04-21T05:11:11","date_gmt":"2025-04-20T21:11:11","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/30902.html"},"modified":"2025-04-21T05:11:11","modified_gmt":"2025-04-20T21:11:11","slug":"c%e9%a1%b9%e7%9b%ae-%e7%bd%91%e7%bb%9c%e8%81%8a%e5%a4%a9%e6%9c%8d%e5%8a%a1%e5%99%a8-%e5%ae%9e%e7%8e%b0%ef%bc%9bqps%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/30902.html","title":{"rendered":"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5"},"content":{"rendered":"<p>\u6e90\u7801 https:\/\/github.com\/DBWGLX\/SZU_system_programming<\/p>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u6280\u672f\u8bbe\u8ba1<\/li>\n<li>\n<ul>\n<li>\u7f16\u7801<\/li>\n<li>\n<ul>\n<li>JSON\u7684\u66ff\u6362<\/li>\n<li>Protobuf<\/li>\n<\/ul>\n<\/li>\n<li>\u7f51\u7edc<\/li>\n<li>\n<ul>\n<li>\u7ebf\u7a0b\u6c60\u66f4\u9ad8\u6548\u7387<\/li>\n<li>\u7f51\u7edc\u5b57\u8282\u5e8f\u7684\u8003\u8651<\/li>\n<li>send\u53ef\u80fd\u65e0\u6cd5\u4e00\u6b21\u6027\u53d1\u9001\u5168\u90e8\u6570\u636e&#xff01;<\/li>\n<li>EPOLLHUP , EPOLLERR \u7684\u6b63\u786e\u5904\u7406<\/li>\n<\/ul>\n<\/li>\n<li>IO<\/li>\n<li>\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u66f4\u9ad8\u6027\u80fd<\/li>\n<\/ul>\n<\/li>\n<li>\u5f00\u53d1\u65e5\u5fd7<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>2025.3<\/li>\n<li>\n<ul>\n<li>a.\u7c98\u5305\u95ee\u9898<\/li>\n<\/ul>\n<\/li>\n<li>2025.4<\/li>\n<li>\n<ul>\n<li>b.\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6\u540c\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u95ee\u9898<\/li>\n<li>\u7b2c\u4e00\u6b21\u6279\u91cf\u6ce8\u518c\u6210\u529f1W\u7528\u6237<\/li>\n<li>500qps<\/li>\n<li>c.\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u6ca1\u5fc5\u8981\u95ee\u9898<\/li>\n<li>700qps<\/li>\n<li>d. \u9ad8\u5e76\u53d1\u5747\u5300\u5904\u7406\u95ee\u9898 [ EPOLLONESHOT ]<\/li>\n<li>1\u4e07\u4e2a\u5957\u63a5\u5b57\u5206\u522b\u53d1\u9001\u6d4b\u8bd5<\/li>\n<li>\u6700\u5927\u8fde\u63a5\u6570&#xff1f;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u6280\u672f\u8bbe\u8ba1<\/h2>\n<h3>\u7f16\u7801<\/h3>\n<h4>JSON\u7684\u66ff\u6362<\/h4>\n<p>JSON \u4e0d\u63d0\u4f9b\u5f3a\u7c7b\u578b&#xff0c;\u5fc5\u987b\u624b\u52a8\u68c0\u67e5\u5b57\u6bb5\u7c7b\u578b\u3002\u800cProtobuf \u53cd\u5e8f\u5217\u5316\u65f6&#xff0c;\u4f1a\u81ea\u52a8\u68c0\u67e5\u5b57\u6bb5\u7c7b\u578b\u3002<\/p>\n<p>JSON\u7f16\u7a0b\u65f6&#xff0c;\u6bcf\u4e2a k \u7684\u8bbe\u7f6e\u89e3\u6790\u90fd\u5f97\u68c0\u67e5\u3002 json_t *response &#061; json_object(); \u5bf9\u8c61\u521b\u5efa&#xff0c;\u6700\u540e\u8fd8\u8981\u91ca\u653e\u3002<\/p>\n<h4>Protobuf<\/h4>\n<p>\u5df2\u7ed3\u5408 K-L-V<\/p>\n<p>\u5b98\u65b9\u7f16\u7801\u6587\u6863\u5b66\u4e60 https:\/\/blog.csdn.net\/JK01WYX\/article\/details\/146919585?spm&#061;1001.2014.3001.5501<\/p>\n<h3>\u7f51\u7edc<\/h3>\n<h4>\u7ebf\u7a0b\u6c60\u66f4\u9ad8\u6548\u7387<\/h4>\n<h4>\u7f51\u7edc\u5b57\u8282\u5e8f\u7684\u8003\u8651<\/h4>\n<p>htol<\/p>\n<h4>send\u53ef\u80fd\u65e0\u6cd5\u4e00\u6b21\u6027\u53d1\u9001\u5168\u90e8\u6570\u636e&#xff01;<\/h4>\n<h4>EPOLLHUP , EPOLLERR \u7684\u6b63\u786e\u5904\u7406<\/h4>\n<p>\u76f4\u63a5\u770b events \u90e8\u5206&#xff1a;https:\/\/blog.csdn.net\/JK01WYX\/article\/details\/132699613<\/p>\n<h3>IO<\/h3>\n<h3>\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u66f4\u9ad8\u6027\u80fd<\/h3>\n<p>\u6570\u636e\u5e93\u67e5\u8be2\u9700\u8981\u65f6\u95f4&#xff0c;\u53ef\u4ee5\u4e0d\u53bb\u7b49\u5176\u64cd\u4f5c\u5b8c<\/p>\n<h2>\u5f00\u53d1\u65e5\u5fd7<\/h2>\n<h4>2025.3<\/h4>\n<p>\u9879\u76ee\u642d\u597d&#xff0c;\u8dd1\u4e86\u4e0b&#xff0c;\u611f\u89c9\u4e00\u70b9\u95ee\u9898\u6ca1\u6709\u3002<\/p>\n<h5>a.\u7c98\u5305\u95ee\u9898<\/h5>\n<p>\u538b\u6d4b\u4e0b&#xff0c;\u6ce8\u518c5W\u4e2a\u7528\u6237&#xff1a; &#xff01;json\u89e3\u6790\u9519\u8bef&#xff0c;\u7c98\u5305\u4e86&#xff01;json\u662f\u4e00\u8d77\u89e3\u6790\u7684&#xff0c;\u6bd5\u7adf\u627e {} \u5373\u53ef\u3002<\/p>\n<p>\u548c\u540c\u5b66\u4ea4\u6d41\u540e\u5f97\u77e5&#xff0c;json\u62a5\u6587\u4e0d\u662f\u5f88\u597d\u7684\u9009\u62e9&#xff0c;\u542f\u52a8protobuf<\/p>\n<h4>2025.4<\/h4>\n<p>protobuf &#043; KLV \u542f\u52a8<\/p>\n<h5>b.\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6\u540c\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u95ee\u9898<\/h5>\n<p>\u4efb\u52a1\u961f\u5217recv \u51fa\u95ee\u9898<\/p>\n<p>\u63a5\u7740\u6ce8\u518c5w\u4e2a\u7528\u6237<\/p>\n<p>\u6211\u7528\u4e00\u4e2a\u5ba2\u6237\u7aef\u53d1\u8d775w\u4efd\u6ce8\u518c\u8bf7\u6c42 \u2014\u2014 \u53ea\u6ce8\u518c\u4e86\u524d5\u4e2a<\/p>\n<p>epoll \u6536\u5230 IO \u53ea\u653e\u5230\u4efb\u52a1\u961f\u5217&#xff0c;\u90a3\u540c\u4e00\u4e2asocket\u6587\u4ef6\u63cf\u8ff0\u7b26\u5c31\u53ef\u80fd\u88ab\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6&#xff0c;\u8fd9\u662f\u9519\u8bef\u7684<\/p>\n<p>\u53ef\u4ee5\u5206\u79bb \u63a5\u6536\u6570\u636e \u548c \u6570\u636e\u5904\u7406&#xff0c;\u540e\u671f\u63a5\u6536\u6570\u636e\u7528\u534f\u7a0b\u548c\u9ad8\u6027\u80fd\u7684io_uring<\/p>\n<h5>\u7b2c\u4e00\u6b21\u6279\u91cf\u6ce8\u518c\u6210\u529f1W\u7528\u6237<\/h5>\n<p>\u901a\u8fc7\u51cf\u6162\u53d1\u9001\u901f\u5ea6&#xff0c;\u63d0\u5347\u7f13\u51b2\u533a net.core.rmem_max&#xff0c;\u7ef4\u62a4 recv\u63a5\u6536\u5b8c\u6574 &#xff08;\u670d\u52a1\u5668\u8fd9\u8fb9\u662f\u4e00\u4e2a\u7ebf\u7a0b\u518d\u5904\u7406&#xff09;<\/p>\n<p>\u7528\u65f6 2m40s (\u7b2c\u4e00\u4e2a\u521b\u5efa\u65f6\u95f4\u548c\u6700\u540e\u4e00\u4e2a\u521b\u5efa\u65f6\u95f4\u4e4b\u5dee)<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211105-680562e9ddf4c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211106-680562ea4bab6.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7528\u7684\u9ed8\u8ba4 net rmem \u7f13\u51b2\u533a\u5927\u5c0f<\/p>\n<p>wyx&#064;ubuntu:~\/work\/SZU_system_programming\/ChatServer$ sysctl net.core.rmem_max<br \/>\nnet.core.rmem_max <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">212992<\/span><br \/>\nwyx&#064;ubuntu:~\/work\/SZU_system_programming\/ChatServer$ sysctl net.core.rmem_default<br \/>\nnet.core.rmem_default <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">212992<\/span><\/p>\n<p>\u4e0d\u9650\u5236\u53d1\u9001\u65b9\u53d1\u9001\u901f\u5ea6&#xff0c;\u7a0b\u5e8f\u6b63\u5e38\u8fd0\u884c<\/p>\n<p>2m18s <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211106-680562ea9d5cf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u63d0\u5347 net.core.rmem_max \u4e3a 16MB&#xff0c;\u901f\u5ea6\u63d0\u5347\u81f3 52s<\/p>\n<p>sudo sysctl -w net.core.rmem_max&#061;16777216<br \/>\nsudo sysctl -w net.core.rmem_default&#061;8388608<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211106-680562eaed830.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h5>500qps<\/h5>\n<p>\u73b0\u5728\u5206\u51fa4\u4e2a\u5ba2\u6237\u7aef&#xff0c;\u5e76\u884c\u8bf7\u6c42&#xff1a;&#xff08;\u6b64\u65f6\u670d\u52a1\u56684\u4e2a\u7ebf\u7a0b\u5e76\u884c\u5904\u7406&#xff09;<\/p>\n<p>18s &#061;&gt; 1e4 \/ 18 &#061; 555 queries per second&#xff01; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211107-680562eb50eb9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> &#xff08;\u63d2\u5165\u65f6\u5206\u914d\u4e3b\u952e&#xff0c;\u6839\u636e\u4e3b\u952eid\u6392\u5e8f\u7684&#xff09;<\/p>\n<h5>c.\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u6ca1\u5fc5\u8981\u95ee\u9898<\/h5>\n<h5>700qps<\/h5>\n<p>\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u7684\u601d\u60f3\u662f\u4e0d\u7528\u9891\u7e41\u521b\u5efa\u91ca\u653e\u6570\u636e\u5e93\u8fde\u63a5\u3002\u7136\u800c\u591a\u7ebf\u7a0b\u4ece\u8fde\u63a5\u6c60\u4e2d\u53d6\u8fde\u63a5&#xff0c;\u4e5f\u4f1a\u51fa\u73b0\u7ade\u6001\u6761\u4ef6 \u6211\u8fd9\u91cc4\u68384\u4efb\u52a1\u7ebf\u7a0b&#xff0c;\u4e0d\u7b97\u591a&#xff0c;\u53ef\u4ee5\u7ed9\u6bcf\u4e2a\u7ebf\u7a0b\u5206\u914d\u4e00\u4e2a\u8fde\u63a5<\/p>\n<p>14s &#061;&gt; 1w\u6ce8\u518c\u8bf7\u6c42 &#xff1a; 1e4 \u2797 14 &#061; 714 qps ! <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211107-680562eb898b6.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>&#xff08;top&#xff09;\u8fd0\u884c\u65f6\u5360\u7528&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211107-680562ebc29c1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5ba2\u6237\u7aef\u53d1\u9001\u7b2c\u4e00\u4e2a\u524d\u7684\u65f6\u95f4&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211107-680562ebeb318.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u670d\u52a1\u5668\u540c\u4e00\u65f6\u523b\u6536\u5230\u6ce8\u518c\u8bf7\u6c42&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211108-680562ec1b547.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h5>d. \u9ad8\u5e76\u53d1\u5747\u5300\u5904\u7406\u95ee\u9898 [ EPOLLONESHOT ]<\/h5>\n<p>\u5728 epoll \u7684\u8fb9\u7f18\u89e6\u53d1&#xff08;Edge Triggered&#xff0c;ET&#xff09;\u6a21\u5f0f\u4e0b\u7ed3\u5408 EPOLLONESHOT \u4f7f\u7528\u65f6&#xff0c;\u4e00\u4e2a socket \u6587\u4ef6\u63cf\u8ff0\u7b26\u5728\u52a0\u5165 epoll \u5b9e\u4f8b\u524d\u6536\u5230\u6d88\u606f&#xff0c;\u52a0\u5165\u540e\u4ecd\u53ef\u4ee5\u6536\u5230\u8fd9\u6b21 IO \u4e8b\u4ef6<\/p>\n<p>\u8fde\u63a5\u4e00\u76f4\u8fde\u63a5\u65ad\u5f00\u524d&#xff0c;recv\u53ef\u4ee5\u4e00\u76f4\u963b\u585e&#xff0c;\u5bfc\u81f4\u4efb\u52a1\u7ebf\u7a0b\u963b\u585e&#xff0c;\u670d\u52a1\u5668\u6ca1\u6cd5\u5904\u7406\u5176\u4ed6\u8bf7\u6c42\u4e86\u3002<\/p>\n<p>\u6240\u4ee5\u5e94\u8bbe\u7f6e\u8d85\u65f6&#xff0c;\u6216\u8005\u5c31\u6309\u4efb\u52a1\u961f\u5217\u987a\u5e8f\u5904\u7406\u3002<\/p>\n<p>\u4f46\u662f&#xff01;\u6309\u7167\u4efb\u52a1\u961f\u5217\u987a\u5e8f\u5904\u7406&#xff0c;\u4e4b\u524d\u8865\u4e01\u52a0\u7684set \u6709\u6f0f\u6d1e&#xff0c;\u53ef\u80fd\u4f1a\u5ffd\u89c6\u4e00\u4e9b\u8fb9\u7f18\u9a71\u52a8&#xff0c; \u5e94\u4f7f\u7528 EPOLLONESHOT<\/p>\n<p>19s &#061;&gt; 1e4 \/ 19 &#061; 526 qps <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211108-680562ec63939.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u63a5\u7740\u5c31\u53ef\u4ee5\u5199 io_uring \u5566&#xff01;<\/p>\n<h5>1\u4e07\u4e2a\u5957\u63a5\u5b57\u5206\u522b\u53d1\u9001\u6d4b\u8bd5<\/h5>\n<p>\u7528\u65f6 18s &#xff1a;555qps \u8bc1\u660e\u8be5\u670d\u52a1\u5668\u5904\u7406\u5927\u91cf\u8fde\u63a5\u8bf7\u6c42\u57fa\u672c\u6ca1\u6709\u95ee\u9898~ <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211108-680562ec9f6f4.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7ec6\u8282&#xff1a;<\/p>\n<p>\u6b63\u662f\u4e0d\u540c\u7684\u8fde\u63a5&#xff0c;\u5c3d\u7ba1\u5ba2\u6237\u7aef\u662f\u6309\u987a\u5e8f\u53d1\u9001&#xff0c;\u670d\u52a1\u5668\u5904\u7406\u987a\u5e8f\u5374\u6709\u6240\u4e0d\u540c&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211108-680562ecde426.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6d4b\u8bd5\u5ba2\u6237\u7aef\u662f for\u5faa\u73af\u521b\u5efa1w\u4e2a\u5957\u63a5\u5b57&#xff0c;\u7136\u540e for\u5faa\u73af\u53d1\u9001 1w\u4e2a\u6ce8\u518c\u8bf7\u6c42\u7684\u3002 \u521b\u5efa\u5957\u63a5\u5b57\u7528\u65f64s&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211109-680562ed2161a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e0d\u8fc7 connect \u5e76\u4e0d\u662f\u540c\u65f6\u5230\u8fbe&#xff0c;\u670d\u52a1\u5668\u8fd9\u8fb9\u662f\u5148\u63a5\u6536\u4e866000&#043;\u540e&#xff0c;\u5c31\u5f00\u59cb\u63a5\u6536\u6ce8\u518c\u8bf7\u6c42\u4e86&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211109-680562ed6f925.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u5f00\u59cb\u5904\u7406&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211109-680562edb4cec.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6700\u540e\u5230\u8fbe\u7684\u8fde\u63a5&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211110-680562ee09ec4.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fd9\u8bf4\u660e\u4e86 \u963b\u585e connect() \u2260 \u7b49\u670d\u52a1\u5668\u5904\u7406\u5b8c &#xff01;<\/p>\n<p>\u8fd9\u548c \u7f51\u7edc\u534f\u8bae\u6808 &#043; \u5185\u6838\u8c03\u5ea6 &#043; \u670d\u52a1\u7aef\u5904\u7406\u6a21\u578b \u6709\u5173\u3002\u5185\u6838\u5728\u8fde\u63a5&#xff0c;\u800c\u670d\u52a1\u5668\u5c42\u53ea\u662f\u5904\u7406~<\/p>\n<h5>\u6700\u5927\u8fde\u63a5\u6570&#xff1f;<\/h5>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211110-680562ee58e70.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> 16000&#043;<\/p>\n<p>\u9650\u5236\u56e0\u7d20&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u4e2a\u8fdb\u7a0b\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u76ee<\/li>\n<li>socket\u6570\u91cf\u9650\u5236 cat \/proc\/sys\/fs\/file-max cat \/proc\/sys\/net\/core\/somaxconn cat \/proc\/sys\/net\/ipv4\/ip_local_port_range <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211110-680562eea2608.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/li>\n<li>\u7aef\u53e3\u8017\u5c3d (28K\u4e2a)<\/li>\n<\/ul>\n<p>\u89e3\u51b3\u65b9\u6cd5&#xff1a;<\/p>\n<p># \u4e34\u65f6\u63d0\u5347\u5f53\u524d\u4f1a\u8bdd\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u76ee\u9650\u5236<br \/>\nulimit -n 1000000<\/p>\n<p># \u8bbe\u7f6e\u5141\u8bb8\u7684\u6700\u5927\u6587\u4ef6\u6570<br \/>\nsysctl -w fs.file-max&#061;2097152<\/p>\n<p># \u8bbe\u7f6e backlog \u961f\u5217\u957f\u5ea6<br \/>\nsysctl -w net.core.somaxconn&#061;65535<\/p>\n<p># \u8bbe\u7f6e\u4e34\u65f6\u7aef\u53e3\u8303\u56f4&#xff08;\u9ed8\u8ba4\u901a\u5e38\u662f 32768-60999&#xff09;<br \/>\nsysctl -w net.ipv4.ip_local_port_range&#061;&#034;1024 65535&#034;<\/p>\n<p>\u591a\u8fdb\u7a0b\/\u591a\u673a\u538b\u6d4b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb983\u6b21\uff0c\u70b9\u8d5e20\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u8bbe\u8ba1\u7ec6\u8282\u548c\u5b9e\u73b0\u7ec6\u8282\uff0c\u4ee5\u53ca\u6d4b\u8bd5\u8fed\u4ee3<\/p>\n","protected":false},"author":2,"featured_media":30884,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2478,55],"topic":[],"class_list":["post-30902","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-2025-c","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5 - \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\/30902.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb983\u6b21\uff0c\u70b9\u8d5e20\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u8bbe\u8ba1\u7ec6\u8282\u548c\u5b9e\u73b0\u7ec6\u8282\uff0c\u4ee5\u53ca\u6d4b\u8bd5\u8fed\u4ee3\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/30902.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-20T21:11:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211105-680562e9ddf4c.png\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/30902.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/30902.html\",\"name\":\"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-20T21:11:11+00:00\",\"dateModified\":\"2025-04-20T21:11:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/30902.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/30902.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/30902.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5\"}]},{\"@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":"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5 - \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\/30902.html","og_locale":"zh_CN","og_type":"article","og_title":"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb983\u6b21\uff0c\u70b9\u8d5e20\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u8bbe\u8ba1\u7ec6\u8282\u548c\u5b9e\u73b0\u7ec6\u8282\uff0c\u4ee5\u53ca\u6d4b\u8bd5\u8fed\u4ee3","og_url":"https:\/\/www.wsisp.com\/helps\/30902.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-20T21:11:11+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420211105-680562e9ddf4c.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/30902.html","url":"https:\/\/www.wsisp.com\/helps\/30902.html","name":"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-20T21:11:11+00:00","dateModified":"2025-04-20T21:11:11+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/30902.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/30902.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/30902.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"c++\u9879\u76ee \u7f51\u7edc\u804a\u5929\u670d\u52a1\u5668 \u5b9e\u73b0\uff1bQPS\u6d4b\u8bd5"}]},{"@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\/30902","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=30902"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/30902\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/30884"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=30902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=30902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=30902"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=30902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}