{"rsdb":{"rid":"301055","subhead":"","postdate":"0","aid":"216409","fid":"78","uid":"1","topic":"1","content":"
\n

\u641c\u7d22\u4e1a\u52a1\u662f\u9a6c\u8702\u7a9d\u6d41\u91cf\u5206\u53d1\u7684\u91cd\u8981\u5165\u53e3\u3002\u5f88\u591a\u7528\u6237\u5728\u4f7f\u7528\u9a6c\u8702\u7a9d\u65f6\uff0c\u90fd\u4f1a\u6709\u76ee\u7684\u6027\u5730\u4e3b\u52a8\u641c\u7d22\u4e0e\u81ea\u5df1\u65c5\u884c\u9700\u6c42\u76f8\u5173\u7684\u5404\u79cd\u4fe1\u606f\uff0c\u8863\u98df\u4f4f\u884c\uff0c\u4e8b\u65e0\u5de8\u7ec6\uff0c\u4ece\u800c\u505a\u51fa\u6700\u7b26\u5408\u9700\u6c42\u7684\u65c5\u884c\u51b3\u7b56\u3002<\/p> \n

\u56e0\u6b64\u5728\u9a6c\u8702\u7a9d\uff0c\u641c\u7d22\u4e1a\u52a1\u4ea4\u4e92\u7684\u4e0b\u6e38\u6a21\u5757\u975e\u5e38\u591a\uff0c\u4e3b\u8981\u6709\u76ee\u7684\u5730\u3001POI\u3001\u70ed\u95e8\u666f\u70b9\u3001\u7f8e\u98df\u3001\u5546\u573a\u3001\u9152\u5e97\u3001\u95ee\u7b54\u3001\u653b\u7565\u3001\u673a\u7968\u706b\u8f66\u7968\u7b49\u7b49\uff0c\u901a\u8fc7\u5b9e\u65f6\u3001\u7cbe\u51c6\u5730\u8fd4\u56de\u641c\u7d22\u7ed3\u679c\uff0c\u5e2e\u52a9\u7528\u6237\u505a\u51fa\u4e2a\u6027\u5316\u65c5\u884c\u51b3\u7b56\u3002<\/p> \n

\u9762\u5bf9\u8d8a\u6765\u8d8a\u9ad8\u7684\u6d41\u91cf\uff0c\u9a6c\u8702\u7a9d\u6280\u672f\u56e2\u961f\u79ef\u6781\u5c1d\u8bd5\u5bf9\u641c\u7d22\u67b6\u6784\u8fdb\u884c\u4f18\u5316\u548c\u5347\u7ea7\uff0c\u6765\u4fdd\u8bc1\u641c\u7d22\u4e1a\u52a1\u7684\u7a33\u5b9a\u548c\u6027\u80fd\u3002<\/p> \n

 <\/p> \n

\u65b9\u6848\u80cc\u666f<\/h2> \n

\u7531\u4e8e\u5386\u53f2\u539f\u56e0\uff0c\u4f18\u5316\u524d\u7684\u641c\u7d22\u670d\u52a1\u4e0e\u4e0b\u6e38\u6a21\u5757\u4ea4\u7684\u4e92\u65b9\u5f0f\u4e3b\u8981\u4e3a\u8c03\u7528\u5404\u4e0b\u6e38\u6a21\u5757\u63d0\u4f9b\u7684\u51fd\u6570\uff0c\u5e76\u4e14\u91c7\u7528\u4e32\u884c\u8c03\u7528\u3002<\/p> \n

\"\"<\/p> \n

\u56fe 1: \u9a6c\u8702\u7a9d\u641c\u7d22\u4e1a\u52a1\u67b6\u6784\u548c\u6280\u672f\u4f53\u7cfb<\/strong><\/p> \n

 <\/p> \n

\u641c\u7d22\u6280\u672f\u4f53\u7cfb<\/h3> \n
    \n
  • \u5b58\u50a8\u2014\u2014MySQL\u3001Memcache<\/p> <\/li> \n

  • \u6a21\u5757\u4ea4\u4e92\u2014\u2014Function Call<\/p> <\/li> \n

  • \u68c0\u7d22\u2014\u2014Elasticsearch<\/p> <\/li> \n <\/ul> \n

    \u641c\u7d22\u4e1a\u52a1\u67b6\u6784<\/h3> \n

    \u6211\u4eec\u5c06\u641c\u7d22\u4e1a\u52a1\u62bd\u8c61\u4e3a\u4e09\u4e2a\u529f\u80fd\u6a21\u5757:<\/p> \n

    1. \u51b3\u7b56\u7cfb\u7edf<\/strong><\/p> \n

    \u8d1f\u8d23\u6839\u636e\u7528\u6237\u610f\u56fe\u3001\u8fd0\u8425\u7b56\u7565\u3001\u70b9\u51fb\u65e5\u5fd7\u7b49\u6570\u636e\uff0c\u7ed3\u5408\u51b3\u7b56\u7cfb\u7edf\u76f8\u5173\u7b97\u6cd5\u548c\u6a21\u578b\uff0c\u51b3\u7b56\u5e94\u8be5\u5c55\u793a\u54ea\u4e9b\u6a21\u5757\uff08\u6e38\u8bb0\u3001\u5546\u54c1\u7b49\uff09\u53ca\u5404\u6a21\u5757\u5c55\u793a\u987a\u5e8f\u3002<\/p> \n

    2. Agent<\/strong><\/p> \n

    \u8d1f\u8d23\u6839\u636e\u51b3\u7b56\u7cfb\u7edf\u786e\u5b9a\u8981\u5c55\u793a\u7684\u6a21\u5757\uff0c\u4ece Elasticsearch \u548c\u4e1a\u52a1\u65b9\u83b7\u53d6\u6a21\u5757\uff08\u5982\u6e38\u8bb0\u3001\u5546\u54c1\u7b49\uff09\u6570\u636e\u3002<\/p> \n

    3. Format<\/strong><\/p> \n

    \u8d1f\u8d23\u6839\u636e\u4e0d\u540c\u6a21\u5757\u7684 UI \u4ea4\u4e92\u5b9a\u4e49\u683c\u5f0f\u5316\u6570\u636e\uff0c\u8865\u5145 UI \u4ea4\u4e92\u7f3a\u5931\u6570\u636e\u3002<\/p> \n

    \u4e32\u884c\u7684\u51fd\u6570\u7ea7\u8c03\u7528\u65b9\u5f0f\uff0c\u4f7f\u4e4b\u524d\u7684\u641c\u7d22\u670d\u52a1\u67b6\u6784\u5b58\u5728\u4e00\u7cfb\u5217\u95ee\u9898\uff1a<\/p> \n

      \n
    • \u4e1a\u52a1\u95f4\u8026\u5408\u5ea6\u9ad8\u3002\u968f\u7740\u4ea4\u4e92\u6a21\u5757\u8d8a\u6765\u8d8a\u591a\uff0c\u5bfc\u81f4\u641c\u7d22\u670d\u52a1\u8017\u65f6\u53d8\u5f97\u5f88\u957f\uff0c\u5e73\u5747\u8fbe\u5230 400-500 ms\uff1b<\/p> <\/li> \n

    • \u7531\u4e8e\u4e0e\u5404\u4e1a\u52a1\u95f4\u4ea4\u4e92\u7684\u65b9\u5f0f\u662f Function Call\uff0c\u4f7f\u4e0a\u6e38\u5f88\u96be\u63a7\u5236\u4e0b\u6e38\u6a21\u5757\u963b\u585e\u65f6\u95f4\uff1b<\/p> <\/li> \n

    • \u4e0b\u6e38\u8c03\u7528\u589e\u52a0\u54cd\u5e94\u65f6\u95f4\u76f8\u5e94\u5448\u7ebf\u6027\u589e\u957f\uff0c\u4f7f\u5176\u5f88\u96be\u518d\u53e0\u52a0\u65b0\u7684\u529f\u80fd\uff0c\u53ef\u6269\u5c55\u6027\u5dee\uff1b<\/p> <\/li> \n

    • \u5982\u679c\u4e0b\u6e38\u6a21\u5757\u51fa\u73b0\u6545\u969c\uff0c\u4f1a\u7531\u4e8e\u63a5\u53e3\u963b\u585e\u5f15\u8d77\u8d85\u65f6\uff0c\u5bfc\u81f4\u641c\u7d22\u670d\u52a1\u6574\u4f53\u90fd\u53d7\u5230\u5f71\u54cd\uff0c\u8868\u73b0\u51fa\u767d\u9875\uff0c\u7528\u6237\u4f53\u9a8c\u4e25\u91cd\u4e0b\u964d\u3002<\/p> <\/li> \n <\/ul> \n

      \"\"<\/p> \n

      \u56fe 2:\u95ee\u9898\u5206\u6790<\/strong><\/p> \n

       <\/p> \n

      \u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u627e\u5230\u4e00\u79cd\u65b9\u5f0f\u6765\u964d\u4f4e\u641c\u7d22\u670d\u52a1\u5bf9\u4e8e\u4e0b\u6e38\u6a21\u5757\u7684\u4f9d\u8d56\uff0c\u4ee5\u53ca\u6a21\u5757\u95f4\u7684\u8026\u5408\uff0c\u4ece\u800c\u63d0\u5347\u67b6\u6784\u7684\u6574\u4f53\u53ef\u7528\u6027\u548c\u6027\u80fd\u3002<\/p> \n

       <\/h2> \n

      \u57fa\u4e8e Golang \u7684\u5e76\u53d1\u4ee3\u7406\u5b9e\u73b0<\/h2> \n

      \u7ecf\u8fc7\u8c03\u7814\uff0c\u6211\u4eec\u5f00\u53d1\u4e86\u57fa\u4e8e Golang \u534f\u7a0b\u5b9e\u73b0\u7684\u5e76\u53d1\u8bf7\u6c42\u4ee3\u7406\u5de5\u5177\uff0c\u5c06\u4e4b\u524d\u51fd\u6570\u7ea7\u8c03\u7528\u7684\u65b9\u5f0f\u53d8\u4e3a\u57fa\u4e8e TCP\/IP \u7684 HTTP \u63a5\u53e3\u8c03\u7528\u6765\u4e0e\u4e0b\u6e38\u6a21\u5757\u89e3\u8026\uff0c\u540c\u65f6\u5c06\u4e32\u884c\u8c03\u7528\u53d8\u4e3a\u5e76\u53d1\uff0c\u5b9e\u73b0\u8d85\u65f6\u63a7\u5236\u548c\u5f02\u5e38\u5bb9\u9519\u5904\u7406\u3002<\/p> \n

      \u4e3b\u8981\u6280\u672f\u9009\u578b\u2014\u2014\u534f\u7a0b(Goroutine)<\/h3> \n

      Goroutine \u662f Golang \u8f7b\u91cf\u7ea7\u7ebf\u7a0b\u5b9e\u73b0\uff0c\u7531 Go runtime \u7ba1\u7406\u3002\u5b83\u662f Go \u5e76\u884c\u8bbe\u8ba1\u7684\u6838\u5fc3\uff0c\u4e5f\u662f Golang \u6700\u91cd\u8981\u7684\u7279\u6027\u4e4b\u4e00\uff0c\u76f8\u6bd4\u4e8e\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u4efb\u52a1\u7684\u62a2\u5360\u5f0f\u8c03\u5ea6\uff0c\u9700\u8981\u9891\u7e41\u8fdb\u884c\u4e0a\u4e0b\u6587\u4fe1\u606f\u7684\u5185\u6838\u548c\u7528\u6237\u7a7a\u95f4\u5207\u6362\uff0cGoroutine \u53ef\u4ee5\u7531\u7a0b\u5e8f\u63a7\u5236\uff0c\u4f7f\u5f97\u5b83\u66f4\u6613\u7528\u3001\u66f4\u9ad8\u6548\u3001\u66f4\u8f7b\u4fbf\u3002<\/p> \n

      Goroutine \u7ef4\u62a4\u4e86\u4e00\u7ec4\u6570\u636e\u7ed3\u6784\u548c\u591a\u4e2a\u7ebf\u7a0b\uff0c\u4efb\u52a1\u653e\u5728\u4e00\u4e2a\u5f85\u6267\u884c\u961f\u5217\u4e2d\uff0c\u7531 Goroutine \u7ef4\u62a4\u7684\u7ebf\u7a0b\u6765\u62c9\u53d6\u6267\u884c\u3002\u5f53\u4efb\u52a1\u6267\u884c\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684 IO \u64cd\u4f5c\u7b49\u9700\u8981\u7b49\u5f85\u65f6\uff0cGoroutine \u5229\u7528 Linux IO \u591a\u8def\u590d\u7528\u6280\u672f (Epoll\u3001Select) \u8fdb\u884c\u6267\u884c\u961f\u5217\u7684\u4efb\u52a1\u5207\u6362\u6765\u5b9e\u73b0\u5e76\u53d1\u3002<\/p> \n

      \u76f8\u6bd4\u4e8e\u5176\u4ed6\u8bed\u8a00\u7684\u7ebf\u7a0b\uff0c\u5176\u9ed8\u8ba4\u5360\u7528\u5185\u5b58\u4e3a 2KB, \u8fdc\u5c0f\u4e8e\u5176\u4ed6\u8bed\u8a00\u7684 M \u7ea7\u522b\u3002\u5728\u6027\u80fd\u5f00\u9500\u65b9\u9762\uff0c\u7531\u4e8e\u4efb\u52a1\u8c03\u5ea6\u57fa\u672c\u6709\u7a0b\u5e8f\u63a7\u5236\uff0c\u5f00\u9500\u4e5f\u8fdc\u5c0f\u4e8e\u7ebf\u7a0b\u3002<\/p> \n

      \u9009\u578b\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5bf9\u6bd4\u4e86 PHP \u7684 Swoole\u3001Java \u591a\u7ebf\u7a0b\u5e76\u884c\u5904\u7406\u65b9\u6848\uff0c\u5b83\u4eec\u7684 CPU \u548c\u5185\u5b58\u6d88\u8017\u6bd4 Golang \u7684 Goroutine \u8981\u9ad8\u51fa\u5f88\u591a\uff0c\u5e76\u4e14\u5e76\u884c\u8bf7\u6c42\u6570\u91cf\u4f1a\u53d7\u5230\u8d44\u6e90\u7684\u9650\u5236\uff0c\u5728\u9ad8\u5e76\u53d1\u7684\u60c5\u51b5\u4e0b\u5982\u679c\u63a7\u5236\u4e0d\u5f53\u4f1a\u5bfc\u81f4\u670d\u52a1\u5d29\u6e83\u3002\u800c\u4f7f\u7528 Goroutine \u5b9e\u73b0\u7684\u5e76\u53d1\u4ee3\u7406\uff0c\u53ef\u4ee5\u8f7b\u677e\u652f\u6301\u5343\u4e07\u7ea7\u522b\u7684\u5e76\u53d1\u8bf7\u6c42\u3002<\/p> \n

      \"\"<\/p> \n

      \u56fe 3:\u5e76\u884c\u4e0e\u5e76\u53d1<\/strong><\/p> \n

       <\/p> \n

      Golang \u5e76\u53d1\u4ee3\u7406\u5b9e\u73b0<\/h3> \n

      \u4ee3\u7406\u670d\u52a1\u6309\u8bf7\u6c42\u7684\u5904\u7406\u6d41\u7a0b\uff0c\u53ef\u4ee5\u5212\u5206\u4e3a HTTP Server \u2014\u2014> \u53c2\u6570\u5904\u7406\u2014\u2014> \u5e76\u884c\u8bf7\u6c42 (\u534f\u7a0b\u8c03\u5ea6\uff09\u2014\u2014> HTTP \u6a21\u5757 \u2014\u2014> API \u5c42\u3002\u76ee\u524d\u6211\u4eec\u7684\u65b9\u6848\u652f\u6301 HTTP\/HTTPS \u534f\u8bae\u7684\u8bf7\u6c42\u3002<\/p> \n

      \"\"<\/p> \n

      \u56fe 4:\u5e76\u53d1\u4ee3\u7406\u67b6\u6784\u56fe<\/strong><\/p> \n

       <\/p> \n

      \u5404\u6a21\u5757\u529f\u80fd\u6982\u8981<\/strong>\uff1a<\/p> \n

        \n
      1. HTTP Sever<\/strong>\uff1a\u4f7f\u7528 Go \u8bed\u8a00 httpserver package \u5b9e\u73b0\uff0c\u7528\u4e8e\u63a5\u6536\u548c\u5904\u7406\u6709\u4ee3\u7406\u9700\u6c42\u7684\u4e0a\u6e38\u6a21\u5757\u7684 HTTP \u8bf7\u6c42\uff1b<\/p> <\/li> \n

      2. \u53c2\u6570\u5904\u7406<\/strong>\uff1a\u6839\u636e\u5b9a\u4e49\u597d\u7684\u4ea4\u4e92\u534f\u8bae\uff0c\u5c06\u4e0a\u6e38\u6a21\u5757\u7684\u8bf7\u6c42\u89e3\u6790\u4e3a\u5e76\u884c\u8bf7\u6c42\u5546\u54c1\u3001\u6e38\u8bb0\u7b49\u4e0b\u6e38\u6a21\u5757\u7684\u8bf7\u6c42\u4efb\u52a1\uff1b<\/p> <\/li> \n

      3. \u534f\u7a0b\u8c03\u5ea6<\/strong>\uff1a\u4f7f\u7528 Go \u8bed\u8a00\u7684 Goroutine \u5b9e\u73b0\uff0c\u8d1f\u8d23\u6267\u884c\u5bf9\u4e0b\u6e38\u6a21\u5757\u7684\u5e76\u53d1\u8bf7\u6c42\u4efb\u52a1\uff1b<\/p> <\/li> \n

      4. HTTP \u6a21\u5757<\/strong>\uff1a\u4f7f\u7528 Go \u8bed\u8a00\u7684 ioutil\/http package \u5b9e\u73b0\uff0c\u8d1f\u8d23\u4e0e\u4e0b\u6e38 API \u6a21\u5757\u4ee5 HTTP \u534f\u8bae\u5f62\u5f0f\u4ea4\u4e92\uff1b<\/p> <\/li> \n

      5. API \u6a21\u5757<\/strong>\uff1a\u5c06\u4e0b\u6e38\u6a21\u5757\u7684\u51fd\u6570\u8c03\u7528\u5c01\u88c5\u4e3a TCP\/IP\u63a5\u53e3\uff0c\u5c06\u51fd\u6570\u5f62\u5f0f\u4ea4\u4e92\u53d8\u4e3a HTTP \u63a5\u53e3\u5f62\u5f0f\u4ea4\u4e92\u3002<\/p> <\/li> \n <\/ol> \n

        \u641c\u7d22\u4e1a\u52a1\u5e94\u7528\u4ee3\u7406\u540e\uff0c\u6574\u4f53\u67b6\u6784\u53d8\u5316\u4e3a\uff1a<\/p> \n

        \"\"<\/p> \n

        \u56fe 5:\u5e76\u53d1\u4ee3\u7406\u5728\u641c\u7d22\u4e1a\u52a1\u4e2d\u7684\u5e94\u7528<\/strong><\/p> \n

         <\/p> \n

        \u5c0f\u7ed3\u4e0e\u540e\u7eed\u89c4\u5212<\/strong><\/h2> \n

        \u57fa\u4e8e Golang \u7684\u5e76\u53d1\u4ee3\u7406\u5728\u9a6c\u8702\u7a9d\u641c\u7d22\u4e1a\u52a1\u4e2d\u5df2\u7ecf\u4f7f\u7528\u4e86\u4e00\u6bb5\u65f6\u95f4\uff0c\u5f88\u597d\u5730\u89e3\u51b3\u4e86\u4e4b\u524d\u5b58\u5728\u7684\u4e00\u4e9b\u95ee\u9898\u3002\u76ee\u524d\uff0c\u641c\u7d22\u670d\u52a1\u5e73\u5747\u8017\u65f6\u5df2\u7ecf\u964d\u4f4e\u5230240ms \u5de6\u53f3\uff0c\u67b6\u6784\u7684\u53ef\u7528\u6027\u548c\u53ef\u6269\u5c55\u6027\u4e5f\u5f97\u5230\u5f88\u5927\u63d0\u5347\uff0c\u5e76\u4e14\u6709\u6548\u63d0\u9ad8\u4e86\u7cfb\u7edf\u8d44\u6e90\u7684\u5229\u7528\u7387\u3002<\/p> \n

        \u73b0\u5728\u5e76\u53d1\u4ee3\u7406\u53ea\u652f\u6301 HTTP\uff0c\u540e\u7eed\u4f1a\u589e\u52a0 RPC\uff0c\u6765\u66f4\u597d\u5730\u652f\u6301\u6574\u4f53\u7684\u670d\u52a1\u5316\u6539\u9020\u3002\u5728\u63a8\u8fdb\u548c\u5b9e\u65bd\u641c\u7d22\u67b6\u6784\u5347\u7ea7\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4e5f\u4f1a\u628a\u66f4\u591a\u7684\u7ecf\u9a8c\u5206\u4eab\u51fa\u6765\uff0c\u5e0c\u671b\u5927\u5bb6\u6301\u7eed\u5173\u6ce8\u3002<\/p> \n

        \u672c\u6587\u4f5c\u8005<\/strong>\uff1a\u738b\u6c5f\u6d9b\uff0c\u9a6c\u8702\u7a9d\u641c\u7d22\u63a8\u8350\u7814\u53d1\u5de5\u7a0b\u5e08\u3002<\/p> \n

         <\/p> \n

        \u5173\u6ce8\u9a6c\u8702\u7a9d\u6280\u672f\uff0c\u627e\u5230\u66f4\u591a\u4f60\u60f3\u8981\u7684\u5185\u5bb9<\/p> \n

        \"\"<\/p>\n<\/div>","orderid":"0","title":"\u9a6c\u8702\u7a9d\u641c\u7d22\u57fa\u4e8e Golang \u5e76\u53d1\u4ee3\u7406\u7684\u4e00\u6b21\u67b6\u6784\u5347\u7ea7","smalltitle":"","mid":"0","fname":"GO","special_id":"0","bak_id":"0","info":"0","hits":"197","pages":"1","comments":"0","posttime":"2019-03-29 16:08:47","list":"1553846927","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u9a6c\u8702\u7a9d<\/A> \u641c\u7d22<\/A> \u57fa\u4e8e<\/A> Golang<\/A> \u5e76\u53d1<\/A> \u4ee3\u7406<\/A> \u4e00\u6b21<\/A> \u67b6\u6784<\/A> \u5347\u7ea7<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"47.106.78.186","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u9a6c\u8702\u7a9d\u641c\u7d22\u57fa\u4e8e Golang \u5e76\u53d1\u4ee3\u7406\u7684\u4e00\u6b21\u67b6\u6784\u5347\u7ea7","lastview":"1713509242","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}