{"id":218933,"date":"2021-06-05T08:55:23","date_gmt":"2021-06-05T00:55:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=218933"},"modified":"2021-05-23T10:57:16","modified_gmt":"2021-05-23T02:57:16","slug":"limit-infrastructure","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/limit-infrastructure.html","title":{"rendered":"\u5e38\u7528\u7684\u9650\u6d41\u6846\u67b6"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u4f5c\u4e3a\u5e94\u5bf9\u9ad8\u5e76\u53d1\u7684\u624b\u6bb5\u4e4b\u4e00\uff0c\u9650\u6d41\u5e76\u4e0d\u662f\u4e00\u4e2a\u65b0\u9c9c\u7684\u8bdd\u9898\u4e86\u3002\u4eceGuava\u7684Ratelimiter\u5230Hystrix\uff0c\u4ee5\u53caSentinel\u90fd\u53ef\u4f5c\u4e3a\u9650\u6d41\u7684\u5de5\u5177\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u81ea\u9002\u5e94\u9650\u6d41<\/strong><\/div>\n \u4e00\u822c\u7684\u9650\u6d41\u5e38\u5e38\u9700\u8981\u6307\u5b9a\u4e00\u4e2a\u56fa\u5b9a\u503c(qps)\u4f5c\u4e3a\u9650\u6d41\u5f00\u5173\u7684\u9608\u503c\uff0c\u8fd9\u4e2a\u503c\u4e00\u662f\u9760\u7ecf\u9a8c\u5224\u65ad\uff0c\u4e8c\u662f\u9760\u901a\u8fc7\u5927\u91cf\u7684\u6d4b\u8bd5\u6570\u636e\u5f97\u51fa\u3002\u4f46\u8fd9\u4e2a\u9608\u503c\uff0c\u5728\u6d41\u91cf\u6fc0\u589e\u3001\u7cfb\u7edf\u81ea\u52a8\u4f38\u7f29\u6216\u8005\u67d0\u67d0commit\u4e86\u4e00\u6bb5\u6709\u6bd2\u4ee3\u7801\u540e\u5c31\u6709\u53ef\u80fd\u53d8\u5f97\u4e0d\u90a3\u4e48\u5408\u9002\u4e86\u3002\u5e76\u4e14\u4e00\u822c\u4e1a\u52a1\u65b9\u4e5f\u4e0d\u592a\u80fd\u591f\u6b63\u786e\u8bc4\u4f30\u81ea\u5df1\u7684\u5bb9\u91cf\uff0c\u53bb\u8bbe\u7f6e\u4e00\u4e2a\u5408\u9002\u7684\u9650\u6d41\u9608\u503c\u3002<\/p>\n \u800c\u6b64\u65f6\u81ea\u9002\u5e94\u9650\u6d41\u5c31\u662f\u89e3\u51b3\u8fd9\u6837\u7684\u95ee\u9898\u7684\uff0c\u9650\u6d41\u9608\u503c\u4e0d\u9700\u8981\u624b\u52a8\u6307\u5b9a\uff0c\u4e5f\u4e0d\u9700\u8981\u53bb\u9884\u4f30\u7cfb\u7edf\u7684\u5bb9\u91cf\uff0c\u5e76\u4e14\u9608\u503c\u80fd\u591f\u968f\u7740\u7cfb\u7edf\u76f8\u5173\u6307\u6807\u53d8\u5316\u800c\u53d8\u5316\u3002<\/p>\n \u81ea\u9002\u5e94\u9650\u6d41\u7b97\u6cd5\u501f\u9274\u4e86TCP\u62e5\u585e\u7b97\u6cd5\uff0c\u6839\u636e\u5404\u79cd\u6307\u6807\u9884\u4f30\u9650\u6d41\u7684\u9608\u503c\uff0c\u5e76\u4e14\u4e0d\u65ad\u8c03\u6574\u3002\u5927\u81f4\u83b7\u5f97\u7684\u6548\u679c\u5982\u4e0b:<\/p>\n <\/p>\n \u4ece\u56fe\u4e0a\u53ef\u4ee5\u770b\u5230\uff0c\u9996\u5148\u4ee5\u4e00\u4e2a\u964d\u4f4e\u7684\u521d\u59cb\u5e76\u53d1\u503c\u53d1\u9001\u8bf7\u6c42\uff0c\u540c\u65f6\u901a\u8fc7\u589e\u5927\u9650\u6d41\u7a97\u53e3\u6765\u63a2\u6d4b\u7cfb\u7edf\u66f4\u9ad8\u7684\u5e76\u53d1\u6027\u3002\u800c\u4e00\u65e6\u5ef6\u8fdf\u589e\u52a0\u5230\u4e00\u5b9a\u7a0b\u5ea6\u4e86\uff0c\u53c8\u4f1a\u9000\u56de\u5230\u8f83\u5c0f\u7684\u9650\u6d41\u7a97\u53e3\u3002\u5faa\u73af\u5f80\u590d\u6301\u7eed\u63a2\u6d4b\u5e76\u53d1\u6781\u9650\uff0c\u4ece\u800c\u4ea7\u751f\u7c7b\u4f3c\u952f\u9f7f\u72b6\u7684\u65f6\u95f4\u5173\u7cfb\u51fd\u6570\u3002<\/p>\n TCP Vegas<\/strong><\/div>\n vegas\u662f\u4e00\u79cd\u4e3b\u52a8\u8c03\u6574cwnd\u7684\u62e5\u585e\u63a7\u5236\u7b97\u6cd5\uff0c\u4e3b\u8981\u662f\u8bbe\u7f6e\u4e24\u4e2a\u9608\u503calpha \u548c beta\uff0c\u7136\u540e\u901a\u8fc7\u8ba1\u7b97\u76ee\u6807\u901f\u7387\u548c\u5b9e\u9645\u901f\u7387\u7684\u5deediff\uff0c\u518d\u6bd4\u8f83\u5deediff\u4e0ealpha\u548cbeta\u7684\u5173\u7cfb\uff0c\u5bf9cwnd\u8fdb\u884c\u8c03\u8282\u3002\u4f2a\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n diff = cwnd*(1-baseRTT\/RTT) \r\nif (diff < alpha) \r\nset: cwndcwnd = cwnd + 1 \r\nelse if (diff >= beta) \r\nset: cwndcwnd = cwnd - 1 \r\nelse \r\nset: cwndcwnd = cwnd <\/pre>\n |