{"id":92636,"date":"2020-03-15T16:48:35","date_gmt":"2020-03-15T08:48:35","guid":{"rendered":"http:\/\/4563.org\/?p=92636"},"modified":"2020-03-15T16:48:35","modified_gmt":"2020-03-15T08:48:35","slug":"%e7%94%a8%e4%ba%86-swoole%ef%bc%8c%e8%af%b7%e6%b1%82%e6%9c%89%e6%97%b6%e5%80%99-600-%e5%a4%9a-ms-%ef%bc%8c%e5%a6%82%e4%bd%95%e4%bc%98%e5%8c%96%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=92636","title":{"rendered":"\u7528\u4e86 Swoole\uff0c\u8bf7\u6c42\u6709\u65f6\u5019 600 \u591a ms \uff0c\u5982\u4f55\u4f18\u5316\u5462\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u7528\u4e86 Swoole\uff0c\u8bf7\u6c42\u6709\u65f6\u5019 600 \u591a ms \uff0c\u5982\u4f55\u4f18\u5316\u5462\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : baoshu <\/span>  <span><i><\/i> 81<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>Swoole \u4ee3\u7801\u5982\u4e0b\uff0c\u4ec5\u4ec5\u662f\u8f93\u51fa\u4e86 Hello World<\/p>\n<pre><code>\/\/\u521b\u5efa Server \u5bf9\u8c61\uff0c\u76d1\u542c 127.0.0.1:9501 \u7aef\u53e3 $serv = new SwooleServer(\"127.0.0.1\", 9501);   \/\/\u76d1\u542c\u8fde\u63a5\u8fdb\u5165\u4e8b\u4ef6 $serv-&gt;on('Connect', function ($serv, $fd) {       echo \"Client: Connect.n\"; });  \/\/\u76d1\u542c\u6570\u636e\u63a5\u6536\u4e8b\u4ef6 $serv-&gt;on('Receive', function ($serv, $fd, $from_id, $data) {     $serv-&gt;send($fd, \"Server: \".$data); });  \/\/\u76d1\u542c\u8fde\u63a5\u5173\u95ed\u4e8b\u4ef6 $serv-&gt;on('Close', function ($serv, $fd) {     echo \"Client: Close.n\"; });  \/\/\u542f\u52a8\u670d\u52a1\u5668 $serv-&gt;start();  <\/code><\/pre>\n<p>\u7136\u540e\u7528\u6d4f\u89c8\u5668\u67e5\u770b\u8bf7\u6c42\u8017\u65f6\uff0c\u53d1\u73b0\u5927\u90e8\u5206\u662f 60ms \u5de6\u53f3\u3002\u4f46\u662f\u6709\u65f6\u5019\u9ad8\u8fbe 600 \u591a ms\uff0c\u592a\u4e0d\u6b63\u5e38\u7684\u3002 \u8bbf\u95ee\u662f\u7528\u5916\u7f51 IP+\u7aef\u53e3\uff0c\u8bbf\u95ee\u7684\u3002 \u670d\u52a1\u5668\u7528\u7684\u817e\u8baf\u4e91\uff0c\u7cfb\u7edf\u662f Linux CentOS\u3002<\/p>\n<p>RT\uff1a <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200519_5ec44901af8be.png\" alt=\"\u7528\u4e86 Swoole\uff0c\u8bf7\u6c42\u6709\u65f6\u5019 600 \u591a ms \uff0c\u5982\u4f55\u4f18\u5316\u5462\uff1f\" \/><\/p>\n<p>\u6709\u6ca1\u6709\u5927\u4f6c\u77e5\u9053\u5982\u4f55\u4f18\u5316\u7684\u54c8\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"957868\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : baoshu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u670d\u52a1\u5668\u662f 1 \u6838 2G \u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957869\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iamfirst <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u548c\u7f51\u7edc\u73af\u5883\u6709\u5173\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957870\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : eryueyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u67e5\u670d\u52a1\u5668\u6027\u80fd\u5360\u7528\uff0c\u7f51\u7edc\u73af\u5883                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957871\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : KasuganoSoras <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8d34\u7684\u8fd9\u6bb5\u4ee3\u7801\u548c\u4f60\u622a\u56fe\u91cc\u7684\u6839\u672c\u4e0d\u4e00\u6837\u5427\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957872\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : baoshu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @KasuganoSoras <br \/>\u786e\u5b9e\u662f<\/p>\n<p>~~~<br \/>&lt;?php<br \/>$http = new swoole_http_server(&#8220;0.0.0.0&#8221;, 9501);<\/p>\n<p>$http-&gt;on(&#8220;start&#8221;, function ($server) {<br \/> echo &#8220;Swoole http server is started at http:\/\/127.0.0.1:9501n&#8221;;<br \/>});<\/p>\n<p>$http-&gt;on(&#8220;request&#8221;, function ($request, $response) {<br \/> $response-&gt;header(&#8220;Content-Type&#8221;, &#8220;text\/plain&#8221;);<br \/> $response-&gt;end(&#8220;Hello Worldn&#8221;);<br \/>});<\/p>\n<p>$http-&gt;start();<br \/>~~~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957873\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : baoshu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @eryueyu @iamfirst <br \/>\u5927\u90e8\u5206\u65f6\u5019\u90fd\u662f 30-60ms\uff0c\u6781\u5c11\u6570\u60c5\u51b5\u662f 600ms \u5de6\u53f3\u3002\uff08\u51fa\u73b0\u9891\u7387\u53ef\u80fd\u662f 30\/1 \u6837\u5f0f\uff0c\u4e0d\u56fa\u5b9a\uff09<br \/>\u770b\u4e86 CPU \u5185\u5b58\u548c\u7f51\u7edc\u90fd\u6b63\u5e38\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957874\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : KasuganoSoras <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @baoshu #6 \u90a3\u5927\u6982\u5c31\u662f\u673a\u5668\u6027\u80fd\u6216\u8005\u7f51\u7edc\u95ee\u9898\u4e86\uff0c\u817e\u8baf\u4e91\u5e94\u8be5\u548c\u963f\u91cc\u4e91\u4e00\u6837\u4f1a\u538b\u5236\u4f4e\u914d\u673a\u5668\u6027\u80fd\u7684\u2026\u2026\u4e0d\u8fc7\u6211\u89c9\u5f97\u66f4\u5927\u7684\u53ef\u80fd\u662f\u56e0\u4e3a\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u8bd5\u4e0b\u5728\u670d\u52a1\u5668\u4e0a\u7528 ab \u6216\u8005 wrk \u81ea\u884c\u538b\u6d4b\u4e00\u4e0b\u770b\u770b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"957875\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iamfirst <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u672c\u5730\u73af\u5883\u548c\u7f51\u7edc\u4e00\u822c\u6bd4\u8f83\u7a33\u5b9a\uff0c\u53ef\u4ee5\u5728\u672c\u5730\u7528 ab \u6d4b\u8bd5\u6570\u5343\u767e\u6b21\uff0c\u5982\u679c\u672c\u5730\u7684\u6d4b\u8bd5\u7ed3\u679c\u6bd4\u8f83\u7a33\u5b9a\uff0c\u76f8\u5dee\u4e0d\u5927\u3002\u5c31\u57fa\u672c\u53ef\u4ee5\u786e\u5b9a\u662f\u817e\u8baf\u4e91\u7684\u7f51\u7edc\u73af\u5883\u95ee\u9898\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u7528\u4e86 Swoole\uff0c\u8bf7\u6c42\u6709\u65f6\u5019 6&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/92636"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=92636"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/92636\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92636"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}