{"id":8193,"date":"2024-06-19T09:01:01","date_gmt":"2024-06-19T01:01:01","guid":{"rendered":""},"modified":"2024-06-19T09:01:01","modified_gmt":"2024-06-19T01:01:01","slug":"spring cloud \u6d41\u91cf\u63a7\u5236_dubbo\u5b9e\u6218\u4e0e\u6e90\u7801\u5206\u6790","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8193.html","title":{"rendered":"spring cloud \u6d41\u91cf\u63a7\u5236_dubbo\u5b9e\u6218\u4e0e\u6e90\u7801\u5206\u6790"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u5b9e\u6218\u793a\u4f8b<\/h2>\n

\u63a7\u5236\u53f0\u521d\u4f53\u9a8c<\/h3>\n

Sentinel\u7684\u63a7\u5236\u53f0\u542f\u52a8\u540e\uff0c\u63a7\u5236\u53f0\u9875\u9762\u7684\u5185\u5bb9\u6570\u636e\u90fd\u662f\u7a7a\u7684\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u9010\u6b65\u64cd\u4f5c\u6f14\u793a\u7ed3\u5408\u63a7\u5236\u53f0\u7684\u4f7f\u7528\uff0c\u5728\u4e0a\u4e00\u8282\u4e5f\u5df2\u8bf4\u660e\u6574\u5408SpringCloud Alibaba\u7b2c\u4e00\u6b65\u5148\u52a0\u5165spring-cloud-starter-alibaba-sentinel\u542f\u52a8\u5668\u4f9d\u8d56<\/p>\n

\"spring<\/p>\n

\u914d\u7f6e\u6587\u4ef6\u6dfb\u52a0\u53c2\u6570\uff0cdashboard\u5373\u4e3a\u63a7\u5236\u53f0\u7684\u7aef\u53e3\uff0c\u6211\u4eec\u662f\u672c\u5730\u542f\u52a8\u4f7f\u75288858\u7aef\u53e3<\/p>\n

spring<\/span>:<\/span> cloud<\/span>:<\/span> sentinel<\/span>:<\/span> enabled<\/span>:<\/span> true<\/span> transport<\/span>:<\/span> dashboard<\/span>:<\/span> localhost:<\/span>8858<\/span> port<\/span>:<\/span> 8719<\/span> <\/code><\/pre>\n

\u8ba2\u5355\u6dfb\u52a0\u63a7\u5236\u5668\u4e2d\u6709\u4e00\u4e2a\u8ba2\u5355\u6dfb\u52a0\u7684\u63a5\u53e3<\/p>\n

\"spring<\/p>\n

\u542f\u52a8\u8ba2\u5355\u5fae\u670d\u52a1\u7a0b\u5e8f\uff0c\u8bbf\u95ee\u8ba2\u5355\u63a7\u5236\u5668\u7684\u6dfb\u52a0\u8ba2\u5355\u63a5\u53e3\uff0chttp:\/\/localhost:4070\/add-order<\/p>\n

\"spring<\/p>\n

\u7136\u540e\u518d\u67e5\u770bsentinel\u7684\u63a7\u5236\u53f0\u9996\u9875-\u7c07\u70b9\u94fe\u8def\uff0c\u8fd9\u65f6\u5df2\u7ecf\u6709\/add-order\u8fd9\u4e2a\u8d44\u6e90\u540d\u7684\u6570\u636e<\/p>\n

\"spring<\/p>\n

\u591a\u6b21\u8bbf\u95ee\u540e\u5728\u5b9e\u65f6\u76d1\u63a7\u4e5f\u53ef\u4ee5\u770b\u5230\u76f8\u5e94\u8d44\u6e90\u7684\u5b9e\u65f6QPS\u7edf\u8ba1\u6570\u636e<\/p>\n

\"spring<\/p>\n

    \n
  • Sentinel \u7684\u6240\u6709\u89c4\u5219\u90fd\u53ef\u4ee5\u5728\u5185\u5b58\u6001\u4e2d\u52a8\u6001\u5730\u67e5\u8be2\u53ca\u4fee\u6539\uff0c\u4fee\u6539\u4e4b\u540e\u7acb\u5373\u751f\u6548\u3002\u540c\u65f6 Sentinel \u4e5f\u63d0\u4f9b\u76f8\u5173 API\u6765\u5b9a\u5236\u81ea\u5df1\u7684\u89c4\u5219\u7b56\u7565\u3002<\/li>\n
  • Sentinel \u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\u89c4\u5219\uff1a\u6d41\u91cf\u63a7\u5236\u89c4\u5219<\/strong>\u3001\u7194\u65ad\u964d\u7ea7\u89c4\u5219<\/strong>\u3001\u7cfb\u7edf\u4fdd\u62a4\u89c4\u5219<\/strong>\u3001\u6765\u6e90\u8bbf\u95ee\u63a7\u5236\u89c4\u5219<\/strong> \u548c \u70ed\u70b9\u53c2\u6570\u89c4\u5219<\/strong>\u3002<\/li>\n
  • \n

    \u6d41\u63a7\u89c4\u5219<\/h3>\n<\/li>\n<\/ul>\n

    \u5b9a\u4e49<\/h4>\n
      \n
    • \n

      \u6d41\u91cf\u63a7\u5236\uff1aSentinel\u7684\u6d41\u63a7\u7684\u539f\u7406\u4e3b\u8981\u662f\u76d1\u63a7\u5e94\u7528\u6d41\u91cf\u6216\u8005\u8bf4\u662f\u8d44\u6e90\u7684QPS\u6216\u8005\u5e76\u53d1\u7ebf\u7a0b\u6570\uff0c\u5f53\u8fbe\u5230\u6307\u5b9a\u7684\u9608\u503c\u540e\u5bf9\u6d41\u91cf\u8fdb\u884c\u63a7\u5236\uff0c\u4ee5\u907f\u514d\u88ab\u77ac\u65f6\u7684\u6d41\u91cf\u6d2a\u5cf0\u51b2\u57ae\uff0c\u4ece\u800c\u4fdd\u969c\u5e94\u7528\u7684\u9ad8\u53ef\u7528\u6027<\/p>\n<\/li>\n

    • \n

      QPS<\/strong>\uff1a\u6bcf\u79d2\u8bf7\u6c42\u6570\uff0c\u5373\u5728\u4e0d\u65ad\u5411\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u7684\u60c5\u51b5\u4e0b\uff0c\u670d\u52a1\u5668\u6bcf\u79d2\u80fd\u591f\u5904\u7406\u7684\u8bf7\u6c42\u6570\u91cf\u3002<\/p>\n<\/li>\n

    • \n

      \u5e76\u53d1\u7ebf\u7a0b\u6570<\/strong>\uff1a\u6307\u7684\u662f\u65bd\u538b\u673a\u65bd\u52a0\u7684\u540c\u65f6\u8bf7\u6c42\u7684\u7ebf\u7a0b\u6570\u91cf\u3002<\/p>\n<\/li>\n<\/ul>\n

      \"spring<\/p>\n

      \u6d41\u91cf\u89c4\u5219\u7684\u5b9a\u4e49\u7684\u91cd\u8981\u5c5e\u6027\uff1a<\/p>\n\n\n\n\n\n\n\n\n\n\n
      Field<\/th>\n\u8bf4\u660e<\/th>\n\u9ed8\u8ba4\u503c<\/th>\n<\/tr>\n<\/thead>\n
      resource<\/td>\n\u8d44\u6e90\u540d\uff0c\u8d44\u6e90\u540d\u662f\u9650\u6d41\u89c4\u5219\u7684\u4f5c\u7528\u5bf9\u8c61<\/td>\n<\/td>\n<\/tr>\n
      count<\/td>\n\u9650\u6d41\u9608\u503c<\/td>\n<\/td>\n<\/tr>\n
      grade<\/td>\n\u9650\u6d41\u9608\u503c\u7c7b\u578b\uff0cQPS \u6216\u7ebf\u7a0b\u6570\u6a21\u5f0f<\/td>\nQPS \u6a21\u5f0f<\/td>\n<\/tr>\n
      limitApp<\/td>\n\u6d41\u63a7\u9488\u5bf9\u7684\u8c03\u7528\u6765\u6e90<\/td>\ndefault<\/code>\uff0c\u4ee3\u8868\u4e0d\u533a\u5206\u8c03\u7528\u6765\u6e90<\/td>\n<\/tr>\n
      strategy<\/td>\n\u8c03\u7528\u5173\u7cfb\u9650\u6d41\u7b56\u7565\uff1a\u76f4\u63a5\u3001\u94fe\u8def\u3001\u5173\u8054<\/td>\n\u6839\u636e\u8d44\u6e90\u672c\u8eab\uff08\u76f4\u63a5\uff09<\/td>\n<\/tr>\n
      controlBehavior<\/td>\n\u6d41\u63a7\u6548\u679c\uff08\u76f4\u63a5\u62d2\u7edd \/ \u6392\u961f\u7b49\u5f85 \/ \u6162\u542f\u52a8\u6a21\u5f0f\uff09\uff0c\u4e0d\u652f\u6301\u6309\u8c03\u7528\u5173\u7cfb\u9650\u6d41<\/td>\n\u76f4\u63a5\u62d2\u7edd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

      FlowSlot<\/code> \u4f1a\u6839\u636e\u9884\u8bbe\u7684\u89c4\u5219\uff0c\u7ed3\u5408\u524d\u9762 NodeSelectorSlot<\/code>\u3001ClusterNodeBuilderSlot<\/code>\u3001StatistcSlot<\/code> \u7edf\u8ba1\u51fa\u6765\u7684\u5b9e\u65f6\u4fe1\u606f\u8fdb\u884c\u6d41\u91cf\u63a7\u5236\u3002\u540c\u4e00\u4e2a\u8d44\u6e90\u53ef\u4ee5\u5bf9\u5e94\u591a\u6761\u9650\u6d41\u89c4\u5219\u3002FlowSlot<\/code> \u4f1a\u5bf9\u8be5\u8d44\u6e90\u7684\u6240\u6709\u9650\u6d41\u89c4\u5219\u4f9d\u6b21\u904d\u5386\uff0c\u76f4\u5230\u6709\u89c4\u5219\u89e6\u53d1\u9650\u6d41\u6216\u8005\u6240\u6709\u89c4\u5219\u904d\u5386\u5b8c\u6bd5\u3002\u4e00\u6761\u9650\u6d41\u89c4\u5219\u4e3b\u8981\u7531\u4e0b\u9762\u51e0\u4e2a\u56e0\u7d20\u7ec4\u6210\uff0c\u53ef\u4ee5\u7ec4\u5408\u8fd9\u4e9b\u5143\u7d20\u6765\u5b9e\u73b0\u4e0d\u540c\u7684\u9650\u6d41\u6548\u679c\uff1a<\/p>\n

        \n
      • resource<\/code>\uff1a\u8d44\u6e90\u540d\uff0c\u5373\u9650\u6d41\u89c4\u5219\u7684\u4f5c\u7528\u5bf9\u8c61<\/li>\n
      • count<\/code>: \u9650\u6d41\u9608\u503c<\/li>\n
      • grade<\/code>: \u9650\u6d41\u9608\u503c\u7c7b\u578b\uff0cQPS \u6216\u7ebf\u7a0b\u6570<\/li>\n
      • 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

        \"spring<\/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

        \"spring<\/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

        \"spring<\/p>\n

        \u8bbe\u7f6e\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3\u7684\u6d41\u63a7\u89c4\u5219<\/p>\n

        \"spring<\/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

        \"spring<\/p>\n

        \u5feb\u901f\u8bbf\u95ee\u8ba2\u5355\u63a7\u5236\u5668\u7684\u67e5\u8be2\u8ba2\u5355\u63a5\u53e3<\/p>\n

        \"spring<\/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

        \"spring<\/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

        \"spring<\/p>\n

        \u7b2c\u4e8c\u4e2a\u9875\u9762\u5c31\u663e\u793a\u88ab\u6d41\u63a7\u4e86<\/p>\n

        \"spring<\/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

          \"spring<\/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

          \"spring<\/p>\n

          \u542f\u52a8\u6301\u7eed\u7684\u8bbf\u95ee\u8ba2\u5355\u67e5\u8be2\u63a5\u53e3<\/p>\n

          \"spring<\/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

          \"spring<\/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

          \"spring<\/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>\n

          Warm Up<\/h5>\n
            \n
          • Sentinel\u7684Warm Up\uff08RuleConstant.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

            \"spring<\/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

            \"spring<\/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

              \"spring<\/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\"spring<\/p>\n

                \u5728\u7c07\u70b9\u94fe\u8def<\/strong>\u70b9\u51fb\u7194\u65ad\u6309\u94ae\u8fdb\u884c\u8bbe\u7f6e<\/p>\n

                \"spring<\/p>\n

                \u5148\u7528\u7528apifox\u591a\u4e2a\u7ebf\u7a0b\u8c03\u7528http:\/\/localhost:4070\/add-order<\/p>\n

                \"spring<\/p>\n

                \u518d\u8bbf\u95eehttp:\/\/localhost:4070\/add-order\uff0c\u663e\u793a\u5f53\u524d\u8bf7\u6c42\u88ab\u6d41\u91cf\u9650\u5236\u4e86<\/p>\n

                \"spring<\/p>\n

                \u5f02\u5e38\u6bd4\u4f8b<\/h4>\n

                \u5728\u6dfb\u52a0\u8ba2\u5355\u63a5\u53e3\u4e2d\u6dfb\u52a0\u5f02\u5e38\u4ee3\u7801<\/p>\n

                \"spring<\/p>\n

                \u8bbe\u7f6e\u89c4\u5219<\/p>\n

                \"spring<\/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

                \"spring<\/p>\n

                \u540c\u6837\u5f02\u5e38\u6570\u7684\u8bbe\u7f6e\u4e5f\u662f\u5982\u6b64<\/p>\n

                \"spring<\/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

                  \"spring<\/p>\n

                  \u8bbe\u7f6e\u70ed\u70b9\u89c4\u5219<\/p>\n

                  \"spring<\/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

                  \"spring<\/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

                  \"spring<\/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.<\/span>itxs.<\/span>ecom.<\/span>commons.<\/span>entity<\/span>;<\/span> public<\/span> class<\/span> Result<\/span><<\/span>T<\/span>><\/span><\/span> { \n   <\/span> private<\/span> Integer<\/span> code;<\/span> private<\/span> String<\/span> msg;<\/span> private<\/span> T<\/span> data;<\/span> public<\/span> Result<\/span>(<\/span>Integer<\/span> code,<\/span> String<\/span> msg,<\/span> T<\/span> data)<\/span> { \n   <\/span> this<\/span>.<\/span>code =<\/span> code;<\/span> this<\/span>.<\/span>msg =<\/span> msg;<\/span> this<\/span>.<\/span>data =<\/span> data;<\/span> }<\/span> public<\/span> Result<\/span>(<\/span>Integer<\/span> code,<\/span> String<\/span> msg)<\/span> { \n   <\/span> this<\/span>.<\/span>code =<\/span> code;<\/span> this<\/span>.<\/span>msg =<\/span> msg;<\/span> }<\/span> public<\/span> Integer<\/span> getCode<\/span>(<\/span>)<\/span> { \n   <\/span> return<\/span> code;<\/span> }<\/span> public<\/span> void<\/span> setCode<\/span>(<\/span>Integer<\/span> code)<\/span> { \n   <\/span> this<\/span>.<\/span>code =<\/span> code;<\/span> }<\/span> public<\/span> String<\/span> getMsg<\/span>(<\/span>)<\/span> { \n   <\/span> return<\/span> msg;<\/span> }<\/span> public<\/span> void<\/span> setMsg<\/span>(<\/span>String<\/span> msg)<\/span> { \n   <\/span> this<\/span>.<\/span>msg =<\/span> msg;<\/span> }<\/span> public<\/span> T<\/span> getData<\/span>(<\/span>)<\/span> { \n   <\/span> return<\/span> data;<\/span> }<\/span> public<\/span> void<\/span> setData<\/span>(<\/span>T<\/span> data)<\/span> { \n   <\/span> this<\/span>.<\/span>data =<\/span> data;<\/span> }<\/span> public<\/span> static<\/span> Result<\/span> error<\/span>(<\/span>Integer<\/span> code,<\/span>String<\/span> msg)<\/span>{ \n   <\/span> return<\/span> new<\/span> Result<\/span>(<\/span>code,<\/span>msg)<\/span>;<\/span> }<\/span> }<\/span> <\/code><\/pre>\n

                  \u6dfb\u52a0ItxsBlockExceptionHandler.java<\/p>\n

                  package<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>order.<\/span>exception<\/span>;<\/span> import<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>commons.<\/span>entity.<\/span><\/span>Result<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>csp.<\/span>sentinel.<\/span>adapter.<\/span>spring.<\/span>webmvc.<\/span>callback.<\/span><\/span>BlockExceptionHandler<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>csp.<\/span>sentinel.<\/span>slots.<\/span>block.<\/span><\/span>BlockException<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>csp.<\/span>sentinel.<\/span>slots.<\/span>block.<\/span>authority.<\/span><\/span>AuthorityException<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>csp.<\/span>sentinel.<\/span>slots.<\/span>block.<\/span>degrade.<\/span><\/span>DegradeException<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>csp.<\/span>sentinel.<\/span>slots.<\/span>block.<\/span>flow.<\/span><\/span>FlowException<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>csp.<\/span>sentinel.<\/span>slots.<\/span>block.<\/span>flow.<\/span>param.<\/span><\/span>ParamFlowException<\/span>;<\/span> import<\/span> com.<\/span>alibaba.<\/span>fastjson.<\/span><\/span>JSON;<\/span> import<\/span> lombok.<\/span>extern.<\/span>slf4j.<\/span><\/span>Slf4j<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>http.<\/span><\/span>MediaType<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>stereotype.<\/span><\/span>Component<\/span>;<\/span> import<\/span> javax.<\/span>servlet.<\/span>http.<\/span><\/span>HttpServletRequest<\/span>;<\/span> import<\/span> javax.<\/span>servlet.<\/span>http.<\/span><\/span>HttpServletResponse<\/span>;<\/span> import<\/span> java.<\/span>io.<\/span><\/span>IOException<\/span>;<\/span> import<\/span> java.<\/span>io.<\/span><\/span>PrintWriter<\/span>;<\/span> @Component<\/span> @Slf4j<\/span> public<\/span> class<\/span> ItxsBlockExceptionHandler<\/span> implements<\/span> BlockExceptionHandler<\/span> { \n   <\/span> @Override<\/span> public<\/span> void<\/span> handle<\/span>(<\/span>HttpServletRequest<\/span> request,<\/span> HttpServletResponse<\/span> response,<\/span> BlockException<\/span> e)<\/span> throws<\/span> IOException<\/span> { \n   <\/span> \/\/getRule\u8fd4\u56de\u8d44\u6e90\u3001\u89c4\u5219\u7684\u8be6\u7ec6\u4fe1\u606f<\/span> log.<\/span>info<\/span>(<\/span>\"BlockExceptionHandler BlockException================\"<\/span>+<\/span>e.<\/span>getRule<\/span>(<\/span>)<\/span>)<\/span>;<\/span> Result<\/span> r =<\/span> null<\/span>;<\/span> if<\/span>(<\/span>e instanceof<\/span> FlowException<\/span>)<\/span>{ \n   <\/span> r =<\/span> Result<\/span>.<\/span>error<\/span>(<\/span>400<\/span>,<\/span>\"\u54c8\u54c8\u54c8\uff0c\u7edf\u4e00\u5904\u7406\u65b9\u6cd5\u5904\u63a5\u53e3\u88ab\u9650\u6d41\u4e86\"<\/span>)<\/span>;<\/span> }<\/span>else<\/span> if<\/span> (<\/span>e instanceof<\/span> DegradeException<\/span>)<\/span>{ \n   <\/span> r =<\/span> Result<\/span>.<\/span>error<\/span>(<\/span>401<\/span>,<\/span>\"\u54c8\u54c8\u54c8\uff0c\u7edf\u4e00\u5904\u7406\u65b9\u6cd5\u5904\u670d\u52a1\u964d\u7ea7\u4e86\"<\/span>)<\/span>;<\/span> }<\/span>else<\/span> if<\/span> (<\/span>e instanceof<\/span> ParamFlowException<\/span>)<\/span>{ \n   <\/span> r =<\/span> Result<\/span>.<\/span>error<\/span>(<\/span>402<\/span>,<\/span>\"\u54c8\u54c8\u54c8\uff0c\u7edf\u4e00\u5904\u7406\u65b9\u6cd5\u5904\u70ed\u70b9\u53c2\u6570\u9650\u6d41\u4e86\"<\/span>)<\/span>;<\/span> }<\/span>else<\/span> if<\/span> (<\/span>e instanceof<\/span> AuthorityException<\/span>)<\/span>{ \n   <\/span> r =<\/span> Result<\/span>.<\/span>error<\/span>(<\/span>404<\/span>,<\/span>\"\u54c8\u54c8\u54c8\uff0c\u7edf\u4e00\u5904\u7406\u65b9\u6cd5\u5904\u7406\u6388\u6743\u89c4\u5219\u4e0d\u901a\u8fc7\"<\/span>)<\/span>;<\/span> }<\/span>else<\/span> if<\/span> (<\/span>e instanceof<\/span> SystemBlockException<\/span>)<\/span>{ \n   <\/span> r =<\/span> Result<\/span>.<\/span>error<\/span>(<\/span>405<\/span>,<\/span>\"\u54c8\u54c8\u54c8\uff0c\u7edf\u4e00\u5904\u7406\u65b9\u6cd5\u5904\u7406\u7cfb\u7edf\u89c4\u5219\u4e0d\u901a\u8fc7\"<\/span>)<\/span>;<\/span> }<\/span> \/\/\u8fd4\u56deJson\u6570\u636e<\/span> response.<\/span>setStatus<\/span>(<\/span>200<\/span>)<\/span>;<\/span> response.<\/span>setCharacterEncoding<\/span>(<\/span>\"UTF-8\"<\/span>)<\/span>;<\/span> response.<\/span>setContentType<\/span>(<\/span>MediaType<\/span>.<\/span>APPLICATION_JSON_VALUE)<\/span>;<\/span> PrintWriter<\/span> writer=<\/span>null<\/span>;<\/span> try<\/span> { \n   <\/span> writer=<\/span>response.<\/span>getWriter<\/span>(<\/span>)<\/span>;<\/span> writer.<\/span>write<\/span>(<\/span>JSON.<\/span>toJSONString<\/span>(<\/span>r)<\/span>)<\/span>;<\/span> writer.<\/span>flush<\/span>(<\/span>)<\/span>;<\/span> }<\/span> catch<\/span> (<\/span>IOException<\/span> ioException)<\/span> { \n   <\/span> log.<\/span>error<\/span>(<\/span>\"\u5f02\u5e38\uff1a{}\"<\/span>,<\/span>ioException)<\/span>;<\/span> }<\/span>finally<\/span> { \n   <\/span> if<\/span>(<\/span>writer!=<\/span>null<\/span>)<\/span> { \n   <\/span> writer.<\/span>close<\/span>(<\/span>)<\/span>;<\/span> }<\/span> }<\/span> }<\/span> }<\/span> <\/code><\/pre>\n

                  \u6d4b\u8bd5\u7684\u63a7\u5236\u5668\u5219\u65e0\u9700\u4f7f\u7528@SentinelResource<\/p>\n

                  \"spring<\/p>\n

                  \u542f\u52a8\u8bbf\u95eehttp:\/\/localhost:4070\/order\/add \uff0c\u7136\u540e\u8bbe\u7f6e\u6d41\u63a7\u89c4\u5219\uff0c\u518d\u6b21\u8bbf\u95ee\uff0c\u8fd9\u662f\u5219\u662f\u7edf\u4e00\u5f02\u5e38\u8fd4\u56de\u7ed3\u679c\uff0c\u914d\u7f6e\u7194\u65ad\u964d\u7ea7\u89c4\u5219\u547d\u4e2d\u4e5f\u662f\u5982\u6b64\u3002<\/p>\n

                  \"spring<\/p>\n

                  \u7cfb\u7edf\u89c4\u5219\u9650\u6d41<\/h3>\n

                  \u7cfb\u7edf\u4fdd\u62a4\u89c4\u5219\u662f\u4ece\u5e94\u7528\u7ea7\u522b\u7684\u5165\u53e3\u6d41\u91cf\u8fdb\u884c\u63a7\u5236\uff0c\u4ece\u5355\u53f0\u673a\u5668\u7684\u603b\u4f53 Load\u3001RT\u3001\u5165\u53e3 QPS \u548c\u7ebf\u7a0b\u6570\u56db\u4e2a\u7ef4\u5ea6\u76d1\u63a7\u5e94\u7528\u6570\u636e\uff0c\u8ba9\u7cfb\u7edf\u5c3d\u53ef\u80fd\u8dd1\u5728\u6700\u5927\u541e\u5410\u91cf\u7684\u540c\u65f6\u4fdd\u8bc1\u7cfb\u7edf\u6574\u4f53\u7684\u7a33\u5b9a\u6027\u3002\u7cfb\u7edf\u4fdd\u62a4\u89c4\u5219\u662f\u5e94\u7528\u6574\u4f53\u7ef4\u5ea6\u7684\uff0c\u800c\u4e0d\u662f\u8d44\u6e90\u7ef4\u5ea6\u7684\uff0c\u5e76\u4e14\u4ec5\u5bf9\u5165\u53e3\u6d41\u91cf\u751f\u6548<\/strong>\u3002\u5165\u53e3\u6d41\u91cf\u6307\u7684\u662f\u8fdb\u5165\u5e94\u7528\u7684\u6d41\u91cf\uff08EntryType.IN<\/code>\uff09\uff0c\u6bd4\u5982 Web \u670d\u52a1\u6216 Dubbo \u670d\u52a1\u7aef\u63a5\u6536\u7684\u8bf7\u6c42\uff0c\u90fd\u5c5e\u4e8e\u5165\u53e3\u6d41\u91cf\u3002\u5728\u7cfb\u7edf\u89c4\u5219\u4e2d\u8bbe\u7f6e\u9608\u503c\u7c7b\u578bCPU \uff0c\u9608\u503c\u4e3a0.1<\/p>\n

                  \"spring<\/p>\n

                  \u7531\u4e8e\u6211\u672c\u673aCPU\u4e00\u76f4\u9ad8\u4e8e10%\u7684\uff0c\u8bbf\u95eehttp:\/\/localhost:4070\/order\/add \u540e\u4f1a\u51fa\u73b0\u7cfb\u7edf\u89c4\u5219\u9650\u6d41\u4e86\uff0c\u800c\u8c03\u9ad8CPU\u7684\u9608\u503c\u59820.8\u540e\u8bbf\u95ee\u5219\u662f\u6b63\u5e38\u7684\u3002<\/p>\n

                  \"spring<\/p>\n

                  \u6574\u5408OpenFeign\u4f7f\u7528<\/h3>\n

                  \u51c6\u5907\u4e00\u4e2a\u5e93\u5b58\u5fae\u670d\u52a1\uff0c\u524d\u9762\u6211\u4eec\u5df2\u7ecf\u4f7f\u7528\uff0c\u5728\u5e93\u5b58\u63a7\u5236\u5668\u589e\u52a0\u4e00\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u548c\u542f\u52a8\u5e93\u5b58\u5fae\u670d\u52a1<\/p>\n

                   @RequestMapping<\/span>(<\/span>\"\/deduct-storage\"<\/span>)<\/span> public<\/span> String<\/span> deductStorage<\/span>(<\/span>)<\/span>{ \n   <\/span> int<\/span> i =<\/span> 1<\/span>\/<\/span>0<\/span>;<\/span> return<\/span> \"\u6263\u51cf\u5e93\u5b58\"<\/span>;<\/span> }<\/span> <\/code><\/pre>\n

                  \"spring<\/p>\n

                  \u8ba2\u5355\u5fae\u670d\u52a1\u4e2d\u589e\u52a0\u4e00\u4e2aStorageFeignService\u7684Feign\u63a5\u53e3\u58f0\u660e<\/p>\n

                  package<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>order.<\/span>service<\/span>;<\/span> import<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>commons.<\/span>service.<\/span>openfeign.<\/span><\/span>StorageFeignServiceFackBack<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>cloud.<\/span>openfeign.<\/span><\/span>FeignClient<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>web.<\/span>bind.<\/span>annotation.<\/span><\/span>RequestMapping<\/span>;<\/span> @FeignClient<\/span>(<\/span>value =<\/span> \"ecom-storage-service\"<\/span>,<\/span>fallback =<\/span> StorageFeignServiceFackBack<\/span>.<\/span>class<\/span>)<\/span> public<\/span> interface<\/span> StorageFeignService<\/span> { \n   <\/span> @RequestMapping<\/span>(<\/span>\"\/deduct-storage\"<\/span>)<\/span> String<\/span> deductStorage<\/span>(<\/span>)<\/span>;<\/span> }<\/span> <\/code><\/pre>\n

                  \u521b\u5efa\u964d\u7ea7\u7684\u5b9e\u73b0\u7c7b<\/p>\n

                  package<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>order.<\/span>service<\/span>;<\/span> import<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>commons.<\/span>service.<\/span>openfeign.<\/span><\/span>StorageFeignService<\/span>;<\/span> import<\/span> lombok.<\/span>extern.<\/span>slf4j.<\/span><\/span>Slf4j<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>stereotype.<\/span><\/span>Component<\/span>;<\/span> @Component<\/span> @Slf4j<\/span> public<\/span> class<\/span> StorageFeignServiceFackBack<\/span> implements<\/span> StorageFeignService<\/span> { \n   <\/span> @Override<\/span> public<\/span> String<\/span> deductStorage<\/span>(<\/span>)<\/span> { \n   <\/span> log.<\/span>info<\/span>(<\/span>\"\u8fdb\u5165\u8865\u507f\u5904\u7406\u7684\u6d41\u7a0b----------\"<\/span>)<\/span>;<\/span> return<\/span> \"\u8fdb\u5165\u8865\u507f\u5904\u7406\u7684\u6d41\u7a0b----------\"<\/span>;<\/span> }<\/span> }<\/span> <\/code><\/pre>\n

                  \u8ba2\u5355\u63a7\u5236\u5668\u589e\u52a0\u65b9\u6cd5<\/p>\n

                   @Autowired<\/span> OrderService<\/span> orderService;<\/span> @RequestMapping<\/span>(<\/span>\"\/create-order\"<\/span>)<\/span> public<\/span> String<\/span> createOrder<\/span>(<\/span>)<\/span>{ \n   <\/span> return<\/span> orderService.<\/span>createOrder<\/span>(<\/span>)<\/span>;<\/span> }<\/span> <\/code><\/pre>\n

                  \u8ba2\u5355\u670d\u52a1\u63a5\u53e3\u7684\u5b9e\u73b0\u7c7b\u8c03\u7528\u58f0\u660e\u5e93\u5b58\u7684Feign\u63a5\u53e3<\/p>\n

                  package<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>order.<\/span>service.<\/span>impl<\/span>;<\/span> import<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>commons.<\/span>service.<\/span><\/span>OrderService<\/span>;<\/span> import<\/span> cn.<\/span>itxs.<\/span>ecom.<\/span>commons.<\/span>service.<\/span>openfeign.<\/span><\/span>StorageFeignService<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>beans.<\/span>factory.<\/span>annotation.<\/span><\/span>Autowired<\/span>;<\/span> import<\/span> org.<\/span>springframework.<\/span>stereotype.<\/span><\/span>Component<\/span>;<\/span> @Component<\/span> public<\/span> class<\/span> OrderServiceImpl<\/span> implements<\/span> OrderService<\/span> { \n   <\/span> @Autowired<\/span> private<\/span> StorageFeignService<\/span> storageFeignService;<\/span> @Override<\/span> public<\/span> String<\/span> createOrder<\/span>(<\/span>)<\/span> { \n   <\/span> return<\/span> storageFeignService.<\/span>deductStorage<\/span>(<\/span>)<\/span>;<\/span> }<\/span> }<\/span> <\/code><\/pre>\n

                  \u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u589e\u52a0\u542f\u7528feign\u6574\u5408sentinel<\/p>\n

                  feign<\/span>:<\/span> sentinel<\/span>:<\/span> enabled<\/span>:<\/span> true<\/span> <\/code><\/pre>\n

                  \u5728\u8ba2\u5355\u5fae\u670d\u52a1\u7684\u542f\u52a8\u7c7b\u589e\u52a0@EnableFeignClients\u5f00\u542f<\/p>\n

                  \"spring<\/p>\n

                  \u8bbf\u95eehttp:\/\/localhost:4070\/order\/create-order\uff0c\u89e6\u53d1\u5e93\u5b58\u670d\u52a1\u5f02\u5e38\u540e\u8fd4\u56de\u8865\u507f\u6d41\u7a0b\u63d0\u793a\u3002<\/p>\n

                  \"spring<\/p>\n

                  \u89c4\u5219\u6301\u4e45\u5316<\/h3>\n

                  DataSource<\/code> \u6269\u5c55\u5e38\u89c1\u7684\u5b9e\u73b0\u65b9\u5f0f\u6709:<\/p>\n

                    \n
                  • \u62c9\u6a21\u5f0f<\/strong>\uff1a\u5ba2\u6237\u7aef\u4e3b\u52a8\u5411\u67d0\u4e2a\u89c4\u5219\u7ba1\u7406\u4e2d\u5fc3\u5b9a\u671f\u8f6e\u8be2\u62c9\u53d6\u89c4\u5219\uff0c\u8fd9\u4e2a\u89c4\u5219\u4e2d\u5fc3\u53ef\u4ee5\u662f RDBMS\u3001\u6587\u4ef6\uff0c\u751a\u81f3\u662f VCS \u7b49\u3002\u8fd9\u6837\u505a\u7684\u65b9\u5f0f\u662f\u7b80\u5355\uff0c\u7f3a\u70b9\u662f\u65e0\u6cd5\u53ca\u65f6\u83b7\u53d6\u53d8\u66f4\uff1b<\/li>\n
                  • \u63a8\u6a21\u5f0f<\/strong>\uff1a\u89c4\u5219\u4e2d\u5fc3\u7edf\u4e00\u63a8\u9001\uff0c\u5ba2\u6237\u7aef\u901a\u8fc7\u6ce8\u518c\u76d1\u542c\u5668\u7684\u65b9\u5f0f\u65f6\u523b\u76d1\u542c\u53d8\u5316\uff0c\u6bd4\u5982\u4f7f\u7528Nacos\u3001Zookeeper \u7b49\u914d\u7f6e\u4e2d\u5fc3\u3002\u8fd9\u79cd\u65b9\u5f0f\u6709\u66f4\u597d\u7684\u5b9e\u65f6\u6027\u548c\u4e00\u81f4\u6027\u4fdd\u8bc1\u3002<\/li>\n<\/ul>\n

                    Sentinel \u76ee\u524d\u652f\u6301\u4ee5\u4e0b\u6570\u636e\u6e90\u6269\u5c55\uff1a<\/p>\n

                      \n
                    • Pull-based: \u52a8\u6001\u6587\u4ef6\u6570\u636e\u6e90\u3001Consul, Eureka<\/li>\n
                    • Push-based: ZooKeeper, Redis, Nacos\uff0c Apollo, etcd<\/li>\n<\/ul>\n

                      Dashboard\u4e2d\u6dfb\u52a0\u7684\u89c4\u5219\u6570\u636e\u5b58\u50a8\u5728\u5185\u5b58\uff0c\u5fae\u670d\u52a1\u505c\u6389\u89c4\u5219\u6570\u636e\u5c31\u6d88\u5931\uff0c\u5728\u2f63\u4ea7\u73af\u5883\u4e0b\u4e0d\u5408\u9002\u3002\u6211\u4eec\u53ef\u4ee5\u5c06Sentinel\u89c4\u5219\u6570\u636e\u6301\u4e45\u5316\u5230Nacos\u914d\u7f6e\u4e2d\u2f3c\uff0c\u8ba9\u5fae\u670d\u52a1\u4eceNacos\u83b7\u53d6\u89c4\u5219\u6570\u636e\u3002<\/p>\n

                      \u6dfb\u52a0\u4f9d\u8d56<\/p>\n

                       <<\/span>dependency><\/span><\/span> <<\/span>groupId><\/span><\/span>com.<\/span>alibaba.<\/span>csp<<\/span>\/<\/span>groupId><\/span> <<\/span>artifactId><\/span><\/span>sentinel-<\/span>datasource-<\/span>nacos<<\/span>\/<\/span>artifactId><\/span> <<\/span>\/<\/span>dependency><\/span> <\/code><\/pre>\n

                      Nacos\u589e\u52a0\u914d\u7f6e<\/p>\n

                      \"spring<\/p>\n

                      \u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u4e2d\u589e\u52a0<\/p>\n

                      spring<\/span>:<\/span> application<\/span>:<\/span> name<\/span>:<\/span> ecom-<\/span>order-<\/span>service cloud<\/span>:<\/span> sentinel<\/span>:<\/span> enabled<\/span>:<\/span> true<\/span> transport<\/span>:<\/span> dashboard<\/span>:<\/span> localhost:<\/span>8858<\/span> port<\/span>:<\/span> 8719<\/span> datasource<\/span>:<\/span> # \u6b64\u5904\u7684flow\u4e3a\u2f83\u5b9a\u4e49\u6570\u636e\u6e90\u540d<\/span> flow<\/span>:<\/span> # \u6d41\u63a7\u89c4\u5219<\/span> nacos<\/span>:<\/span> # server-addr: ${spring.cloud.nacos.discovery.server-addr}<\/span> server-addr<\/span>:<\/span> ${ \n   <\/span>spring.cloud.nacos.server-<\/span>addr}<\/span> namespace<\/span>:<\/span> a2b1a5b7-<\/span>d0bc-<\/span>48e8-<\/span>ab65-<\/span>04695e61db01 data-id<\/span>:<\/span> ${ \n   <\/span>spring.application.name}<\/span>-<\/span>flow-<\/span>rules groupId<\/span>:<\/span> order-<\/span>group username<\/span>:<\/span> itsx password<\/span>:<\/span> itxs123 data-type<\/span>:<\/span> json rule-type<\/span>:<\/span> flow # \u7c7b\u578b\u6765\u2f83RuleType\u7c7b<\/span> <\/code><\/pre>\n

                      \u5feb\u901f\u8bbf\u95eehttp:\/\/localhost:4070\/order\/add\uff0c\u51fa\u73b0\u88ab\u6d41\u63a7\u7684\u63d0\u793a<\/p>\n

                      \"spring<\/p>\n

                      \u67e5\u770bsentinel\u63a7\u5236\u53f0\u6d41\u63a7\u89c4\u5219\u4e5f\u662f\u6211\u4eec\u5728Nacos\u4e0a\u7684\u6d41\u63a7\u89c4\u5219\u914d\u7f6e<\/p>\n

                      \"spring<\/p>\n

                      **\u672c\u4eba\u535a\u5ba2\u7f51\u7ad9 **IT\u5c0f\u795e www.itxiaoshen.com<\/p>\n","protected":false},"excerpt":{"rendered":"spring cloud \u6d41\u91cf\u63a7\u5236_dubbo\u5b9e\u6218\u4e0e\u6e90\u7801\u5206\u6790\u672c\u7bc7\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u6700\u65b0\u7248\u672c1.8.4Sentinel\u63a7\u5236\u53f0\u7684\u4f7f\u7528\uff0c\u9010\u6b65\u8bf4\u660e\u5982\u4f55\u4ece\u63a7\u5236\u53f0\u8bbe\u7f6e\u6d41...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8193"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8193"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8193\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}