{"id":198618,"date":"2020-08-24T08:09:20","date_gmt":"2020-08-24T00:09:20","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=198618"},"modified":"2020-08-19T17:10:03","modified_gmt":"2020-08-19T09:10:03","slug":"load-balance","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/load-balance.html","title":{"rendered":"\u7b80\u8ff0\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8d1f\u8f7d\u5747\u8861\u5efa\u7acb\u5728\u73b0\u6709\u7f51\u7edc\u7ed3\u6784\u4e4b\u4e0a\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u5ec9\u4ef7\u6709\u6548\u900f\u660e\u7684\u65b9\u6cd5\u6269\u5c55\u7f51\u7edc\u8bbe\u5907\u548c\u670d\u52a1\u5668\u7684\u5e26\u5bbd\u3001\u589e\u52a0\u541e\u5410\u91cf\u3001\u52a0\u5f3a\u7f51\u7edc\u6570\u636e\u5904\u7406\u80fd\u529b\u3001\u63d0\u9ad8\u7f51\u7edc\u7684\u7075\u6d3b\u6027\u548c\u53ef\u7528\u6027\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4ec0\u4e48\u662f\u8d1f\u8f7d\u5747\u8861\uff1f<\/strong><\/div>\n

\u8bb0\u5f97\u7b2c\u4e00\u6b21\u63a5\u89e6 Nginx \u662f\u5728\u5b9e\u9a8c\u5ba4\uff0c\u90a3\u65f6\u5019\u5728\u670d\u52a1\u5668\u90e8\u7f72\u7f51\u7ad9\u9700\u8981\u7528 Nginx \u3002Nginx \u662f\u4e00\u4e2a\u670d\u52a1\u7ec4\u4ef6\uff0c\u7528\u6765\u53cd\u5411\u4ee3\u7406\u3001\u8d1f\u8f7d\u5e73\u8861\u548c HTTP \u7f13\u5b58\u7b49\u3002\u90a3\u4e48\u8fd9\u91cc\u7684 \u8d1f\u8f7d\u5747\u8861 \u662f\u4ec0\u4e48\uff1f<\/p>\n

\u8d1f\u8f7d\u5747\u8861\uff08LB\uff0cLoad Balance\uff09\uff0c\u662f\u4e00\u79cd\u6280\u672f\u89e3\u51b3\u65b9\u6848\u3002\u7528\u6765\u5728\u591a\u4e2a\u8d44\u6e90\uff08\u4e00\u822c\u662f\u670d\u52a1\u5668\uff09\u4e2d\u5206\u914d\u8d1f\u8f7d\uff0c\u8fbe\u5230\u6700\u4f18\u5316\u8d44\u6e90\u4f7f\u7528\uff0c\u907f\u514d\u8fc7\u8f7d\u3002<\/p>\n

\"\"<\/p>\n

\u8d44\u6e90\uff0c\u76f8\u5f53\u4e8e\u6bcf\u4e2a\u670d\u52a1\u5b9e\u4f8b\u7684\u6267\u884c\u64cd\u4f5c\u5355\u5143\uff0c\u8d1f\u8f7d\u5747\u8861\u5c31\u662f\u5c06\u5927\u91cf\u7684\u6570\u636e\u5904\u7406\u64cd\u4f5c\u5206\u644a\u5230\u591a\u4e2a\u64cd\u4f5c\u5355\u5143\u8fdb\u884c\u6267\u884c\uff0c\u7528\u6765\u89e3\u51b3\u4e92\u8054\u7f51\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u5927\u6d41\u91cf\u3001\u9ad8\u5e76\u53d1\u548c\u9ad8\u53ef\u7528\u7684\u95ee\u9898\u3002\u90a3\u4ec0\u4e48\u662f\u9ad8\u53ef\u7528\u5462\uff1f<\/p>\n

\u4ec0\u4e48\u662f\u9ad8\u53ef\u7528\uff1f<\/strong><\/div>\n

\u9996\u5148\u4e86\u89e3\u4ec0\u4e48\u662f\u9ad8\u53ef\u7528\uff1f<\/p>\n

\u8fd9\u662f CAP \u5b9a\u7406\u662f\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u57fa\u7840\uff0c\u4e5f\u662f\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684 3 \u4e2a\u6307\u6807\uff1a<\/p>\n

Consistency\uff08\u4e00\u81f4\u6027\uff09<\/p>\n

Availability\uff08\u53ef\u7528\u6027\uff09<\/p>\n

Partition tolerance\uff08\u5206\u533a\u5bb9\u9519\u6027\uff09<\/p>\n

\u90a3\u9ad8\u53ef\u7528\uff08High Availability\uff09\u662f\u4ec0\u4e48\uff1f\u9ad8\u53ef\u7528\uff0c\u7b80\u79f0 HA\uff0c\u662f\u7cfb\u7edf\u4e00\u79cd\u7279\u5f81\u6216\u8005\u6307\u6807\uff0c\u901a\u5e38\u662f\u6307\uff0c\u63d0\u4f9b\u4e00\u5b9a\u6027\u80fd\u4e0a\u7684\u670d\u52a1\u8fd0\u884c\u65f6\u95f4\uff0c\u9ad8\u4e8e\u5e73\u5747\u6b63\u5e38\u65f6\u95f4\u6bb5\u3002\u53cd\u4e4b\uff0c\u6d88\u9664\u7cfb\u7edf\u670d\u52a1\u4e0d\u53ef\u7528\u7684\u65f6\u95f4\u3002<\/p>\n

\u8861\u91cf\u7cfb\u7edf\u662f\u5426\u6ee1\u8db3\u9ad8\u53ef\u7528\uff0c\u5c31\u662f\u5f53\u4e00\u53f0\u6216\u8005\u591a\u53f0\u670d\u52a1\u5668\u5b95\u673a\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u6574\u4f53\u548c\u670d\u52a1\u4f9d\u7136\u6b63\u5e38\u53ef\u7528\u3002<\/p>\n

\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u4e00\u4e9b\u77e5\u540d\u7684\u7f51\u7ad9\u4fdd\u8bc1 4 \u4e2a 9 \u4ee5\u4e0a\u7684\u53ef\u7528\u6027\uff0c\u4e5f\u5c31\u662f\u53ef\u7528\u6027\u8d85\u8fc7 99.99%\u3002\u90a3 0.01% \u5c31\u662f\u6240\u8c13\u6545\u969c\u65f6\u95f4\u7684\u767e\u5206\u6bd4\u3002\u6bd4\u5982\u7535\u5546\u7f51\u7ad9\u6709\u8d5e\uff0c\u670d\u52a1\u4e0d\u53ef\u7528\u4f1a\u9020\u6210\u5546\u5bb6\u635f\u5931\u91d1\u94b1\u548c\u7528\u6237\u3002\u90a3\u4e48\u5728\u63d0\u9ad8\u53ef\u7528\u6027\u57fa\u7840\u4e0a\u540c\u65f6\uff0c\u5bf9\u7cfb\u7edf\u5b95\u673a\u548c\u670d\u52a1\u4e0d\u53ef\u7528\u4f1a\u6709\u8865\u507f\u3002<\/p>\n

\"\"<\/p>\n

\u6bd4\u5982\u4e0b\u5355\u670d\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u5e26\u6709\u8d1f\u8f7d\u5747\u8861\u7684\u591a\u4e2a\u4e0b\u5355\u670d\u52a1\u5b9e\u4f8b\uff0c\u4ee3\u66ff\u5355\u4e00\u7684\u4e0b\u5355\u670d\u52a1\u5b9e\u4f8b\uff0c\u5373\u4f7f\u7528\u5197\u4f59\u7684\u65b9\u5f0f\u6765\u63d0\u9ad8\u53ef\u9760\u6027\u3002<\/p>\n

\u603b\u800c\u8a00\u4e4b\uff0c\u8d1f\u8f7d\u5747\u8861\uff08Load Balance\uff09\u662f\u5206\u5e03\u5f0f\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u4e2d\u5fc5\u987b\u8003\u8651\u7684\u56e0\u7d20\u4e4b\u4e00\u3002\u4e00\u822c\u901a\u8fc7\u8d1f\u8f7d\u5747\u8861\uff0c\u5197\u4f59\u540c\u4e00\u4e2a\u670d\u52a1\u5b9e\u4f8b\u7684\u65b9\u5f0f\uff0c\u89e3\u51b3\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u5927\u6d41\u91cf\u3001\u9ad8\u5e76\u53d1\u548c\u9ad8\u53ef\u7528\u7684\u95ee\u9898\u3002\u8d1f\u8f7d\u5747\u8861\u6838\u5fc3\u5173\u952e\uff1a\u5728\u4e8e\u662f\u5426\u5206\u914d\u5747\u5300\u3002<\/p>\n

\u5e38\u89c1\u7684\u8d1f\u8f7d\u5747\u8861\u6848\u4f8b<\/strong><\/div>\n

\u573a\u666f1\uff1a\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\uff0c\u7f51\u5173\u8def\u7531\u5230\u5177\u4f53\u7684\u670d\u52a1\u5b9e\u4f8b hello\uff1a<\/p>\n

\u2013 \u4e24\u4e2a\u76f8\u540c\u7684\u670d\u52a1\u5b9e\u4f8b hello service \uff0c\u4e00\u4e2a\u7aef\u53e3 8000 \uff0c\u53e6\u4e00\u4e2a\u7aef\u53e3 8082<\/p>\n

\u2013 \u901a\u8fc7 Kong \u7684\u8d1f\u8f7d\u5747\u8861 LB \u529f\u80fd\uff0c\u8ba9\u8bf7\u6c42\u5747\u5300\u7684\u5206\u53d1\u5230\u4e24\u4e2a hello \u670d\u52a1\u5b9e\u4f8b<\/p>\n

\u2013 Kong \u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u7b97\u6cd5\u5f88\u591a\uff1a\u9ed8\u8ba4 weighted-round-robin \u7b97\u6cd5\uff0c\u8fd8\u6709 consumer: consumer id \u4f5c\u4e3a hash \u7b97\u6cd5\u8f93\u5165\u503c\u7b49<\/p>\n

\"\"<\/p>\n

\u573a\u666f2\uff1a\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\uff0cA \u670d\u52a1\u8c03\u7528 B \u670d\u52a1\u7684\u96c6\u7fa4\u3002\u901a\u8fc7\u4e86 Ribbon \u5ba2\u6237\u7aef\u8d1f\u8f7d\u5747\u8861\u7ec4\u4ef6\uff1a<\/p>\n

\u2013 \u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u7b97\u6cd5\u5e76\u4e0d\u9ad8\u7ea7\uff0c\u6700\u7b80\u5355\u7684\u662f\u968f\u673a\u9009\u62e9\u548c\u8f6e\u5faa<\/p>\n

\u4e92\u8054\u7f51\u5206\u5e03\u5f0f\u7cfb\u7edf\u89e3\u51b3\u65b9\u6848<\/strong><\/div>\n

\"\"<\/p>\n

\u5e38\u89c1\u7684\u4e92\u8054\u7f51\u5206\u5e03\u5f0f\u7cfb\u7edf\u67b6\u6784\u5206\u4e3a\u51e0\u5c42\uff0c\u4e00\u822c\u5982\u4e0b\uff1a<\/p>\n

\u5ba2\u6237\u7aef\u5c42\uff1a\u6bd4\u5982\u7528\u6237\u6d4f\u89c8\u5668\u3001APP \u7aef<\/p>\n

\u53cd\u5411\u4ee3\u7406\u5c42\uff1a\u6280\u672f\u9009\u578b Nignx \u6216\u8005 F5 \u7b49<\/p>\n

Web \u5c42\uff1a\u524d\u540e\u7aef\u5206\u79bb\u573a\u666f\u4e0b\uff0c Web \u7aef\u53ef\u4ee5\u7528 NodeJS \u3001 RN \u3001Vue<\/p>\n

\u4e1a\u52a1\u670d\u52a1\u5c42\uff1a\u7528 Java \u3001Go\uff0c\u4e00\u822c\u4e92\u8054\u7f51\u516c\u53f8\uff0c\u6280\u672f\u65b9\u6848\u9009\u578b\u5c31\u662f SC \u6216\u8005 Spring Boot + Dubbo \u670d\u52a1\u5316<\/p>\n

\u6570\u636e\u5b58\u50a8\u5c42\uff1aDB \u9009\u578b MySQL \uff0cCache \u9009\u578b Redis \uff0c\u641c\u7d22\u9009\u578b ES \u7b49<\/p>\n

\u4e00\u4e2a\u8bf7\u6c42\u4ece\u7b2c 1 \u5c42\u5230\u7b2c 4 \u5c42\uff0c\u5c42\u5c42\u8bbf\u95ee\u90fd\u9700\u8981\u8d1f\u8f7d\u5747\u8861\u3002\u5373\u6bcf\u4e2a\u4e0a\u6e38\u8c03\u7528\u4e0b\u6e38\u591a\u4e2a\u4e1a\u52a1\u65b9\u7684\u65f6\u5019\uff0c\u9700\u8981\u5747\u5300\u8c03\u7528\u3002\u8fd9\u6837\u6574\u4f53\u7cfb\u7edf\u6765\u770b\uff0c\u5c31\u6bd4\u8f83\u8d1f\u8f7d\u5747\u8861<\/p>\n

\u7b2c 1 \u5c42\uff1a\u5ba2\u6237\u7aef\u5c42 -> \u53cd\u5411\u4ee3\u7406\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861<\/strong><\/span><\/div>\n

\u5ba2\u6237\u7aef\u5c42 -> \u53cd\u5411\u4ee3\u7406\u5c42\u7684\u8d1f\u8f7d\u5747\u8861\u5982\u4f55\u5b9e\u73b0\u5462\uff1f<\/p>\n

\u7b54\u6848\u662f\uff1aDNS \u7684\u8f6e\u8be2\u3002 DNS \u53ef\u4ee5\u901a\u8fc7 A \uff08Address\uff0c\u8fd4\u56de\u57df\u540d\u6307\u5411\u7684 IP \u5730\u5740\uff09\u8bbe\u7f6e\u591a\u4e2a IP \u5730\u5740\u3002\u6bd4\u5982\u8fd9\u91cc\u8bbf\u95ee bysocket.com \u7684 DNS \u914d\u7f6e\u4e86 ip1 \u548c ip2 \u3002\u4e3a\u4e86\u53cd\u5411\u4ee3\u7406\u5c42\u7684\u9ad8\u53ef\u7528\uff0c\u81f3\u5c11\u4f1a\u6709\u4e24\u6761 A \u8bb0\u5f55\u3002\u8fd9\u6837\u5197\u4f59\u7684\u4e24\u4e2a ip \u5bf9\u5e94\u7684 nginx \u670d\u52a1\u5b9e\u4f8b\uff0c\u9632\u6b62\u5355\u70b9\u6545\u969c\u3002<\/p>\n

\u6bcf\u6b21\u8bf7\u6c42 bysocket.com \u57df\u540d\u7684\u65f6\u5019\uff0c\u901a\u8fc7 DNS \u8f6e\u8be2\uff0c\u8fd4\u56de\u5bf9\u5e94\u7684 ip \u5730\u5740\uff0c\u6bcf\u4e2a ip \u5bf9\u5e94\u7684\u53cd\u5411\u4ee3\u7406\u5c42\u7684\u670d\u52a1\u5b9e\u4f8b\uff0c\u4e5f\u5c31\u662f nginx \u7684\u5916\u7f51ip\u3002\u8fd9\u6837\u53ef\u4ee5\u505a\u5230\u6bcf\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u5c42\u5b9e\u4f8b\u5f97\u5230\u7684\u8bf7\u6c42\u5206\u914d\u662f\u5747\u8861\u7684\u3002<\/p>\n

\u7b2c 2 \u5c42\uff1a\u53cd\u5411\u4ee3\u7406\u5c42 -> Web \u5c42 \u7684\u8d1f\u8f7d\u5747\u8861<\/strong><\/span><\/div>\n

\u53cd\u5411\u4ee3\u7406\u5c42 -> Web \u5c42 \u7684\u8d1f\u8f7d\u5747\u8861\u5982\u4f55\u5b9e\u73b0\u5462\uff1f<\/p>\n

\u662f\u901a\u8fc7\u53cd\u5411\u4ee3\u7406\u5c42\u7684\u8d1f\u8f7d\u5747\u8861\u6a21\u5757\u5904\u7406\u3002\u6bd4\u5982 nginx \u6709\u591a\u79cd\u5747\u8861\u65b9\u6cd5\uff1a<\/p>\n

\u8bf7\u6c42\u8f6e\u8be2\u3002\u8bf7\u6c42\u6309\u65f6\u95f4\u987a\u5e8f\uff0c\u9010\u4e00\u5206\u914d\u5230 web \u5c42\u670d\u52a1\uff0c\u7136\u540e\u5468\u800c\u590d\u59cb\u3002\u5982\u679c web \u5c42\u670d\u52a1 down \u6389\uff0c\u81ea\u52a8\u5254\u9664<\/p>\n

\r\nupstream web-server {\r\n    server ip3;\r\n    server ip4;\r\n}\r\n<\/pre>\n

ip \u54c8\u5e0c\u3002\u6309\u7167 ip \u7684\u54c8\u5e0c\u503c\uff0c\u786e\u5b9a\u8def\u7531\u5230\u5bf9\u5e94\u7684 web \u5c42\u3002\u53ea\u8981\u662f\u7528\u6237\u7684 ip \u662f\u5747\u5300\u7684\uff0c\u90a3\u4e48\u8bf7\u6c42\u5230 Web \u5c42\u4e5f\u662f\u5747\u5300\u7684\u3002<\/p>\n

\u8fd8\u6709\u4e2a\u597d\u5904\u5c31\u662f\u540c\u4e00\u4e2a ip \u7684\u8bf7\u6c42\u4f1a\u5206\u53d1\u5230\u76f8\u540c\u7684 web \u5c42\u670d\u52a1\u3002\u8fd9\u6837\u6bcf\u4e2a\u7528\u6237\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a web \u5c42\u670d\u52a1\uff0c\u53ef\u4ee5\u89e3\u51b3 session \u7684\u95ee\u9898\u3002<\/p>\n

\r\nupstream web-server {\r\n    ip_hash;\r\n    server ip3;\r\n    server ip4;\r\n}\r\n<\/pre>\n

weight \u6743\u91cd \u3001 fair\u3001url_hash \u7b49<\/p>\n

\u7b2c 3 \u5c42\uff1aWeb \u5c42 -> \u4e1a\u52a1\u670d\u52a1\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861<\/strong><\/span><\/div>\n

Web \u5c42 -> \u4e1a\u52a1\u670d\u52a1\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861\u5982\u4f55\u5b9e\u73b0\u5462\uff1f<\/p>\n

\u6bd4\u5982 Dubbo \u662f\u4e00\u4e2a\u670d\u52a1\u6cbb\u7406\u65b9\u6848\uff0c\u5305\u62ec\u670d\u52a1\u6ce8\u518c\u3001\u670d\u52a1\u964d\u7ea7\u3001\u8bbf\u95ee\u63a7\u5236\u3001\u52a8\u6001\u914d\u7f6e\u8def\u7531\u89c4\u5219\u3001\u6743\u91cd\u8c03\u8282\u3001\u8d1f\u8f7d\u5747\u8861\u3002\u5176\u4e2d\u4e00\u4e2a\u7279\u6027\u5c31\u662f\u667a\u80fd\u8d1f\u8f7d\u5747\u8861\uff1a\u5185\u7f6e\u591a\u79cd\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u667a\u80fd\u611f\u77e5\u4e0b\u6e38\u8282\u70b9\u5065\u5eb7\u72b6\u51b5\uff0c\u663e\u8457\u51cf\u5c11\u8c03\u7528\u5ef6\u8fdf\uff0c\u63d0\u9ad8\u7cfb\u7edf\u541e\u5410\u91cf\u3002<\/p>\n

\u4e3a\u4e86\u907f\u514d\u907f\u514d\u5355\u70b9\u6545\u969c\u548c\u652f\u6301\u670d\u52a1\u7684\u6a2a\u5411\u6269\u5bb9\uff0c\u4e00\u4e2a\u670d\u52a1\u901a\u5e38\u4f1a\u90e8\u7f72\u591a\u4e2a\u5b9e\u4f8b\uff0c\u5373 Dubbo \u96c6\u7fa4\u90e8\u7f72\u3002\u4f1a\u5c06\u591a\u4e2a\u670d\u52a1\u5b9e\u4f8b\u6210\u4e3a\u4e00\u4e2a\u670d\u52a1\u63d0\u4f9b\u65b9\uff0c\u7136\u540e\u6839\u636e\u914d\u7f6e\u7684\u968f\u673a\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u572820\u4e2a Provider \u4e2d\u968f\u673a\u9009\u62e9\u4e86\u4e00\u4e2a\u6765\u8c03\u7528\uff0c\u5047\u8bbe\u968f\u673a\u5230\u4e86\u7b2c7\u4e2a Provider\u3002LoadBalance \u7ec4\u4ef6\u4ece\u63d0\u4f9b\u8005\u5730\u5740\u5217\u8868\u4e2d\uff0c\u4f7f\u7528\u5747\u8861\u7b56\u7565\uff0c\u9009\u62e9\u9009\u4e00\u4e2a\u63d0\u4f9b\u8005\u8fdb\u884c\u8c03\u7528\uff0c\u5982\u679c\u8c03\u7528\u5931\u8d25\uff0c\u518d\u9009\u53e6\u4e00\u53f0\u8c03\u7528\u3002<\/p>\n

Dubbo\u5185\u7f6e\u4e864\u79cd\u8d1f\u8f7d\u5747\u8861\u7b56\u7565:<\/p>\n

RandomLoadBalance:\u968f\u673a\u8d1f\u8f7d\u5747\u8861\u3002\u968f\u673a\u7684\u9009\u62e9\u4e00\u4e2a\u3002\u662fDubbo\u7684\u9ed8\u8ba4\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u3002<\/p>\n

RoundRobinLoadBalance:\u8f6e\u8be2\u8d1f\u8f7d\u5747\u8861\u3002\u8f6e\u8be2\u9009\u62e9\u4e00\u4e2a\u3002<\/p>\n

LeastActiveLoadBalance:\u6700\u5c11\u6d3b\u8dc3\u8c03\u7528\u6570\uff0c\u76f8\u540c\u6d3b\u8dc3\u6570\u7684\u968f\u673a\u3002\u6d3b\u8dc3\u6570\u6307\u8c03\u7528\u524d\u540e\u8ba1\u6570\u5dee\u3002\u4f7f\u6162\u7684 Provider \u6536\u5230\u66f4\u5c11\u8bf7\u6c42\uff0c\u56e0\u4e3a\u8d8a\u6162\u7684 Provider \u7684\u8c03\u7528\u524d\u540e\u8ba1\u6570\u5dee\u4f1a\u8d8a\u5927\u3002<\/p>\n

ConsistentHashLoadBalance:\u4e00\u81f4\u6027\u54c8\u5e0c\u8d1f\u8f7d\u5747\u8861\u3002\u76f8\u540c\u53c2\u6570\u7684\u8bf7\u6c42\u603b\u662f\u843d\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u3002<\/p>\n

\u540c\u6837\uff0c\u56e0\u4e3a\u4e1a\u52a1\u7684\u9700\u8981\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u81ea\u5df1\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565<\/p>\n

\u7b2c 4 \u5c42\uff1a\u4e1a\u52a1\u670d\u52a1\u5c42 -> \u6570\u636e\u5b58\u50a8\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861<\/strong><\/span><\/div>\n

\u6570\u636e\u5b58\u50a8\u5c42\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u4e00\u822c\u901a\u8fc7 DBProxy \u5b9e\u73b0\u3002\u6bd4\u5982 MySQL \u5206\u5e93\u5206\u8868\u3002<\/p>\n

\u5f53\u5355\u5e93\u6216\u8005\u5355\u8868\u8bbf\u95ee\u592a\u5927\uff0c\u6570\u636e\u91cf\u592a\u5927\u7684\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u8fdb\u884c\u5782\u76f4\u62c6\u5206\u548c\u6c34\u5e73\u62c6\u5206\u4e24\u4e2a\u7ef4\u5ea6\u3002\u6bd4\u5982\u6c34\u5e73\u5207\u5206\u89c4\u5219\uff1a<\/p>\n

Range \u3001 \u65f6\u95f4<\/p>\n

hash \u53d6\u6a21\uff0c\u8ba2\u5355\u6839\u636e\u5e97\u94faID \u7b49<\/p>\n

\u4f46\u4f34\u968f\u7740\u8fd9\u5757\u7684\u8d1f\u8f7d\u4f1a\u51fa\u73b0\u4e0b\u9762\u7684\u95ee\u9898\uff0c\u9700\u8981\u89e3\u51b3\uff1a<\/p>\n

\u5206\u5e03\u5f0f\u4e8b\u52a1<\/p>\n

\u8de8\u5e93 join \u7b49<\/p>\n

\u73b0\u72b6\u5206\u5e93\u5206\u8868\u7684\u4ea7\u54c1\u65b9\u6848\u5f88\u591a\uff1a\u5f53\u5f53 sharding-jdbc\u3001\u963f\u91cc\u7684 Cobar \u7b49<\/p>\n

\u5c0f\u7ed3<\/strong><\/div>\n

\u5bf9\u5916\u770b\u6765\uff0c\u8d1f\u8f7d\u5747\u8861\u662f\u4e00\u4e2a\u7cfb\u7edf\u6216\u8f6f\u4ef6\u7684\u6574\u4f53\u3002\u5bf9\u5185\u770b\u6765\uff0c\u5c42\u5c42\u4e0a\u4e0b\u6e38\u8c03\u7528\u3002\u53ea\u8981\u5b58\u5728\u8c03\u7528\uff0c\u5c31\u9700\u8981\u8003\u8651\u8d1f\u8f7d\u5747\u8861\u8fd9\u4e2a\u56e0\u7d20\u3002\u6240\u4ee5\u8d1f\u8f7d\u5747\u8861\uff08Load Balance\uff09\u662f\u5206\u5e03\u5f0f\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u4e2d\u5fc5\u987b\u8003\u8651\u7684\u56e0\u7d20\u4e4b\u4e00\u3002\u8003\u8651\u4e3b\u8981\u662f\u5982\u4f55\u8ba9\u4e0b\u6e38\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u662f\u5747\u5300\u5206\u5e03\u7684\uff1a<\/p>\n

\u7b2c 1 \u5c42\uff1a\u5ba2\u6237\u7aef\u5c42 -> \u53cd\u5411\u4ee3\u7406\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861\u3002\u901a\u8fc7 DNS \u8f6e\u8be2<\/p>\n

\u7b2c 2 \u5c42\uff1a\u53cd\u5411\u4ee3\u7406\u5c42 -> Web \u5c42 \u7684\u8d1f\u8f7d\u5747\u8861\u3002\u901a\u8fc7 Nginx \u7684\u8d1f\u8f7d\u5747\u8861\u6a21\u5757<\/p>\n

\u7b2c 3 \u5c42\uff1aWeb \u5c42 -> \u4e1a\u52a1\u670d\u52a1\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861\u3002\u901a\u8fc7\u670d\u52a1\u6cbb\u7406\u6846\u67b6\u7684\u8d1f\u8f7d\u5747\u8861\u6a21\u5757<\/p>\n

\u7b2c 4 \u5c42\uff1a\u4e1a\u52a1\u670d\u52a1\u5c42 -> \u6570\u636e\u5b58\u50a8\u5c42 \u7684\u8d1f\u8f7d\u5747\u8861\u3002\u901a\u8fc7\u6570\u636e\u7684\u6c34\u5e73\u5206\u5e03\uff0c\u6570\u636e\u5747\u5300\u4e86\uff0c\u7406\u8bba\u4e0a\u8bf7\u6c42\u4e5f\u4f1a\u5747\u5300\u3002\u6bd4\u5982\u901a\u8fc7\u4e70\u5bb6ID\u5206\u7247\u7c7b\u4f3c<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8bb0\u5f97\u7b2c\u4e00\u6b21\u63a5\u89e6 Nginx \u662f\u5728\u5b9e\u9a8c\u5ba4\uff0c\u90a3\u65f6\u5019\u5728\u670d\u52a1\u5668\u90e8\u7f72\u7f51\u7ad9\u9700\u8981\u7528 Nginx \u3002Nginx \u662f\u4e00\u4e2a\u670d\u52a1\u7ec4\u4ef6 […]<\/p>\n","protected":false},"author":1479,"featured_media":198655,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-198618","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=198618"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198618\/revisions"}],"predecessor-version":[{"id":198658,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198618\/revisions\/198658"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/198655"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=198618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=198618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=198618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}