strategy<\/code>: \u6839\u636e\u8c03\u7528\u5173\u7cfb\u9009\u62e9\u7b56\u7565<\/li>\n<\/ul>\n\u6d41\u63a7\u7c7b\u578b<\/h4>\n\u57fa\u4e8eQPS\u6d41\u63a7<\/h5>\n
\u901a\u8fc7\u63a7\u5236\u53f0\u9996\u9875-\u7c07\u70b9\u94fe\u8def\uff0c\u5728\u76f8\u5e94\u8d44\u6e90\u7684\u8bb0\u5f55\u53f3\u8fb9\u70b9\u51fb\u6d41\u63a7\u6309\u94ae\u5e76\u8bbe\u7f6e\u76f8\u5e94\u7684\u6d41\u63a7\u89c4\u5219\u3002<\/p>\n
<\/p>\n
\u5feb\u901f\u8bbf\u95ee\u8ba2\u5355\u63a7\u5236\u5668\u7684\u6dfb\u52a0\u8ba2\u5355\u63a5\u53e3\uff0c\u5f53\u524d\u8bbe\u7f6e\u6bcf\u79d2\u8d85\u8fc72\u6b21\u5c31\u4f1a\u88ab\u6d41\u63a7<\/p>\n
<\/p>\n
\u540c\u6837\u6211\u4eec\u4e5f\u53ef\u4ee5\u548c\u524d\u9762\u6838\u5fc3\u5e93\u793a\u4f8b\u4e00\u6837\u81ea\u5b9a\u6d41\u63a7\u63d0\u793a<\/p>\n
<\/p>\n
\u8bbe\u7f6e\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3\u7684\u6d41\u63a7\u89c4\u5219<\/p>\n
<\/p>\n
\u901a\u8fc7\u63a7\u5236\u53f0\u9996\u9875-\u6d41\u63a7\u89c4\u5219\u67e5\u770b\u5f53\u524d\u7684\u6d41\u63a7\u89c4\u5219\uff0c\u6bcf\u6b21\u91cd\u542f\u5fae\u670d\u52a1\u6a21\u5757\u5176\u8bbe\u7f6e\u89c4\u5219\u5728\u5185\u5b58\u4e2d\u4e22\u5931\u4e86\uff0c\u4e5f\u5373\u662f\u524d\u9762\u8bbe\u7f6e\u6dfb\u52a0\u8ba2\u5355\u7684\u6d41\u63a7\u89c4\u5219\u4e5f\u6ca1\u6709\u4e86\uff0c\u5982\u9700\u8981\u5219\u9700\u91cd\u65b0\u8bbe\u7f6e<\/p>\n
<\/p>\n
\u5feb\u901f\u8bbf\u95ee\u8ba2\u5355\u63a7\u5236\u5668\u7684\u67e5\u8be2\u8ba2\u5355\u63a5\u53e3<\/p>\n
<\/p>\n
\u5e76\u53d1\u7ebf\u7a0b\u6570<\/h5>\n
\u7ebf\u7a0b\u6570\u9650\u6d41\u7528\u4e8e\u4fdd\u62a4\u4e1a\u52a1\u7ebf\u7a0b\u6570\u4e0d\u88ab\u8017\u5c3d\u3002\u4f8b\u5982\uff0c\u5f53\u5e94\u7528\u6240\u4f9d\u8d56\u7684\u4e0b\u6e38\u5e94\u7528\u7531\u4e8e\u67d0\u79cd\u539f\u56e0\u5bfc\u81f4\u670d\u52a1\u4e0d\u7a33\u5b9a\u3001\u54cd\u5e94\u5ef6\u8fdf\u589e\u52a0\uff0c\u5bf9\u4e8e\u8c03\u7528\u8005\u6765\u8bf4\uff0c\u610f\u5473\u7740\u541e\u5410\u91cf\u4e0b\u964d\u548c\u66f4\u591a\u7684\u7ebf\u7a0b\u6570\u5360\u7528\uff0c\u6781\u7aef\u60c5\u51b5\u4e0b\u751a\u81f3\u5bfc\u81f4\u7ebf\u7a0b\u6c60\u8017\u5c3d\u3002\u4e3a\u5e94\u5bf9\u9ad8\u7ebf\u7a0b\u5360\u7528\u7684\u60c5\u51b5\uff0c\u4e1a\u5185\u6709\u4f7f\u7528\u9694\u79bb\u7684\u65b9\u6848\uff0c\u6bd4\u5982\u901a\u8fc7\u4e0d\u540c\u4e1a\u52a1\u903b\u8f91\u4f7f\u7528\u4e0d\u540c\u7ebf\u7a0b\u6c60\u6765\u9694\u79bb\u4e1a\u52a1\u81ea\u8eab\u4e4b\u95f4\u7684\u8d44\u6e90\u4e89\u62a2\uff08\u7ebf\u7a0b\u6c60\u9694\u79bb\uff09\uff0c\u6216\u8005\u4f7f\u7528\u4fe1\u53f7\u91cf\u6765\u63a7\u5236\u540c\u65f6\u8bf7\u6c42\u7684\u4e2a\u6570\uff08\u4fe1\u53f7\u91cf\u9694\u79bb\uff09\u3002\u8fd9\u79cd\u9694\u79bb\u65b9\u6848\u867d\u7136\u80fd\u591f\u63a7\u5236\u7ebf\u7a0b\u6570\u91cf\uff0c\u4f46\u65e0\u6cd5\u63a7\u5236\u8bf7\u6c42\u6392\u961f\u65f6\u95f4\u3002\u5f53\u8bf7\u6c42\u8fc7\u591a\u65f6\u6392\u961f\u4e5f\u662f\u65e0\u76ca\u7684\uff0c\u76f4\u63a5\u62d2\u7edd\u80fd\u591f\u8fc5\u901f\u964d\u4f4e\u7cfb\u7edf\u538b\u529b\u3002Sentinel\u7ebf\u7a0b\u6570\u9650\u6d41\u4e0d\u8d1f\u8d23\u521b\u5efa\u548c\u7ba1\u7406\u7ebf\u7a0b\u6c60\uff0c\u800c\u662f\u7b80\u5355\u7edf\u8ba1\u5f53\u524d\u8bf7\u6c42\u4e0a\u4e0b\u6587\u7684\u7ebf\u7a0b\u4e2a\u6570\uff0c\u5982\u679c\u8d85\u51fa\u9608\u503c\uff0c\u65b0\u7684\u8bf7\u6c42\u4f1a\u88ab\u7acb\u5373\u62d2\u7edd\u3002\u6211\u4eec\u5728\u67e5\u8be2\u8ba2\u5355\u63a5\u53e3\u4e2d\u589e\u52a0\u4f11\u7720\u6765\u6f14\u793a\u6548\u679c<\/p>\n
@RequestMapping<\/span>(<\/span>\"\/query-order\"<\/span>)<\/span> @SentinelResource<\/span>(<\/span>value =<\/span> \"query-order\"<\/span>,<\/span>blockHandler =<\/span> \"querydOrderBlockHandler\"<\/span>)<\/span> public<\/span> String<\/span> querydOrder<\/span>(<\/span>)<\/span> { \n <\/span> try<\/span> { \n <\/span> TimeUnit<\/span>.<\/span>SECONDS.<\/span>sleep<\/span>(<\/span>10<\/span>)<\/span>;<\/span> }<\/span> catch<\/span> (<\/span>InterruptedException<\/span> e)<\/span> { \n <\/span> e.<\/span>printStackTrace<\/span>(<\/span>)<\/span>;<\/span> }<\/span> return<\/span> \"\u8ba2\u5355\u67e5\u8be2\u6210\u529f\"<\/span>;<\/span> }<\/span> <\/code><\/pre>\n\u8bbe\u7f6e\u5e76\u53d1\u7ebf\u7a0b\u6570\u7684\u9608\u503c\u4e3a1<\/p>\n
<\/p>\n
\u8bbf\u95ee\u7b2c\u4e00\u4e2a\u9875\u9762\u7684\u7d27\u8ddf\u7740\u518d\u6253\u5f00\u53e6\u5916\u4e00\u4e2a\u9875\u9762\u7ee7\u7eed\u8bbf\u95ee<\/p>\n
<\/p>\n
\u7b2c\u4e8c\u4e2a\u9875\u9762\u5c31\u663e\u793a\u88ab\u6d41\u63a7\u4e86<\/p>\n
<\/p>\n
\u6d41\u63a7\u6a21\u5f0f<\/h4>\n\u6a21\u5f0f\u5206\u7c7b<\/h5>\n\n- \u76f4\u63a5\u62d2\u7edd\uff1a\u63a5\u53e3\u8fbe\u5230\u9650\u6d41\u6761\u4ef6\u65f6\uff0c\u76f4\u63a5\u9650\u6d41<\/li>\n
- \u5173\u8054\uff1a\u5f53\u5173\u8054\u7684\u8d44\u6e90\u8fbe\u5230\u9608\u503c\u65f6\uff0c\u5c31\u9650\u6d41\u81ea\u5df1<\/li>\n
- \u94fe\u8def\uff1a\u53ea\u8bb0\u5f55\u6307\u5b9a\u94fe\u8def\u4e0a\u7684\u6d41\u91cf\uff08\u6307\u5b9a\u8d44\u6e90\u4ece\u5165\u53e3\u8d44\u6e90\u8fdb\u6765\u7684\u6d41\u91cf\uff0c\u5982\u679c\u8fbe\u5230\u9608\u503c\uff0c\u5c31\u53ef\u4ee5\u9650\u6d41\uff09<\/li>\n<\/ul>\n
\u76f4\u63a5\u62d2\u7edd<\/h5>\n
\u9ed8\u8ba4\u7684\u6d41\u91cf\u63a7\u5236\u65b9\u5f0f\uff0c\u5f53QPS\u8d85\u8fc7\u4efb\u610f\u89c4\u5219\u7684\u9608\u503c\u540e\uff0c\u65b0\u7684\u8bf7\u6c42\u5c31\u4f1a\u88ab\u7acb\u5373\u62d2\u7edd\uff0c\u62d2\u7edd\u65b9\u5f0f\u4e3a\u629b\u51fa\u3002\u524d\u9762\u7684\u4f8b\u5b50\u90fd\u662f\u4f7f\u7528\u76f4\u63a5\u62d2\u7edd\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u8bf4\u660e\u3002<\/p>\n
\u5173\u8054\u6d41\u63a7<\/h5>\n
\u5177\u6709\u5173\u7cfb\u7684\u8d44\u6e90\u6d41\u91cf\u63a7\u5236\uff0c\u5f53\u4e24\u4e2a\u8d44\u6e90\u4e4b\u95f4\u5177\u6709\u8d44\u6e90\u4e89\u62a2\u6216\u8005\u4f9d\u8d56\u5173\u7cfb\u7684\u65f6\u5019\uff0c\u8fd9\u4e24\u4e2a\u8d44\u6e90\u4fbf\u5177\u6709\u4e86\u5173\u8054\u3002\u6bd4\u5982\u5bf9\u6570\u636e\u5e93\u540c\u4e00\u4e2a\u5b57\u6bb5\u7684\u8bfb\u64cd\u4f5c\u548c\u5199\u64cd\u4f5c\u5b58\u5728\u4e89\u62a2\uff0c\u8bfb\u7684\u901f\u5ea6\u8fc7\u9ad8\u4f1a\u5f71\u54cd\u5199\u5f97\u901f\u5ea6\uff0c\u5199\u7684\u901f\u5ea6\u8fc7\u9ad8\u4f1a\u5f71\u54cd\u8bfb\u7684\u901f\u5ea6\u3002\u5982\u679c\u653e\u4efb\u8bfb\u5199\u64cd\u4f5c\u4e89\u62a2\u8d44\u6e90\uff0c\u5219\u4e89\u62a2\u672c\u8eab\u5e26\u6765\u7684\u5f00\u9500\u4f1a\u964d\u4f4e\u6574\u4f53\u7684\u541e\u5410\u91cf\u3002\u53ef\u4f7f\u7528\u5173\u8054\u9650\u6d41\u6765\u907f\u514d\u5177\u6709\u5173\u8054\u5173\u7cfb\u7684\u8d44\u6e90\u4e4b\u95f4\u8fc7\u5ea6\u7684\u4e89\u62a2\uff0c\u4e3e\u4f8b\u6765\u8bf4\uff0cread_db<\/code> \u548c write_db<\/code> \u8fd9\u4e24\u4e2a\u8d44\u6e90\u5206\u522b\u4ee3\u8868\u6570\u636e\u5e93\u8bfb\u5199\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed9 read_db<\/code> \u8bbe\u7f6e\u9650\u6d41\u89c4\u5219\u6765\u8fbe\u5230\u5199\u4f18\u5148\u7684\u76ee\u7684\uff1a\u8bbe\u7f6e FlowRule.strategy<\/code> \u4e3a RuleConstant.RELATE<\/code> \u540c\u65f6\u8bbe\u7f6e FlowRule.ref_identity<\/code> \u4e3a write_db<\/code>\u3002\u8fd9\u6837\u5f53\u5199\u5e93\u64cd\u4f5c\u8fc7\u4e8e\u9891\u7e41\u65f6\uff0c\u8bfb\u6570\u636e\u7684\u8bf7\u6c42\u4f1a\u88ab\u9650\u6d41\u3002\u6211\u4eec\u5148\u628a\u524d\u9762\u7684querydOrder\u4f11\u7720\u53bb\u6389\uff0c\u8bbe\u7f6e\u6d41\u63a7\u6a21\u5f0f\u4e3a\u5173\u8054\uff0c\u5173\u8054\u8d44\u6e90\u4e3a\u6dfb\u52a0\u8ba2\u5355\u63a5\u53e3<\/p>\n<\/p>\n
\u5148\u901a\u8fc7ApiFox\u8bbe\u7f6e\u5faa\u73af\u8bbf\u95ee\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u5de5\u5177\u5982jmeter\u7b49\uff0cApiFox\u4e5f\u53ef\u4ee5\u524d\u9762\u7684\u6587\u7ae0\u4e5f\u6709\u8bb2\u89e3\u53bb\u4f7f\u7528<\/p>\n
<\/p>\n
\u542f\u52a8\u6301\u7eed\u7684\u8bbf\u95ee\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3<\/p>\n
<\/p>\n
\u8bbf\u95ee\u8ba2\u5355\u6dfb\u52a0\u5df2\u7ecf\u663e\u793a\u88ab\u6d41\u63a7\u4e86\uff0c\u6682\u505cApiFox\u540e\u8bbf\u95ee\u5219\u6b63\u5e38\u3002<\/p>\n
<\/p>\n
\u94fe\u8def\u6d41\u63a7<\/h5>\n
NodeSelectorSlot<\/code> \u4e2d\u8bb0\u5f55\u4e86\u8d44\u6e90\u4e4b\u95f4\u7684\u8c03\u7528\u94fe\u8def\uff0c\u8fd9\u4e9b\u8d44\u6e90\u901a\u8fc7\u8c03\u7528\u5173\u7cfb\uff0c\u76f8\u4e92\u4e4b\u95f4\u6784\u6210\u4e00\u68f5\u8c03\u7528\u6811\u3002\u8fd9\u68f5\u6811\u7684\u6839\u8282\u70b9\u662f\u4e00\u4e2a\u540d\u5b57\u4e3a machine-root<\/code> \u7684\u865a\u62df\u8282\u70b9\uff0c\u8c03\u7528\u94fe\u7684\u5165\u53e3\u90fd\u662f\u8fd9\u4e2a\u865a\u8282\u70b9\u7684\u5b50\u8282\u70b9\u3002\u5728\u8ba2\u5355\u5b9e\u73b0\u7c7b\u4e2d\u589e\u52a0\u6d4b\u8bd5\u65b9\u6cd5<\/p>\n @Override<\/span> @SentinelResource<\/span>(<\/span>value =<\/span> \"getOrder\"<\/span>)<\/span> public<\/span> String<\/span> getOrder<\/span>(<\/span>)<\/span> { \n <\/span> return<\/span> \"\u6d4b\u8bd5\u67e5\u8be2\u8ba2\u5355\"<\/span>;<\/span> }<\/span> <\/code><\/pre>\n\u8ba2\u5355\u63a7\u5236\u5668\u589e\u52a0\u4e24\u4e2a\u63a5\u53e3\u65b9\u6cd5\uff0c\u90fd\u8c03\u7528\u5230\u4e86getOrder<\/p>\n
@RequestMapping<\/span>(<\/span>\"\/test1\"<\/span>)<\/span> public<\/span> String<\/span> test1<\/span>(<\/span>)<\/span>{ \n <\/span> return<\/span> orderService.<\/span>getOrder<\/span>(<\/span>)<\/span>;<\/span> }<\/span> @RequestMapping<\/span>(<\/span>\"\/test2\"<\/span>)<\/span> public<\/span> String<\/span> test2<\/span>(<\/span>)<\/span>{ \n <\/span> return<\/span> orderService.<\/span>getOrder<\/span>(<\/span>)<\/span>;<\/span> }<\/span> <\/code><\/pre>\n\u914d\u7f6e\u6587\u4ef6\u589e\u52a0\u4e0b\u9762\u53c2\u6570<\/p>\n
spring<\/span>:<\/span> cloud<\/span>:<\/span> sentinel<\/span>:<\/span> web-context-unify<\/span>:<\/span> false<\/span> <\/code><\/pre>\n\u542f\u52a8\u7a0b\u5e8f\u4e3agetOrder\u8d44\u6e90\u8bbe\u7f6e\u94fe\u8def\u6d41\u63a7\u6a21\u5f0f\uff0c\u5165\u53e3\u8d44\u6e90\u4e3a\/test2<\/p>\n
<\/p>\n
\u5feb\u901f\u8bbf\u95eehttp:\/\/localhost:4070\/test2 \uff0c\u51fa\u73b0\u88ab\u6d41\u63a7\u4e86\uff0c\u800c\u5feb\u901f\u8bbf\u95eehttp:\/\/localhost:4070\/test1\u5219\u90fd\u662f\u6b63\u5e38\u8bf7\u6c42<\/p>\n
\u6d41\u63a7\u6548\u679c<\/h4>\n\u5feb\u901f\u5931\u8d25<\/h5>\n
\u9ed8\u8ba4\u7684\u6d41\u91cf\u63a7\u5236\u65b9\u5f0f\uff0c\u5f53QPS\u8d85\u8fc7\u4efb\u610f\u89c4\u5219\u7684\u9608\u503c\u540e\uff0c\u65b0\u7684\u8bf7\u6c42\u5c31\u4f1a\u88ab\u7acb\u5373\u62d2\u7edd\uff0c\u62d2\u7edd\u65b9\u5f0f\u4e3a\u629b\u51faFlowException<\/code>\u3002\u524d\u9762\u5927\u90e8\u5206\u4f8b\u5b50\u90fd\u662f\u4f7f\u7528\u4e86\u5feb\u901f\u5931\u8d25\u6f14\u793a\u3002<\/p>\nWarm Up<\/h5>\n\n- Sentinel\u7684Warm Up\uff08
RuleConstant.CONTROL_BEHAVIOR_WARM_UP<\/code>\uff09\u65b9\u5f0f\uff0c\u5373\u9884\u70ed\/\u51b7\u542f\u52a8\u65b9\u5f0f\u3002\u5f53\u7cfb\u7edf\u957f\u671f\u5904\u4e8e\u4f4e\u6c34\u4f4d\u7684\u60c5\u51b5\u4e0b\uff0c\u5f53\u6d41\u91cf\u7a81\u7136\u589e\u52a0\u65f6\uff0c\u76f4\u63a5\u628a\u7cfb\u7edf\u62c9\u5347\u5230\u9ad8\u6c34\u4f4d\u53ef\u80fd\u77ac\u95f4\u628a\u7cfb\u7edf\u538b\u57ae\u3002\u901a\u8fc7\"\u51b7\u542f\u52a8\"\uff0c\u8ba9\u901a\u8fc7\u7684\u6d41\u91cf\u7f13\u6162\u589e\u52a0\uff0c\u8ba9\u670d\u52a1\u5668\u4e00\u70b9\u4e00\u70b9\u5904\u7406\uff0c\u518d\u6162\u6162\u52a0\u91cf,\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\u9010\u6e10\u589e\u52a0\u5230\u9608\u503c\u4e0a\u9650\uff0c\u7ed9\u51b7\u7cfb\u7edf\u4e00\u4e2a\u9884\u70ed\u7684\u65f6\u95f4\uff0c\u907f\u514d\u51b7\u7cfb\u7edf\u88ab\u538b\u57ae\u3002<\/li>\n- \u9884\u70ed\u5e95\u5c42\u662f\u6839\u636e\u4ee4\u724c\u6876<\/strong>\u7b97\u6cd5\u5b9e\u73b0\u7684\u3002<\/li>\n
- warm up\u51b7\u542f\u52a8\u4e3b\u8981\u7528\u4e8e\u542f\u52a8\u9700\u8981\u989d\u5916\u5f00\u9500\u7684\u573a\u666f\uff0c\u4f8b\u5982\u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5\u3002\u8bbe\u5b9aQPS\u9608\u503c\u4e3a3\uff0c\u6d41\u63a7\u6548\u679c\u4e3awarm up\uff0c\u9884\u70ed\u65f6\u957f\u4e3a5\u79d2\uff0c\u8fd9\u6837\u914d\u7f6e\u4e4b\u540e\u6709\u4ec0\u4e48\u6548\u679c\u5462\uff1aQPS\u8d77\u521d\u4f1a\u4ece(3\/3\/=1)\u6bcf\u79d2\u901a\u8fc7\u4e00\u6b21\u8bf7\u6c42\u5f00\u59cb\u9884\u70ed\u76f4\u52305\u79d2\u4e4b\u540e\u8fbe\u5230\u6bcf\u79d2\u901a\u8fc73\u6b21\u8bf7\u6c42\uff1b\u524d\u51e0\u79d2\u662f\u9891\u7e41\u6d41\u63a7\u7684\uff0c\u76f4\u52305\u79d2\uff0cQPS\u9608\u503c\u8fbe\u5230\u4e863\u3002<\/li>\n<\/ul>\n
\u8bbe\u7f6e\u76f8\u5e94\u6d41\u63a7\u89c4\u5219\uff0c\u6d41\u63a7\u6548\u679c\u9009\u62e9Warm Up<\/p>\n
<\/p>\n
\u6709\u6fc0\u589e\u7684\u6d41\u91cf\u6301\u7eed\u8bf7\u6c42\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3http:\/\/localhost:4070\/query-order\uff0c\u67e5\u770b\u5b9e\u65f6\u76d1\u63a7\u6570\u636e\uff0c\u6709\u4e00\u4e2a\u6162\u6162\u9884\u70ed\u7684\u8fc7\u7a0b<\/p>\n
<\/p>\n
\u5300\u901f\u6392\u961f<\/h5>\n\n- \u5300\u901f\u6392\u961f\u65b9\u5f0f\u4f1a\u4e25\u683c\u63a7\u5236\u8bf7\u6c42\u901a\u8fc7\u7684\u95f4\u9694\u65f6\u95f4\uff0c\u4e5f\u5373\u662f\u8ba9\u8bf7\u6c42\u4ee5\u5747\u5300\u7684\u901f\u5ea6\u901a\u8fc7\uff0c\u5bf9\u5e94\u7684\u662f\u6f0f\u6876\u7b97\u6cd5<\/strong>\u3002\u6709\u4e2a\u8d85\u65f6\u7b49\u5f85\u65f6\u95f4\uff0c\u4e00\u65e6\u8d85\u8fc7\u8fd9\u4e2a\u9884\u5b9a\u8bbe\u7f6e\u7684\u65f6\u95f4\u5c06\u4f1a\u88ab\u9650\u6d41\u3002<\/li>\n
- \u9002\u5408\u7528\u4e8e\u8bf7\u6c42\u4ee5\u7a81\u523a\u72b6\u6765\u5230\uff0c\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u4e0d\u5e0c\u671b\u4e00\u4e0b\u5b50\u628a\u6240\u6709\u7684\u8bf7\u6c42\u90fd\u901a\u8fc7\uff0c\u8fd9\u6837\u53ef\u80fd\u4f1a\u628a\u7cfb\u7edf\u538b\u57ae\uff1b\u540c\u65f6\u6211\u4eec\u4e5f\u671f\u5f85\u7cfb\u7edf\u4ee5\u7a33\u5b9a\u7684\u901f\u5ea6\uff0c\u9010\u6b65\u5904\u7406\u8fd9\u4e9b\u8bf7\u6c42\uff0c\u4ee5\u8d77\u5230\u201c\u524a\u5cf0\u586b\u8c37<\/strong>\u201d\u7684\u6548\u679c\uff0c\u800c\u4e0d\u662f\u62d2\u7edd\u6240\u6709\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n
\u7194\u65ad\u964d\u7ea7<\/h3>\n\u6982\u8ff0<\/h4>\n
\u9664\u4e86\u6d41\u91cf\u63a7\u5236\u4ee5\u5916\uff0c\u5bf9\u8c03\u7528\u94fe\u8def\u4e2d\u4e0d\u7a33\u5b9a\u7684\u8d44\u6e90\u8fdb\u884c\u7194\u65ad\u964d\u7ea7\u4e5f\u662f\u4fdd\u969c\u9ad8\u53ef\u7528\u7684\u91cd\u8981\u63aa\u65bd\u4e4b\u4e00\u3002\u4e00\u4e2a\u670d\u52a1\u5e38\u5e38\u4f1a\u8c03\u7528\u522b\u7684\u6a21\u5757\uff0c\u53ef\u80fd\u662f\u53e6\u5916\u7684\u4e00\u4e2a\u8fdc\u7a0b\u670d\u52a1\u3001\u6570\u636e\u5e93\uff0c\u6216\u8005\u7b2c\u4e09\u65b9 API \u7b49\u3002\u4f8b\u5982\uff0c\u652f\u4ed8\u7684\u65f6\u5019\uff0c\u53ef\u80fd\u9700\u8981\u8fdc\u7a0b\u8c03\u7528\u94f6\u8054\u63d0\u4f9b\u7684 API\uff1b\u67e5\u8be2\u67d0\u4e2a\u5546\u54c1\u7684\u4ef7\u683c\uff0c\u53ef\u80fd\u9700\u8981\u8fdb\u884c\u6570\u636e\u5e93\u67e5\u8be2\u3002\u7136\u800c\uff0c\u8fd9\u4e2a\u88ab\u4f9d\u8d56\u670d\u52a1\u7684\u7a33\u5b9a\u6027\u662f\u4e0d\u80fd\u4fdd\u8bc1\u7684\u3002\u5982\u679c\u4f9d\u8d56\u7684\u670d\u52a1\u51fa\u73b0\u4e86\u4e0d\u7a33\u5b9a\u7684\u60c5\u51b5\uff0c\u8bf7\u6c42\u7684\u54cd\u5e94\u65f6\u95f4\u53d8\u957f\uff0c\u90a3\u4e48\u8c03\u7528\u670d\u52a1\u7684\u65b9\u6cd5\u7684\u54cd\u5e94\u65f6\u95f4\u4e5f\u4f1a\u53d8\u957f\uff0c\u7ebf\u7a0b\u4f1a\u4ea7\u751f\u5806\u79ef\uff0c\u6700\u7ec8\u53ef\u80fd\u8017\u5c3d\u4e1a\u52a1\u81ea\u8eab\u7684\u7ebf\u7a0b\u6c60\uff0c\u670d\u52a1\u672c\u8eab\u4e5f\u53d8\u5f97\u4e0d\u53ef\u7528\u3002<\/p>\n
<\/p>\n
\u73b0\u4ee3\u5fae\u670d\u52a1\u67b6\u6784\u90fd\u662f\u5206\u5e03\u5f0f\u7684\uff0c\u7531\u975e\u5e38\u591a\u7684\u670d\u52a1\u7ec4\u6210\u3002\u4e0d\u540c\u670d\u52a1\u4e4b\u95f4\u76f8\u4e92\u8c03\u7528\uff0c\u7ec4\u6210\u590d\u6742\u7684\u8c03\u7528\u94fe\u8def\u3002\u4ee5\u4e0a\u7684\u95ee\u9898\u5728\u94fe\u8def\u8c03\u7528\u4e2d\u4f1a\u4ea7\u751f\u653e\u5927\u7684\u6548\u679c\u3002\u590d\u6742\u94fe\u8def\u4e0a\u7684\u67d0\u4e00\u73af\u4e0d\u7a33\u5b9a\uff0c\u5c31\u53ef\u80fd\u4f1a\u5c42\u5c42\u7ea7\u8054\uff0c\u6700\u7ec8\u5bfc\u81f4\u6574\u4e2a\u94fe\u8def\u90fd\u4e0d\u53ef\u7528\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5bf9\u4e0d\u7a33\u5b9a\u7684\u5f31\u4f9d\u8d56\u670d\u52a1\u8c03\u7528<\/strong>\u8fdb\u884c\u7194\u65ad\u964d\u7ea7\uff0c\u6682\u65f6\u5207\u65ad\u4e0d\u7a33\u5b9a\u8c03\u7528\uff0c\u907f\u514d\u5c40\u90e8\u4e0d\u7a33\u5b9a\u56e0\u7d20\u5bfc\u81f4\u6574\u4f53\u7684\u96ea\u5d29\u3002\u7194\u65ad\u964d\u7ea7\u4f5c\u4e3a\u4fdd\u62a4\u81ea\u8eab\u7684\u624b\u6bb5\uff0c\u901a\u5e38\u5728\u5ba2\u6237\u7aef\uff08\u8c03\u7528\u7aef\uff09\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n\u7194\u65ad\u7b56\u7565<\/h4>\n
Sentinel \u63d0\u4f9b\u4ee5\u4e0b\u51e0\u79cd\u7194\u65ad\u7b56\u7565\uff1a<\/p>\n
\n- \u6162\u8c03\u7528\u6bd4\u4f8b (
SLOW_REQUEST_RATIO<\/code>)\uff1a\u9009\u62e9\u4ee5\u6162\u8c03\u7528\u6bd4\u4f8b\u4f5c\u4e3a\u9608\u503c\uff0c\u9700\u8981\u8bbe\u7f6e\u5141\u8bb8\u7684\u6162\u8c03\u7528 RT\uff08\u5373\u6700\u5927\u7684\u54cd\u5e94\u65f6\u95f4\uff09\uff0c\u8bf7\u6c42\u7684\u54cd\u5e94\u65f6\u95f4\u5927\u4e8e\u8be5\u503c\u5219\u7edf\u8ba1\u4e3a\u6162\u8c03\u7528\u3002\u5f53\u5355\u4f4d\u7edf\u8ba1\u65f6\u957f\uff08statIntervalMs<\/code>\uff09\u5185\u8bf7\u6c42\u6570\u76ee\u5927\u4e8e\u8bbe\u7f6e\u7684\u6700\u5c0f\u8bf7\u6c42\u6570\u76ee\uff0c\u5e76\u4e14\u6162\u8c03\u7528\u7684\u6bd4\u4f8b\u5927\u4e8e\u9608\u503c\uff0c\u5219\u63a5\u4e0b\u6765\u7684\u7194\u65ad\u65f6\u957f\u5185\u8bf7\u6c42\u4f1a\u81ea\u52a8\u88ab\u7194\u65ad\u3002\u7ecf\u8fc7\u7194\u65ad\u65f6\u957f\u540e\u7194\u65ad\u5668\u4f1a\u8fdb\u5165\u63a2\u6d4b\u6062\u590d\u72b6\u6001\uff08HALF-OPEN \u72b6\u6001\uff09\uff0c\u82e5\u63a5\u4e0b\u6765\u7684\u4e00\u4e2a\u8bf7\u6c42\u54cd\u5e94\u65f6\u95f4\u5c0f\u4e8e\u8bbe\u7f6e\u7684\u6162\u8c03\u7528 RT \u5219\u7ed3\u675f\u7194\u65ad\uff0c\u82e5\u5927\u4e8e\u8bbe\u7f6e\u7684\u6162\u8c03\u7528 RT \u5219\u4f1a\u518d\u6b21\u88ab\u7194\u65ad\u3002<\/li>\n- \u5f02\u5e38\u6bd4\u4f8b (
ERROR_RATIO<\/code>)\uff1a\u5f53\u5355\u4f4d\u7edf\u8ba1\u65f6\u957f\uff08statIntervalMs<\/code>\uff09\u5185\u8bf7\u6c42\u6570\u76ee\u5927\u4e8e\u8bbe\u7f6e\u7684\u6700\u5c0f\u8bf7\u6c42\u6570\u76ee\uff0c\u5e76\u4e14\u5f02\u5e38\u7684\u6bd4\u4f8b\u5927\u4e8e\u9608\u503c\uff0c\u5219\u63a5\u4e0b\u6765\u7684\u7194\u65ad\u65f6\u957f\u5185\u8bf7\u6c42\u4f1a\u81ea\u52a8\u88ab\u7194\u65ad\u3002\u7ecf\u8fc7\u7194\u65ad\u65f6\u957f\u540e\u7194\u65ad\u5668\u4f1a\u8fdb\u5165\u63a2\u6d4b\u6062\u590d\u72b6\u6001\uff08HALF-OPEN \u72b6\u6001\uff09\uff0c\u82e5\u63a5\u4e0b\u6765\u7684\u4e00\u4e2a\u8bf7\u6c42\u6210\u529f\u5b8c\u6210\uff08\u6ca1\u6709\u9519\u8bef\uff09\u5219\u7ed3\u675f\u7194\u65ad\uff0c\u5426\u5219\u4f1a\u518d\u6b21\u88ab\u7194\u65ad\u3002\u5f02\u5e38\u6bd4\u7387\u7684\u9608\u503c\u8303\u56f4\u662f [0.0, 1.0]<\/code>\uff0c\u4ee3\u8868 0% - 100%\u3002<\/li>\n- \u5f02\u5e38\u6570 (
ERROR_COUNT<\/code>)\uff1a\u5f53\u5355\u4f4d\u7edf\u8ba1\u65f6\u957f\u5185\u7684\u5f02\u5e38\u6570\u76ee\u8d85\u8fc7\u9608\u503c\u4e4b\u540e\u4f1a\u81ea\u52a8\u8fdb\u884c\u7194\u65ad\u3002\u7ecf\u8fc7\u7194\u65ad\u65f6\u957f\u540e\u7194\u65ad\u5668\u4f1a\u8fdb\u5165\u63a2\u6d4b\u6062\u590d\u72b6\u6001\uff08HALF-OPEN \u72b6\u6001\uff09\uff0c\u82e5\u63a5\u4e0b\u6765\u7684\u4e00\u4e2a\u8bf7\u6c42\u6210\u529f\u5b8c\u6210\uff08\u6ca1\u6709\u9519\u8bef\uff09\u5219\u7ed3\u675f\u7194\u65ad\uff0c\u5426\u5219\u4f1a\u518d\u6b21\u88ab\u7194\u65ad\u3002<\/li>\n<\/ul>\n\u6162\u8c03\u7528\u6bd4\u4f8b<\/h4>\n
\u5728\u6dfb\u52a0\u8ba2\u5355\u63a5\u53e3\u4f11\u7720\u4e24\u79d2\u6765\u6f14\u793a<\/p>\n
\u5728\u7c07\u70b9\u94fe\u8def<\/strong>\u70b9\u51fb\u7194\u65ad\u6309\u94ae\u8fdb\u884c\u8bbe\u7f6e<\/p>\n<\/p>\n
\u5148\u7528\u7528apifox\u591a\u4e2a\u7ebf\u7a0b\u8c03\u7528http:\/\/localhost:4070\/add-order<\/p>\n
<\/p>\n
\u518d\u8bbf\u95eehttp:\/\/localhost:4070\/add-order\uff0c\u663e\u793a\u5f53\u524d\u8bf7\u6c42\u88ab\u6d41\u91cf\u9650\u5236\u4e86<\/p>\n
<\/p>\n
\u5f02\u5e38\u6bd4\u4f8b<\/h4>\n
\u5728\u6dfb\u52a0\u8ba2\u5355\u63a5\u53e3\u4e2d\u6dfb\u52a0\u5f02\u5e38\u4ee3\u7801<\/p>\n
<\/p>\n
\u8bbe\u7f6e\u89c4\u5219<\/p>\n
<\/p>\n
\u540c\u6837\u5148\u7528apifox\u591a\u4e2a\u7ebf\u7a0b\u8c03\u7528http:\/\/localhost:4070\/add-order\uff0c\u7136\u540e\u518d\u8bbf\u95eehttp:\/\/localhost:4070\/add-order\uff0c\u663e\u793a\u5f53\u524d\u8bf7\u6c42\u88ab\u6d41\u91cf\u9650\u5236\u4e86<\/p>\n
<\/p>\n
\u540c\u6837\u5f02\u5e38\u6570\u7684\u8bbe\u7f6e\u4e5f\u662f\u5982\u6b64<\/p>\n
<\/p>\n
\u70ed\u70b9\u53c2\u6570\u9650\u6d41<\/h3>\n\n- \u70ed\u70b9\u5373\u7ecf\u5e38\u8bbf\u95ee\u7684\u6570\u636e\u3002\u5f88\u591a\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u7edf\u8ba1\u67d0\u4e2a\u70ed\u70b9\u6570\u636e\u4e2d\u8bbf\u95ee\u9891\u6b21\u6700\u9ad8\u7684 Top K \u6570\u636e\uff0c\u5e76\u5bf9\u5176\u8bbf\u95ee\u8fdb\u884c\u9650\u5236\u3002\u6bd4\u5982\u5546\u54c1 ID \u4e3a\u53c2\u6570\uff0c\u7edf\u8ba1\u4e00\u6bb5\u65f6\u95f4\u5185\u6700\u5e38\u8d2d\u4e70\u7684\u5546\u54c1 ID \u5e76\u8fdb\u884c\u9650\u5236\u3002<\/li>\n
- \u70ed\u70b9\u53c2\u6570\u9650\u6d41\u4f1a\u7edf\u8ba1\u4f20\u5165\u53c2\u6570\u4e2d\u7684\u70ed\u70b9\u53c2\u6570\uff0c\u5e76\u6839\u636e\u914d\u7f6e\u7684\u9650\u6d41\u9608\u503c\u4e0e\u6a21\u5f0f\uff0c\u5bf9\u5305\u542b\u70ed\u70b9\u53c2\u6570\u7684\u8d44\u6e90\u8c03\u7528\u8fdb\u884c\u9650\u6d41\u3002\u70ed\u70b9\u53c2\u6570\u9650\u6d41\u53ef\u4ee5\u770b\u505a\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6d41\u91cf\u63a7\u5236\uff0c\u4ec5\u5bf9\u5305\u542b\u70ed\u70b9\u53c2\u6570\u7684\u8d44\u6e90\u8c03\u7528\u751f\u6548\u3002<\/li>\n
- Sentinel \u5229\u7528 LRU \u7b56\u7565\u7edf\u8ba1\u6700\u8fd1\u6700\u5e38\u8bbf\u95ee\u7684\u70ed\u70b9\u53c2\u6570\uff0c\u7ed3\u5408\u4ee4\u724c\u6876\u7b97\u6cd5\u6765\u8fdb\u884c\u53c2\u6570\u7ea7\u522b\u7684\u6d41\u63a7\u3002<\/li>\n<\/ul>\n
\u70ed\u70b9\u53c2\u6570\u89c4\u5219\uff08ParamFlowRule<\/code>\uff09\u7c7b\u4f3c\u4e8e\u524d\u9762\u5217\u51fa\u6d41\u91cf\u63a7\u5236\u89c4\u5219\uff08FlowRule<\/code>\uff09\uff0c\u8be6\u7ec6\u53ef\u4ee5\u67e5\u9605\u5b98\u7f51<\/p>\n\u521b\u5efa\u6d4b\u8bd5\u65b9\u6cd5,\u5e26\u8def\u5f84\u53d8\u91cf\u53c2\u6570<\/p>\n
@RequestMapping<\/span>(<\/span>\"\/get\/{id}\"<\/span>)<\/span> public<\/span> String<\/span> getByOrderId<\/span>(<\/span>@PathVariable<\/span>(<\/span>\"id\"<\/span>)<\/span> Integer<\/span> id)<\/span>{ \n <\/span> log.<\/span>info<\/span>(<\/span>\"getByOrderId id={}\"<\/span>,<\/span>id)<\/span>;<\/span> return<\/span> \"\u67e5\u8be2\u8ba2\u5355\u6b63\u5e38\"<\/span>;<\/span> }<\/span> <\/code><\/pre>\n\u542f\u52a8\u7a0b\u5e8f\uff0c\u8bbf\u95eehttp:\/\/localhost:4070\/order\/get\/1<\/p>\n
<\/p>\n
\u8bbe\u7f6e\u70ed\u70b9\u89c4\u5219<\/p>\n
<\/p>\n
\u70b9\u51fb\u7f16\u8f91\u8fdb\u5165\u8bbe\u7f6e\u9ad8\u7ea7\u9009\u9879\uff0c\u589e\u52a0\u53c2\u6570\u4f8b\u5916\u9879\uff0c\u70b9\u51fb\u6dfb\u52a0<\/p>\n
<\/p>\n
\u8bbf\u95eehttp:\/\/localhost:4070\/order\/get\/2 \u5219\u53ef\u4ee5\u6b63\u5e38\uff0c\u4e0d\u53d7\u9650\u6d41\u9608\u503c2\u7684\u9650\u5236\uff0c\u800c\u8fde\u7eed\u8bbf\u95eehttp:\/\/localhost:4070\/order\/get\/1 \u5219\u51fa\u73b0\u9650\u6d41<\/p>\n
<\/p>\n
\u7edf\u4e00\u5f02\u5e38\u5904\u7406<\/h3>\n
\u7edf\u4e00\u5f02\u5e38\u5904\u7406\u9002\u5408\u5bf9BlockException\u8fd4\u56de\u7684\u4fe1\u606f\u5904\u7406\u662f\u4e00\u6837\u7684\uff0c\u5982\u679c\u4e0d\u4e00\u6837\u5219\u8fd8\u662f\u9700\u8981\u4f7f\u7528@SentinelResource<\/p>\n
\u521b\u5efa\u7edf\u4e00\u8fd4\u56de\u5b9e\u4f53\u7c7bResult<\/p>\n
package<\/span> cn