{"id":51035,"date":"2024-10-08T15:35:17","date_gmt":"2024-10-08T07:35:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/51035\/"},"modified":"2024-10-08T15:35:17","modified_gmt":"2024-10-08T07:35:17","slug":"%e3%80%8anginx-%e7%af%87-%e5%85%ad%e3%80%8bnginx-%e4%bc%ba%e6%9c%8d%e5%99%a8%e4%b8%8a%e7%9a%84-master-%e5%92%8c-worker-%e9%80%b2%e7%a8%8b%e5%88%86%e5%88%a5%e6%98%af%e4%bb%80%e9%ba%bc%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/51035\/","title":{"rendered":"\u300aNginx \u7bc7 \u516d\u300bNginx \u4f3a\u670d\u5668\u4e0a\u7684 Master \u548c Worker \u9032\u7a0b\u5206\u5225\u662f\u4ec0\u9ebc\uff1f"},"content":{"rendered":"<h1 id=\"%e3%80%8anginx-%e7%af%87-%e5%85%ad%e3%80%8bnginx-%e4%bc%ba%e6%9c%8d%e5%99%a8%e4%b8%8a%e7%9a%84-master-%e5%92%8c-worker-%e9%80%b2%e7%a8%8b%e5%88%86%e5%88%a5%e6%98%af%e4%bb%80%e9%ba%bc%ef%bc%9f-EulVyjHtfD\">\u300aNginx \u7bc7 \u516d\u300bNginx \u4f3a\u670d\u5668\u4e0a\u7684 Master \u548c Worker \u9032\u7a0b\u5206\u5225\u662f\u4ec0\u9ebc\uff1f<\/h1>\n<p>Nginx \u662f\u4e00\u6b3e\u9ad8\u6548\u80fd\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u975c\u614b\u5167\u5bb9\u7684\u63d0\u4f9b\u3001\u53cd\u5411\u4ee3\u7406\u3001\u8ca0\u8f09\u5747\u8861\u7b49\u591a\u7a2e\u5834\u666f\u3002\u5728 Nginx \u7684\u67b6\u69cb\u4e2d\uff0cMaster \u548c Worker \u9032\u7a0b\u626e\u6f14\u8457\u81f3\u95dc\u91cd\u8981\u7684\u89d2\u8272\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u5169\u7a2e\u9032\u7a0b\u7684\u529f\u80fd\u53ca\u5176\u904b\u4f5c\u65b9\u5f0f\u3002<\/p>\n<h2 id=\"master-%e9%80%b2%e7%a8%8b%e7%9a%84%e5%8a%9f%e8%83%bd-EulVyjHtfD\">Master \u9032\u7a0b\u7684\u529f\u80fd<\/h2>\n<p>Master \u9032\u7a0b\u662f Nginx \u7684\u6838\u5fc3\uff0c\u8ca0\u8cac\u7ba1\u7406\u6574\u500b\u4f3a\u670d\u5668\u7684\u904b\u884c\u3002\u5176\u4e3b\u8981\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u555f\u52d5\u548c\u505c\u6b62 Worker \u9032\u7a0b\uff1a<\/strong>Master \u9032\u7a0b\u8ca0\u8cac\u555f\u52d5\u3001\u505c\u6b62\u548c\u91cd\u555f Worker \u9032\u7a0b\u3002\u7576 Nginx \u555f\u52d5\u6642\uff0cMaster \u9032\u7a0b\u6703\u5275\u5efa\u4e00\u500b\u6216\u591a\u500b Worker \u9032\u7a0b\u3002<\/li>\n<li><strong>\u914d\u7f6e\u7ba1\u7406\uff1a<\/strong>Master \u9032\u7a0b\u6703\u8b80\u53d6 Nginx \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4e26\u6839\u64da\u914d\u7f6e\u555f\u52d5\u76f8\u61c9\u7684 Worker \u9032\u7a0b\u3002<\/li>\n<li><strong>\u4fe1\u865f\u8655\u7406\uff1a<\/strong>Master \u9032\u7a0b\u80fd\u5920\u63a5\u6536\u548c\u8655\u7406\u7cfb\u7d71\u4fe1\u865f\uff0c\u4f8b\u5982\u91cd\u8f09\u914d\u7f6e\u6587\u4ef6\u6216\u5e73\u6ed1\u91cd\u555f\u3002<\/li>\n<\/ul>\n<p>Master \u9032\u7a0b\u672c\u8eab\u4e0d\u8655\u7406\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\uff0c\u800c\u662f\u5c08\u6ce8\u65bc\u7ba1\u7406\u548c\u5354\u8abf Worker \u9032\u7a0b\u7684\u904b\u884c\u3002<\/p>\n<h2 id=\"worker-%e9%80%b2%e7%a8%8b%e7%9a%84%e5%8a%9f%e8%83%bd-EulVyjHtfD\">Worker \u9032\u7a0b\u7684\u529f\u80fd<\/h2>\n<p>Worker \u9032\u7a0b\u662f Nginx \u5be6\u969b\u8655\u7406\u8acb\u6c42\u7684\u90e8\u5206\u3002\u6bcf\u500b Worker \u9032\u7a0b\u90fd\u80fd\u5920\u7368\u7acb\u8655\u7406\u591a\u500b\u8acb\u6c42\uff0c\u9019\u4f7f\u5f97 Nginx \u80fd\u5920\u9ad8\u6548\u5730\u8655\u7406\u5927\u91cf\u7684\u4e26\u767c\u9023\u63a5\u3002Worker \u9032\u7a0b\u7684\u4e3b\u8981\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u8acb\u6c42\u8655\u7406\uff1a<\/strong>Worker \u9032\u7a0b\u8ca0\u8cac\u63a5\u6536\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\uff0c\u4e26\u6839\u64da\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u6307\u4ee4\u9032\u884c\u76f8\u61c9\u7684\u8655\u7406\uff0c\u4f8b\u5982\u63d0\u4f9b\u975c\u614b\u6587\u4ef6\u6216\u8f49\u767c\u8acb\u6c42\u5230\u5f8c\u7aef\u4f3a\u670d\u5668\u3002<\/li>\n<li><strong>\u9023\u63a5\u7ba1\u7406\uff1a<\/strong>\u6bcf\u500b Worker \u9032\u7a0b\u90fd\u80fd\u5920\u7ba1\u7406\u591a\u500b\u9023\u63a5\uff0c\u9019\u662f\u901a\u904e\u4e8b\u4ef6\u9a45\u52d5\u6a21\u578b\u5be6\u73fe\u7684\u3002Nginx \u4f7f\u7528\u975e\u963b\u585e I\/O \u4f86\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li><strong>\u65e5\u8a8c\u8a18\u9304\uff1a<\/strong>Worker \u9032\u7a0b\u8ca0\u8cac\u8a18\u9304\u8acb\u6c42\u7684\u65e5\u8a8c\u4fe1\u606f\uff0c\u9019\u5c0d\u65bc\u5f8c\u7e8c\u7684\u6545\u969c\u6392\u67e5\u548c\u6027\u80fd\u5206\u6790\u975e\u5e38\u91cd\u8981\u3002<\/li>\n<\/ul>\n<h2 id=\"master-%e5%92%8c-worker-%e9%80%b2%e7%a8%8b%e7%9a%84%e5%8d%94%e4%bd%9c-EulVyjHtfD\">Master \u548c Worker \u9032\u7a0b\u7684\u5354\u4f5c<\/h2>\n<p>Master \u548c Worker \u9032\u7a0b\u4e4b\u9593\u7684\u5354\u4f5c\u662f Nginx \u9ad8\u6548\u904b\u884c\u7684\u95dc\u9375\u3002\u7576\u5ba2\u6236\u7aef\u767c\u9001\u8acb\u6c42\u6642\uff0c\u8acb\u6c42\u9996\u5148\u7531 Master \u9032\u7a0b\u63a5\u6536\uff0c\u7136\u5f8c\u8f49\u767c\u7d66\u53ef\u7528\u7684 Worker \u9032\u7a0b\u9032\u884c\u8655\u7406\u3002\u9019\u7a2e\u8a2d\u8a08\u4f7f\u5f97 Nginx \u80fd\u5920\u5145\u5206\u5229\u7528\u591a\u6838 CPU \u7684\u512a\u52e2\uff0c\u5be6\u73fe\u9ad8\u6548\u7684\u8acb\u6c42\u8655\u7406\u3002<\/p>\n<p>\u6b64\u5916\uff0cNginx \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u53ef\u4ee5\u8a2d\u7f6e Worker \u9032\u7a0b\u7684\u6578\u91cf\uff0c\u901a\u5e38\u5efa\u8b70\u8a2d\u7f6e\u70ba\u8207 CPU \u6838\u5fc3\u6578\u76f8\u7b49\u6216\u7565\u591a\uff0c\u4ee5\u9054\u5230\u6700\u4f73\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u6307\u4ee4\uff1a<\/p>\n<pre><code>worker_processes auto;<\/code><\/pre>\n<p>\u9019\u6a23\uff0cNginx \u5c07\u81ea\u52d5\u6839\u64da\u7cfb\u7d71\u7684 CPU \u6838\u5fc3\u6578\u91cf\u4f86\u8a2d\u7f6e Worker \u9032\u7a0b\u7684\u6578\u91cf\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-EulVyjHtfD\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Nginx \u7684\u67b6\u69cb\u4e2d\uff0cMaster \u548c Worker \u9032\u7a0b\u5404\u81ea\u64d4\u4efb\u8457\u4e0d\u540c\u7684\u89d2\u8272\uff0c\u5354\u540c\u5de5\u4f5c\u4ee5\u5be6\u73fe\u9ad8\u6548\u7684\u8acb\u6c42\u8655\u7406\u3002Master \u9032\u7a0b\u8ca0\u8cac\u7ba1\u7406\u548c\u914d\u7f6e\uff0c\u800c Worker \u9032\u7a0b\u5247\u5c08\u6ce8\u65bc\u5be6\u969b\u7684\u8acb\u6c42\u8655\u7406\u3002\u4e86\u89e3\u9019\u4e9b\u9032\u7a0b\u7684\u904b\u4f5c\u65b9\u5f0f\uff0c\u5c0d\u65bc\u512a\u5316 Nginx \u7684\u6027\u80fd\u548c\u914d\u7f6e\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc Nginx \u7684\u904b\u884c\u548c\u914d\u7f6e\u6709\u9032\u4e00\u6b65\u7684\u9700\u6c42\uff0c\u6216\u662f\u9700\u8981\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u6b61\u8fce\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8cc7\u8a0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3 Nginx \u4f3a\u670d\u5668\u4e2d\u7684 Master \u548c Worker \u9032\u7a0b\u7684\u89d2\u8272\u8207\u529f\u80fd\uff0c\u63d0\u5347\u4f3a\u670d\u5668\u6027\u80fd\u8207\u7ba1\u7406\u6548\u7387\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-51035","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=51035"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51035\/revisions"}],"predecessor-version":[{"id":51036,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51035\/revisions\/51036"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=51035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=51035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=51035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}