{"id":301,"date":"2018-04-16T17:10:05","date_gmt":"2018-04-16T09:10:05","guid":{"rendered":"https:\/\/www.myway5.com\/?p=301"},"modified":"2023-07-05T21:51:15","modified_gmt":"2023-07-05T13:51:15","slug":"flowcontrol","status":"publish","type":"post","link":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/","title":{"rendered":"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848"},"content":{"rendered":"<h2>1.\u573a\u666f<\/h2>\n<p>\u5f53\u524d\u4e1a\u52a1\u4e2d\u63a5\u53e3\u9632\u5237\u7684\u573a\u666f\u6709:<\/p>\n<ul>\n<li>1.\u77ed\u4fe1\/\u90ae\u4ef6\u63a5\u53e3\u3002\u8fd9\u4e2a\u63a5\u53e3\u4e0d\u505a\u597d\u9632\u5237\u7b56\u7565\uff0c\u635f\u5931\u662f\u5f88\u5927\u7684\u3002<\/li>\n<li>2.\u6d89\u53ca\u5230\u5b89\u5168\u95ee\u9898\u7684\u63a5\u53e3\u8c03\u7528\u3002\u6bd4\u5982\u6ce8\u518c\u63a5\u53e3\uff0c\u767b\u5f55\u63a5\u53e3\u7b49\u7b49\u3002\u8fc7\u4e8e\u9891\u7e41\u7684\u8bf7\u6c42\u53ef\u80fd\u4ee3\u8868\u7740\u7528\u6237\u7684\u6279\u91cf\u6ce8\u518c\uff0c\u7528\u6237\u5bc6\u7801\u7684\u66b4\u529b\u7834\u89e3\uff08\u9700\u8981\u8003\u8651\u5230\u53ef\u80fd\u662f\u7528\u6237\u5fd8\u8bb0\u5bc6\u7801\u4e86)\u7b49\u7b49\u3002<\/li>\n<\/ul>\n<h2>2.\u8981\u6c42<\/h2>\n<ul>\n<li>1.\u4e0e\u5f53\u524d\u4e1a\u52a1\u7cfb\u7edf\u89e3\u8026\u5408<\/li>\n<li>2.\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5bf9\u4e0d\u540c\u7684\u63a5\u53e3\u8bbe\u7f6e\u4e0d\u540c\u7684\u8bf7\u6c42\u9891\u7387\u9650\u5236<\/li>\n<li>3.\u5177\u6709\u8f83\u597d\u7684\u6027\u80fd\u3002\u5728\u5927\u5e76\u53d1\u7684\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u6709\u6b63\u786e\u7684\u7ed3\u679c<\/li>\n<\/ul>\n<h2>3.\u65b9\u6848\u63d0\u51fa<\/h2>\n<h3>3.1 token bucket\uff08\u4ee4\u724c\u6876\uff09<\/h3>\n<p>token bucket\u7b97\u6cd5\u7684\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg\" alt=\"token_bucket\" \/><\/p>\n<p>\u63cf\u8ff0\u5982\u4e0b:<\/p>\n<p>1.\u5047\u8bbe\u6709\u4e00\u4e2a\u6876\uff0c\u4e0d\u65ad\u7684\u5411\u6876\u4e2d\u6295\u653etoken\uff0c\u5e76\u4e14\u6211\u4eec\u4e5f\u53ef\u4ee5\u4ece\u6876\u4e2d\u53d6\u51fatoken\u3002<br \/>\n2.\u6295\u653etoken\u7684\u901f\u7387\u662f\u6052\u5b9a\u7684r1\uff0c\u6876\u6ee1\u4e86token\u6570\u91cf\u5219\u4e0d\u4f1a\u518d\u589e\u957f\u3002<br \/>\n3.\u53d6\u51fa\u7684\u901f\u7387\u662f\u968f\u673a\u7684r2\u3002\u5982\u679c\u6876\u662f\u7a7a\u7684\uff0c\u5219\u65e0\u6cd5\u53d6\u51fatoken\u3002<br \/>\n4.\u6240\u6709\u7684\u8bf7\u6c42\u90fd\u5fc5\u987b\u4ece\u6876\u4e2d\u53d6\u51fatoken\u624d\u662f\u6709\u6548\u7684\u3002\u5426\u5219\u8be5\u8bf7\u6c42\u4f1a\u88ab\u62d2\u7edd\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5047\u8bbe\u6876\u7684\u5bb9\u91cf\u662f10\uff0c\u6bcf\u79d2\u653e2\u4e2atoken\u8fdb\u53bb\u3002<\/p>\n<ul>\n<li>\u5982\u679c\u73b0\u5728\u6bcf\u79d22\u4e2a\u8bf7\u6c42\uff0c\u90a3\u4e48\u6240\u6709\u8fd9\u6837\u7684\u8bf7\u6c42\u90fd\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u90fd\u4f1a\u62ff\u5230token\u3002<\/li>\n<li>\u5982\u679c\u73b0\u5728\u6bcf\u79d24\u4e2a\u8bf7\u6c42,10 + 2x = 4x\u3002\u4e5f\u5c31\u662fx=5\u79d2\u540e\u8bf7\u6c42\u5c31\u6ca1\u6cd5\u53ca\u65f6\u62ff\u5230token\uff0c\u88ab\u4e22\u5f03\u3002<\/li>\n<\/ul>\n<p>\u603b\u7ed3\u51fa\u4ee5\u4e0b\u7279\u70b9:<br \/>\n &#8211; \u5982\u679c\u8bf7\u6c42\u901f\u7387\u8fc7\u5feb\uff0c\u5230\u4e00\u6bb5\u65f6\u95f4\u540e\u4f1a\u53d7\u5230\u9650\u5236<br \/>\n &#8211; \u5141\u8bb8\u7a81\u53d1\u8bf7\u6c42<\/p>\n<h3>3.2 redis\u6570\u636e\u5e93<\/h3>\n<p>\u4f7f\u7528redis\u6570\u636e\u5e93\u5b8c\u5168\u662f\u56e0\u4e3a\u65b9\u4fbf\u4ee5\u53ca\u901f\u5ea6\u3002\u53ea\u8981\u6ce8\u610f\u8fd9\u5176\u4e2d\u5b58\u5728\u7684CAS\u95ee\u9898\u5373\u53ef<\/p>\n<h2>4.\u5177\u4f53\u5b9e\u73b0<\/h2>\n<p>\u9996\u5148\uff0c\u4e3a\u4e86\u89e3\u51b3redis\u4e2d\u68c0\u67e5\u548c\u5b58\u50a8\u6570\u636e\u5b58\u5728\u7684CAS\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528lua\u811a\u672c\u3002\u56e0\u6b64\uff0c\u5bf9\u4e8etoken bucket\u7684\u4e3b\u8981\u5b9e\u73b0\u662f\u7528lua\u811a\u672c\u5b9e\u73b0,\u7136\u540e\u901a\u8fc7php\u8c03\u7528\u3002<\/p>\n<pre><code class=\"line-numbers\">local function mysplit(inputstr, sep)\n    if sep == nil then\n            sep = \"%s\"\n    end\n    local t={} ; \n    local i=1\n    for str in string.gmatch(inputstr, \"([^\"..sep..\"]+)\") do\n            t[i] = str\n            i = i + 1\n    end\n    return t\nend\n\nlocal res = redis.pcall('get',KEYS[1])\n\nif (res == false) then\n    -- bucket\u4e0d\u5b58\u5728\uff0c\u521d\u59cb\u5316\u4e3acapacity - 1\n    local str = string.format(\"%d %d\",ARGV[1] - 1,ARGV[2])  \n    return redis.pcall('set',KEYS[1],str)\nend\n\nlocal arr_str = mysplit(res, \" \")\n\nlocal num = arr_str[1]\nlocal timestamp = arr_str[2]\n\n-- \u6839\u636e\u65f6\u95f4\u6233\u6765\u8ba1\u7b97num\uff0c\u8fd9\u91cc\u4e00\u79d22\u4e2a\u4ee4\u724c\nnum = num + (ARGV[2] - timestamp) * ARGV[3]\n-- \u4e0d\u8d85\u8fc710\u4e2a\u4ee4\u724c\nif num &gt; 10 then\n    num = 10\nend\n\nif (tonumber(num) &gt; 0) then\n    -- \u62ff\u5230token\u5e76\u51cf\u4e00\n    local str = string.format(\"%d %d\",num - 1,ARGV[2])\n    return redis.pcall('set', KEYS[1], str)\nelse \n    -- \u6ca1\u6709\u62ff\u5230token\n    return false\nend\n<\/code><\/pre>\n<pre><code class=\"line-numbers\">&lt;?php\n\n<span class=\"katex math inline\">sha = '2ff7ad2d1b49da8430e5adc8675e';\n\n\/**\n * \u521d\u59cb\u5316lua\u811a\u672c\n *\/\nfunction initScript(<\/span>redis) {\n    global <span class=\"katex math inline\">sha;\n    \/\/\u4e0d\u5b58\u5728\u811a\u672c\uff0cload\u8fdb\u53bb<\/span>script = file_get_contents('check_and_set.lua');\n    <span class=\"katex math inline\">sha =<\/span>redis-&gt;script('load', <span class=\"katex math inline\">script);\n    if(<\/span>redis-&gt;getLastError() !== NULL){\n        echo \"\u51fa\u9519\u4e86\uff1a\".<span class=\"katex math inline\">redis-&gt;getLastError().'\\n';\n    }\n    echo \"\u521d\u59cb\u5316\u7684\u811a\u672csha:\".<\/span>sha.PHP_EOL;\n}\n\nfunction getTokenFromBucket(<span class=\"katex math inline\">redis,<\/span>bucket) {\n    global <span class=\"katex math inline\">sha;<\/span>capacity = 10;\n    <span class=\"katex math inline\">time = time();<\/span>inputRate = 2;     \/\/\u4e00\u79d22\u4e2atoken\n    <span class=\"katex math inline\">params = array(<\/span>bucket, <span class=\"katex math inline\">capacity,<\/span>time, <span class=\"katex math inline\">inputRate);<\/span>result = <span class=\"katex math inline\">redis-&gt;evalSha(<\/span>sha, <span class=\"katex math inline\">params, 1);\n    if(<\/span>redis-&gt;getLastError() !== NULL){\n        echo \"\u51fa\u9519\u4e86\uff1a\".<span class=\"katex math inline\">redis-&gt;getLastError().'\\n';\n    }\n    return<\/span>result;\n}\n\n<span class=\"katex math inline\">redis = new Redis();<\/span>redis-&gt;pconnect(\"127.0.0.1\");\n\ninitScript(<span class=\"katex math inline\">redis);<\/span>start = microtime(true) * 1000;\n\nwhile(true) {\n    <span class=\"katex math inline\">result =  getTokenFromBucket(<\/span>redis, 'bucket1');\n    if (!<span class=\"katex math inline\">result) {\n        break;\n    } else {\n        echo time().\"--\u62ff\u5230\u4ee4\u724c\".PHP_EOL;\n        usleep(250000);    \/\/\u6bcf\u79d2\u8bf7\u6c424\u6b21,10 + 2x = 4x, x = 5\u30025\u79d2\u5de6\u53f3\u65e0\u6cd5\u62ff\u5230\u4ee4\u724c\n    }\n}<\/span>end = microtime(true) * 1000;\n\necho \"\u5171\u8017\u65f6\uff1a\".(<span class=\"katex math inline\">end -<\/span>start).\"\u6beb\u79d2\".PHP_EOL.PHP_EOL;\n\n<span class=\"katex math inline\">start = microtime(true) * 1000;\n\nwhile(true) {<\/span>result =  getTokenFromBucket(<span class=\"katex math inline\">redis, 'bucket2');\n    if (!<\/span>result) {\n        break;\n    } else {\n        echo \"\u62ff\u5230\u4ee4\u724c\".PHP_EOL;\n        usleep(500000);    \/\/\u6bcf\u79d2\u8bf7\u6c422\u6b21\uff0c\u6c38\u8fdc\u53ef\u4ee5\u62ff\u5230\u4ee4\u724c\n    }\n}\n\n<span class=\"katex math inline\">end = microtime(true) * 1000;\n\necho \"\u5171\u8017\u65f6\uff1a\".(<\/span>end - $start).\"\u6beb\u79d2\".PHP_EOL.PHP_EOL;\n<\/code><\/pre>\n<p>\u4ee3\u7801\u4e2d\u4e3b\u8981\u90e8\u5206\u6982\u62ec\u5982\u4e0b:<\/p>\n<ul>\n<li>\u68c0\u67e5redis\u4e2d\u662f\u5426\u5b58\u5728\u6876<code>bucket1<\/code>\u3002<\/li>\n<li>\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u90a3\u4e48\u9ed8\u8ba4\u7684\u5bb9\u91cf\u662f10\uff0c\u5c06bucket1\u8bbe\u4e3a<code>9 timestamp<\/code>(timestamp\u4e3a\u5f53\u524d\u7684\u65f6\u95f4\u6233)\u3002\u8fd4\u56detrue<\/li>\n<li>\u5982\u679c\u5b58\u5728\uff0c\u5219\u83b7\u53d6\u8be5bucket1\u7684\u503c\uff0c\u89e3\u6790\u51fa\u5b9e\u9645token\u6570\u91cf\u4e3anum,\u4ee5\u53ca\u4e0a\u4e00\u6b21\u5b58\u50a8\u65f6\u65f6\u95f4\u6233\u4e3apre\u3002\u5982\u679crate\u4e3atoken\u7684\u751f\u6210\u901f\u7387\uff0c\u90a3\u4e48\u73b0\u5728\u7684token\u6570\u91cf\u5e94\u8be5\u662f:num = num + (time() &#8211; pre) * rate\u3002num\u6700\u5927\u4e3a\u9ed8\u8ba4\u5bb9\u91cf10\u3002\u5982\u679cnum\u5927\u4e8e0\uff0c\u5219\u51cf\u4e00\u540e\u91cd\u65b0\u8bbe\u7f6e\uff0c\u8fd4\u56detrue\u3002\u5426\u5219\u8fd4\u56defalse\u3002<\/li>\n<\/ul>\n<p>\u4ee3\u7801\u7684\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/%E6%B7%B1%E5%BA%A6%E6%88%AA%E5%9B%BE_%E9%80%89%E6%8B%A9%E5%8C%BA%E5%9F%9F_20180416170607.png\" alt=\"\u8fd0\u884c\u7ed3\u679c\u6f14\u793a\" \/><\/p>\n<h2>5.\u6269\u5c55\u77e5\u8bc6<\/h2>\n<p>\u4e0etoken bucket\u76f8\u4f3c\u7684\u7b97\u6cd5\u8fd8\u6709leaky bucket\uff08\u6f0f\u6876\uff09\u3002leaky bucket \u5c31\u50cf\u662f token bucket\u7684\u955c\u50cf\u4e00\u6837\u3002leaky bucket \u4e00\u822c\u7528\u4e8eTraffic shaping\u548cTraffic policing\u7b49\u95ee\u9898\uff0c\u4e0e\u4e0b\u9762\u7684\u4e24\u5f20\u56fe\u5bf9\u5e94\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/Leaky_bucket_as_a_meter-shaping.jpeg\" alt=\"leaky bucket\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/Leaky_bucket_as_a_meter-policing.jpeg\" alt=\"leaky bucket\" \/><\/p>\n<p>\u53ef\u4ee5\u63cf\u8ff0\u5982\u4e0b:<\/p>\n<ul>\n<li>1.\u6709\u4e00\u4e2a\u6876\uff0c\u5176\u4e0a\u65b9\u6c34\u9f99\u5934\u4ee5\u53d8\u5316\u7684\u901f\u7387r1\u5411\u91cc\u9762\u6ef4\u6c34\uff0c\u6876\u5e95\u7684\u6c34\u9f99\u5934\u5219\u4ee5\u6052\u5b9a\u7684\u901f\u7387\u5411\u4e0b\u6f0f\u6c34<\/li>\n<li>2.\u6c34\u6876\u88c5\u6ee1\u540e\uff0c\u4e0a\u65b9\u6c34\u9f99\u5934\u7684\u6ef4\u6c34\u5c31\u4f1a\u6ea2\u51fa<\/li>\n<li>3.\u6c34\u6876\u7a7a\u540e\uff0c\u4e0b\u65b9\u6c34\u9f99\u5934\u5219\u4e0d\u4f1a\u6ef4\u6c34<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u4e3e\u4e00\u4e2a\u5f02\u6b65\u4efb\u52a1\u5904\u7406\uff08\u4efb\u52a1\u961f\u5217\u7684\u5bb9\u91cf\u662f\u6709\u9650\u7684\uff09\u7684\u4f8b\u5b50\u3002<\/p>\n<ul>\n<li>\u4e0a\u65b9\u6c34\u9f99\u5934\u76f8\u5f53\u4e8e\u4efb\u52a1\u6295\u9012\u7cfb\u7edf\uff0c\u4e0b\u65b9\u6c34\u9f99\u5934\u76f8\u5f53\u4e8e\u4efb\u52a1\u5904\u7406\u7cfb\u7edf\u3002<\/li>\n<li>\u4efb\u52a1\u6295\u9012\u7684\u901f\u7387\u662f\u53d8\u5316\u7684\uff0c\u56e0\u4e3a\u4e0d\u540c\u65f6\u95f4\u6bb5\u7684\u7cfb\u7edf\u8d1f\u8f7d\u53ef\u80fd\u4e0d\u540c\u3002<\/li>\n<li>\u4efb\u52a1\u5904\u7406\u7cfb\u7edf\u7684\u901f\u7387\u662f\u6052\u5b9a\u7684\uff0c\u56e0\u4e3a\u673a\u5668\u7684\u5904\u7406\u80fd\u529b\u662f\u6052\u5b9a\u7684\u3002<\/li>\n<li>\u5f53\u4efb\u52a1\u6295\u9012\u7684\u901f\u7387\u5927\u4e8e\u5904\u7406\u901f\u7387\uff0c\u586b\u5145\u6ee1\u4efb\u52a1\u961f\u5217\u540e\uff0c\u540e\u9762\u7684\u4efb\u52a1\u90fd\u4f1a\u88ab\u4e22\u5f03\u3002<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u770b\u51faleaky bucket\u53ef\u4ee5\u5c06\u4e0d\u89c4\u5219\u7684\u6296\u52a8\u7684\u8bf7\u6c42\u5e8f\u5217\u53d8\u6210\u89c4\u5219\u7684\u5e73\u6ed1\u7684\u8bf7\u6c42\u5e8f\u5217\u3002leaky bucket\u901a\u5e38\u6709\u4e24\u4e2a\u7248\u672c\uff1a\u4f5c\u4e3a\u4e00\u4e2a\u8bc4\u5224\u7684\u4eea\u5668(meter)\u6216\u8005\u662f\u751f\u6210\u4e00\u4e2a\u5408\u6cd5\u8bf7\u6c42\u961f\u5217(queue)\u3002<\/p>\n<p>\u867d\u7136\u5728\u4f7f\u7528\u4e2dleaky bucket\u548ctoken bucket\u662f\u4e0d\u540c\u7684\uff0c\u4f46\u5b9e\u9645\u4e0a\u4ed6\u4eec\u662f\u540c\u4e00\u79cd\u601d\u8def\u3002leaky bucket\u7684\u53d8\u5316\u7684\u8f93\u5165\u76f8\u5f53\u4e8etoken bucket\u7684\u53d8\u5316\u7684\u8f93\u51fa\uff0cleaky bucket\u7684\u6052\u5b9a\u7684\u8f93\u51fa\u76f8\u5f53\u4e8etoken bucket\u7684\u6052\u5b9a\u7684\u8f93\u51fa\u3002<\/p>\n<h2>\u53c2\u8003\u6587\u732e<\/h2>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Token_bucket\">token bucket<\/a><br \/>\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Leaky_bucket\">leaky bucket<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u573a\u666f \u5f53\u524d\u4e1a\u52a1\u4e2d\u63a5\u53e3\u9632\u5237\u7684\u573a\u666f\u6709: 1.\u77ed\u4fe1\/\u90ae\u4ef6\u63a5\u53e3\u3002\u8fd9\u4e2a\u63a5\u53e3\u4e0d\u505a\u597d\u9632\u5237\u7b56\u7565\uff0c\u635f\u5931\u662f\u5f88\u5927\u7684\u3002 2.\u6d89\u53ca\u5230 &hellip; <a href=\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,19],"tags":[48,47],"class_list":["post-301","post","type-post","status-publish","format-standard","hentry","category-redis","category-work","tag-token_bucket","tag-47"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848 - \u4e00\u53ea\u5b89\u9759\u7684\u732b<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848 - \u4e00\u53ea\u5b89\u9759\u7684\u732b\" \/>\n<meta property=\"og:description\" content=\"1.\u573a\u666f \u5f53\u524d\u4e1a\u52a1\u4e2d\u63a5\u53e3\u9632\u5237\u7684\u573a\u666f\u6709: 1.\u77ed\u4fe1\/\u90ae\u4ef6\u63a5\u53e3\u3002\u8fd9\u4e2a\u63a5\u53e3\u4e0d\u505a\u597d\u9632\u5237\u7b56\u7565\uff0c\u635f\u5931\u662f\u5f88\u5927\u7684\u3002 2.\u6d89\u53ca\u5230 &hellip; \u7ee7\u7eed\u9605\u8bfb\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\" \/>\n<meta property=\"og:site_name\" content=\"\u4e00\u53ea\u5b89\u9759\u7684\u732b\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-16T09:10:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-05T13:51:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg\" \/>\n<meta name=\"author\" content=\"jiangpengfei\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"jiangpengfei\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\"},\"author\":{\"name\":\"jiangpengfei\",\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"headline\":\"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848\",\"datePublished\":\"2018-04-16T09:10:05+00:00\",\"dateModified\":\"2023-07-05T13:51:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\"},\"wordCount\":88,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"image\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg\",\"keywords\":[\"token_bucket\",\"\u63a5\u53e3\u9632\u5237\"],\"articleSection\":[\"redis\",\"\u5de5\u4f5c\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\",\"url\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\",\"name\":\"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848 - \u4e00\u53ea\u5b89\u9759\u7684\u732b\",\"isPartOf\":{\"@id\":\"https:\/\/www.myway5.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg\",\"datePublished\":\"2018-04-16T09:10:05+00:00\",\"dateModified\":\"2023-07-05T13:51:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage\",\"url\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg\",\"contentUrl\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg\",\"width\":421,\"height\":241},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.myway5.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.myway5.com\/#website\",\"url\":\"https:\/\/www.myway5.com\/\",\"name\":\"\u4e00\u53ea\u5b89\u9759\u7684\u732b\",\"description\":\"\u60f3\u5565\u5462\",\"publisher\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.myway5.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\",\"name\":\"jiangpengfei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g\",\"caption\":\"jiangpengfei\"},\"logo\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.myway5.com\/index.php\/author\/joyme\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848 - \u4e00\u53ea\u5b89\u9759\u7684\u732b","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/","og_locale":"zh_CN","og_type":"article","og_title":"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848 - \u4e00\u53ea\u5b89\u9759\u7684\u732b","og_description":"1.\u573a\u666f \u5f53\u524d\u4e1a\u52a1\u4e2d\u63a5\u53e3\u9632\u5237\u7684\u573a\u666f\u6709: 1.\u77ed\u4fe1\/\u90ae\u4ef6\u63a5\u53e3\u3002\u8fd9\u4e2a\u63a5\u53e3\u4e0d\u505a\u597d\u9632\u5237\u7b56\u7565\uff0c\u635f\u5931\u662f\u5f88\u5927\u7684\u3002 2.\u6d89\u53ca\u5230 &hellip; \u7ee7\u7eed\u9605\u8bfb\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848","og_url":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/","og_site_name":"\u4e00\u53ea\u5b89\u9759\u7684\u732b","article_published_time":"2018-04-16T09:10:05+00:00","article_modified_time":"2023-07-05T13:51:15+00:00","og_image":[{"url":"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg","type":"","width":"","height":""}],"author":"jiangpengfei","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"jiangpengfei","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#article","isPartOf":{"@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/"},"author":{"name":"jiangpengfei","@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"headline":"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848","datePublished":"2018-04-16T09:10:05+00:00","dateModified":"2023-07-05T13:51:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/"},"wordCount":88,"commentCount":4,"publisher":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"image":{"@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage"},"thumbnailUrl":"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg","keywords":["token_bucket","\u63a5\u53e3\u9632\u5237"],"articleSection":["redis","\u5de5\u4f5c"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/","url":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/","name":"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848 - \u4e00\u53ea\u5b89\u9759\u7684\u732b","isPartOf":{"@id":"https:\/\/www.myway5.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage"},"image":{"@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage"},"thumbnailUrl":"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg","datePublished":"2018-04-16T09:10:05+00:00","dateModified":"2023-07-05T13:51:15+00:00","breadcrumb":{"@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#primaryimage","url":"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg","contentUrl":"https:\/\/www.myway5.com\/wp-content\/uploads\/2018\/04\/token-bucket.jpg","width":421,"height":241},{"@type":"BreadcrumbList","@id":"https:\/\/www.myway5.com\/index.php\/2018\/04\/16\/flowcontrol\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.myway5.com\/"},{"@type":"ListItem","position":2,"name":"\u63a5\u53e3\u8bf7\u6c42\u901f\u7387\uff08\u63a5\u53e3\u9632\u5237\uff09\u9650\u5236\u65b9\u6848"}]},{"@type":"WebSite","@id":"https:\/\/www.myway5.com\/#website","url":"https:\/\/www.myway5.com\/","name":"\u4e00\u53ea\u5b89\u9759\u7684\u732b","description":"\u60f3\u5565\u5462","publisher":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.myway5.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685","name":"jiangpengfei","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.myway5.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g","caption":"jiangpengfei"},"logo":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/image\/"},"url":"https:\/\/www.myway5.com\/index.php\/author\/joyme\/"}]}},"views":20345,"_links":{"self":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":4,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":1594,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/301\/revisions\/1594"}],"wp:attachment":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}