{"id":115794,"date":"2026-10-13T12:01:08","date_gmt":"2026-10-13T04:01:08","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115794.html"},"modified":"2026-10-13T12:01:08","modified_gmt":"2026-10-13T04:01:08","slug":"%e5%be%ae%e6%9c%8d%e5%8a%a1%e5%bc%b9%e6%80%a7%e6%89%a9%e7%bc%a9%e5%ae%b9%ef%bc%88hpa%ef%bc%89%e6%bb%9e%e5%90%8e%e6%80%a7%e6%b2%bb%e7%90%86%ef%bc%9a%e5%9f%ba%e4%ba%8e%e4%b8%9a%e5%8a%a1-qps-%e9%a2%84","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115794.html","title":{"rendered":"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261013040106-6acdad02dde5c.webp\" alt=\"\u5c01\u9762\u4fe1\u606f\u56fe\" \/><\/p>\n<p>\u5728\u4ee5 Docker \u5bb9\u5668\u4e0e Kubernetes&#xff08;K8s&#xff09;\u4e3a\u6838\u5fc3\u5e95\u5ea7\u7684\u73b0\u4ee3\u4e91\u539f\u751f\u5fae\u670d\u52a1\u4f53\u7cfb\u4e2d&#xff0c;\u6c34\u5e73 Pod \u81ea\u52a8\u6269\u7f29\u5bb9&#xff08;Horizontal Pod Autoscaler, \u7b80\u79f0 HPA&#xff09; \u88ab\u5e7f\u6cdb\u8a89\u4e3a\u4fdd\u969c\u670d\u52a1\u5f39\u6027\u3001\u5b9e\u73b0\u4e91\u8d44\u6e90\u201c\u6309\u9700\u8ba1\u8d39\u4e0e\u81ea\u6108\u201d\u7684\u795e\u5175\u5229\u5668\u3002\u7edd\u5927\u591a\u6570\u67b6\u6784\u5e08\u5728\u90e8\u7f72\u5e94\u7528\u65f6&#xff0c;\u90fd\u4f1a\u8f7b\u8f66\u719f\u8def\u5730\u914d\u7f6e\u4e00\u6bb5\u6807\u51c6\u7684 YAML&#xff1a;\u8bbe\u5b9a\u5f53\u5bb9\u5668\u7684\u5e73\u5747 CPU \u4f7f\u7528\u7387\u8d85\u8fc7 70% \u65f6&#xff0c;\u89e6\u53d1 HPA \u5c06 Pod \u526f\u672c\u6570\u4ece 10 \u4e2a\u81ea\u52a8\u6269\u5bb9\u81f3 50 \u4e2a\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u5728\u9762\u5bf9\u53cc\u5341\u4e00\u5927\u4fc3\u96f6\u70b9\u79d2\u6740\u3001\u7a81\u53d1\u70ed\u70b9\u77ed\u89c6\u9891\u5f15\u6d41\u6216\u4e0d\u53ef\u9884\u671f\u7684\u6d41\u91cf\u5de8\u6d6a\u51b2\u51fb\u65f6&#xff0c;\u8fd9\u5957\u770b\u4f3c\u65e0\u6bd4\u7f8e\u597d\u7684\u81ea\u52a8\u5316\u5f39\u6027\u9632\u7ebf&#xff0c;\u5374\u5c61\u5c61\u6ca6\u4e3a\u6700\u4ee4\u4eba\u6b32\u54ed\u65e0\u6cea\u7684\u201c\u9a6c\u540e\u70ae\u6446\u8bbe\u201d\u3002<\/p>\n<p>\u5728\u771f\u5b9e\u751f\u4ea7\u5927\u4fc3\u7684\u5b9e\u6218\u4e2d&#xff0c;\u6d41\u91cf\u5f80\u5f80\u662f\u5728\u77ed\u77ed\u4e00\u4e24\u79d2\u5185\u4ee5\u5782\u76f4\u8109\u51b2&#xff08;Spike&#xff09;\u7684\u5f62\u5f0f\u77ac\u95f4\u66b4\u589e 10 \u500d\u4e43\u81f3 20 \u500d\u3002\u7136\u800c&#xff0c;\u57fa\u4e8e Kubernetes \u539f\u751f\u57fa\u4e8e CPU \u6c34\u4f4d\u7684 HPA \u63a7\u5236\u5668&#xff0c;\u5176\u53cd\u5e94\u901f\u5ea6\u5374\u6162\u5f97\u4ee4\u4eba\u53d1\u6307&#xff1a;\u7b49\u5b83\u7ec8\u4e8e\u6162\u541e\u541e\u5730\u611f\u77e5\u5230 CPU \u8d85\u6807\u3001\u751f\u6210\u51b3\u7b56\u3001\u8c03\u5ea6\u8282\u70b9\u3001\u62c9\u53d6\u955c\u50cf\u3001\u62c9\u8d77\u5168\u65b0 Pod&#xff0c;\u5e76\u7b49\u5f85\u5e94\u7528\u7a0b\u5e8f\u5b8c\u6210\u51b7\u542f\u52a8\u9884\u70ed\u65f6&#xff0c;\u6574\u4e2a\u65f6\u95f4\u8f74\u5df2\u7ecf\u8fc7\u53bb\u4e86\u6574\u6574 2 \u5230 3 \u5206\u949f\u4e4b\u4e45&#xff01;\u800c\u5728\u9ad8\u5e76\u53d1\u7684\u6218\u573a\u4e0a&#xff0c;3 \u5206\u949f\u65e0\u5f02\u4e8e\u4e00\u4e2a\u4e16\u7eaa\u3002\u5728\u5168\u65b0\u6269\u5bb9\u51fa\u7684 Pod \u521a\u521a\u6253\u6807\u4e3a Ready \u7684\u90a3\u4e00\u77ac\u95f4&#xff0c;\u539f\u672c\u5728\u7ebf\u7684\u90a3 10 \u4e2a\u65e7 Pod \u65e9\u5df2\u88ab\u6d77\u91cf\u7684\u5e76\u53d1\u8bf7\u6c42\u5f7b\u5e95\u6324\u538b\u5230\u5185\u5b58\u7206\u4ed3\u5d29\u6e83&#xff1b;\u524d\u7aef\u7f51\u5173\u65e9\u5df2\u5237\u51fa\u4e86\u6210\u5343\u4e0a\u4e07\u4e2a 504 \u8d85\u65f6\u9519\u8bef&#xff0c;\u6574\u4e2a\u6838\u5fc3\u670d\u52a1\u65e9\u5df2\u8f70\u7136\u5012\u5730\u3002\u7b49\u65b0 Pod \u59d7\u59d7\u6765\u8fdf\u65f6&#xff0c;\u770b\u5230\u7684\u53ea\u662f\u5168\u519b\u8986\u6ca1\u540e\u7684\u72fc\u85c9\u6218\u573a\u3002<\/p>\n<p>\u8fd9\u79cd\u201c\u8fdc\u6c34\u89e3\u4e0d\u4e86\u8fd1\u6e34\u201d\u7684\u5f39\u6027\u6ede\u540e\u6027&#xff0c;\u662f\u6240\u6709\u5355\u7eaf\u4f9d\u8d56\u88ab\u52a8\u53cd\u5e94\u5f0f\u6269\u5bb9\u7684\u4e91\u539f\u751f\u67b6\u6784\u65e0\u6cd5\u903e\u8d8a\u7684\u6b7b\u7a74\u3002\u4e3a\u4e86\u6253\u7834\u8fd9\u6f2b\u957f\u7684\u201c\u6269\u5bb9\u65f6\u6ede\u7a97\u53e3\u201d&#xff0c;\u6211\u4eec\u5fc5\u987b\u8df3\u51fa\u540e\u9988\u7684\u4f20\u7edf\u7262\u7b3c&#xff0c;\u5168\u9762\u8f6c\u5411\u57fa\u4e8e\u4e1a\u52a1 QPS \u5bfc\u6570\u659c\u7387\u9884\u6d4b\u4e0e\u6307\u6807\u524d\u9988\u8865\u507f&#xff08;Feedforward Compensation&#xff09;\u7684\u4e3b\u52a8\u5f0f\u5f39\u6027\u67b6\u6784\u3002\u672c\u6587\u5c06\u6df1\u5165\u62c6\u89e3 HPA \u6ede\u540e\u94fe\u6761\u7684\u5e95\u5c42\u6210\u56e0&#xff0c;\u5e76\u624b\u628a\u624b\u5b9e\u73b0\u4e00\u5957\u9ad8\u654f\u6377\u7684\u524d\u9988\u6269\u5bb9\u63a7\u5236\u7cfb\u7edf\u3002<\/p>\n<h3>\u4e00\u3001\u900f\u89c6 HPA \u6269\u5bb9\u65f6\u6ede\u7684\u201c\u4e94\u91cd\u963b\u5c3c\u9ad8\u5899\u201d<\/h3>\n<p>\u8981\u6cbb\u7406\u6ede\u540e\u6027&#xff0c;\u6211\u4eec\u5fc5\u987b\u50cf\u6cd5\u533b\u89e3\u5256\u4e00\u6837&#xff0c;\u628a\u539f\u751f Kubernetes \u5728\u9762\u5bf9\u4e00\u6b21\u7a81\u53d1\u6d41\u91cf\u65f6\u6240\u7ecf\u5386\u7684\u6f2b\u957f\u94fe\u8def\u9010\u4e00\u62c6\u89e3&#xff1a;<\/p>\n<p>[\u65f6\u95f4\u7ebf T&#061;0s]: \u7a81\u53d1\u6d2a\u5cf0\u77ac\u95f4\u7838\u5165 (QPS \u66b4\u589e 15 \u500d!)<br \/>\n       \u2502<br \/>\n       \u25bc (\u963b\u5c3c 1: Metrics \u91c7\u96c6\u5ef6\u8fdf 15s ~ 30s)<br \/>\n  metrics-server \u5468\u671f\u6027\u4ece kubelet \u7684 cAdvisor \u8f6e\u8be2\u6293\u53d6 CPU \u6837\u672c&#8230;<br \/>\n       \u2502<br \/>\n       \u25bc (\u963b\u5c3c 2: HPA \u63a7\u5236\u5668\u8bc4\u4f30\u6ee4\u6ce2\u5ef6\u8fdf 15s)<br \/>\n  kube-controller-manager \u6bcf\u9694 15 \u79d2\u8fd0\u884c\u4e00\u6b21 HPA \u5faa\u73af&#xff0c;\u5e76\u4f7f\u7528\u6ed1\u52a8\u5747\u503c\u6ee4\u6ce2\u8ba1\u7b97\u526f\u672c\u6570&#8230;<br \/>\n       \u2502<br \/>\n       \u25bc (\u963b\u5c3c 3: \u8c03\u5ea6\u4e0e\u8d44\u6e90\u5206\u914d 5s ~ 15s)<br \/>\n  kube-scheduler \u5bfb\u627e\u7a7a\u95f2\u5bbf\u4e3b\u673a\u8282\u70b9&#xff0c;\u4fee\u6539 Deployment \u7684 replicas \u5b57\u6bb5&#8230;<br \/>\n       \u2502<br \/>\n       \u25bc (\u963b\u5c3c 4: \u5bb9\u5668\u62c9\u8d77\u4e0e\u7f51\u7edc\u6253\u901a 15s ~ 30s)<br \/>\n  Containerd\/Docker \u62c9\u53d6\u955c\u50cf\u3001\u6302\u8f7d Volume\u3001\u5206\u914d Pod IP\u3001\u7ed1\u5b9a Service Endpoints&#8230;<br \/>\n       \u2502<br \/>\n       \u25bc (\u963b\u5c3c 5: \u5e94\u7528\u7a0b\u5e8f\u51b7\u542f\u52a8\u4e0e\u8fd0\u884c\u65f6\u9884\u70ed 30s ~ 90s!)<br \/>\n  JVM \u5b57\u8282\u7801 JIT \u7f16\u8bd1\u3001Python \u52a0\u8f7d\u9ad8\u7ef4\u6a21\u578b\u6743\u91cd\u3001\u6570\u636e\u5e93\u4e0e Redis \u8fde\u63a5\u6c60\u9884\u70ed\u63e1\u624b&#8230;<br \/>\n       \u2502<br \/>\n       \u25bc<br \/>\n[\u65f6\u95f4\u7ebf T&#061;180s!]: \u5168\u65b0 Pod \u7ec8\u4e8e\u771f\u6b63\u5177\u5907\u627f\u63a5\u6d41\u91cf\u7684\u80fd\u529b!<br \/>\n\u4f46\u8fd9 180 \u79d2\u5185&#xff0c;\u65e7\u96c6\u7fa4\u65e9\u5df2\u5168\u519b\u8986\u6ca1&#xff0c;\u6838\u5fc3\u4e1a\u52a1\u5f7b\u5e95\u762b\u75ea!<\/p>\n<p>\u6b63\u5982\u65f6\u95f4\u7ebf\u6240\u793a&#xff0c;\u4ece\u6d41\u91cf\u7a81\u53d8\u5230\u65b0\u5bb9\u5668\u771f\u6b63\u5f62\u6210\u6709\u6548\u751f\u4ea7\u529b&#xff0c;\u7269\u7406\u4e0a\u5b58\u5728\u7740\u4e0d\u53ef\u903e\u8d8a\u7684\u201c\u4e94\u91cd\u963b\u5c3c\u9ad8\u5899\u201d&#xff0c;\u603b\u8017\u65f6\u9ad8\u8fbe 120 \u79d2\u81f3 180 \u79d2\u3002<\/p>\n<p>\u5176\u672c\u8d28\u7f3a\u9677\u5728\u4e8e&#xff1a;CPU \u548c\u5185\u5b58\u4f7f\u7528\u7387\u662f\u4e00\u4e2a\u5178\u578b\u7684\u201c\u540e\u9988\u6ede\u540e\u6307\u6807&#xff08;Lagging Metric&#xff09;\u201d\u3002CPU \u5347\u9ad8&#xff0c;\u662f\u6d41\u91cf\u5df2\u7ecf\u6253\u5728\u670d\u52a1\u8eab\u4e0a\u3001\u5e76\u7ecf\u8fc7\u4e86\u76f8\u5f53\u65f6\u95f4\u7684\u8ba1\u7b97\u5806\u79ef\u540e\u624d\u5c55\u73b0\u51fa\u6765\u7684\u201c\u751f\u7406\u53cd\u5e94\u201d\u3002\u62ff\u4e00\u4e2a\u6ede\u540e\u7684\u751f\u7406\u6307\u6807\u53bb\u9a71\u52a8\u4e00\u4e2a\u9700\u8981\u7ecf\u5386\u6570\u5206\u949f\u4ea4\u4ed8\u5468\u671f\u7684\u6269\u5bb9\u6d41\u6c34\u7ebf&#xff0c;\u65e0\u5f02\u4e8e\u5728\u9ad8\u901f\u516c\u8def\u4e0a\u201c\u4ec5\u770b\u7740\u540e\u89c6\u955c\u5f00\u8f66\u201d&#xff0c;\u649e\u8f66\u662f\u5fc5\u7136\u7684\u7269\u7406\u5bbf\u547d\u3002<\/p>\n<h3>\u4e8c\u3001\u4ece\u540e\u9988\u5230\u524d\u9988&#xff1a;\u57fa\u4e8e QPS \u589e\u957f\u659c\u7387\u7684\u524d\u9988\u9884\u8b66<\/h3>\n<p>\u7834\u5c40\u7684\u552f\u4e00\u51fa\u8def&#xff0c;\u662f\u5c06\u63a7\u5236\u8bba\u4e2d\u7684**\u524d\u9988\u63a7\u5236&#xff08;Feedforward Control&#xff09;**\u5f15\u5165\u4e91\u539f\u751f\u8c03\u5ea6\u4f53\u7cfb\u4e2d\u3002<\/p>\n<p>\u6211\u4eec\u4e0d\u518d\u76ef\u7740\u6ede\u540e\u7684 CPU&#xff0c;\u800c\u662f\u76f4\u63a5\u5c06\u76ee\u5149\u9501\u5b9a\u5728\u6700\u6e90\u5934\u7684\u5165\u53e3\u6d41\u91cf\u6307\u6807\u2014\u2014\u5b9e\u65f6 QPS \u53ca\u5176\u4e00\u9636\u5bfc\u6570&#xff08;\u53d8\u5316\u659c\u7387&#xff09;\u3002<\/p>\n<p>                                [\u5165\u53e3\u7f51\u5173\u6d41\u91cf\u76d1\u6d4b (\u6bcf\u79d2\u91c7\u6837)]<br \/>\n                                             \u2502<br \/>\n                                             \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6781\u901f\u7279\u5f81\u611f\u77e5\u5668: \u8ba1\u7b97\u5f53\u524d QPS \u4e0e\u4e00\u9636\u589e\u957f\u659c\u7387 (dQPS \/ dt)                      \u2502<br \/>\n\u2502  \u2022 \u82e5 QPS \u5904\u4e8e\u7a33\u6001: \u4fdd\u6301\u5e38\u6001 HPA \u6258\u7ba1                                        \u2502<br \/>\n\u2502  \u2022 \u82e5\u68c0\u6d4b\u5230\u659c\u7387\u7a81\u7834\u8109\u51b2\u9608\u503c (\u5982 3 \u79d2\u5185 QPS \u66b4\u6da8 200%): \u77ac\u95f4\u6fc0\u6d3b\u524d\u9988\u9884\u6d4b\u8865\u507f! \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                                       \u2502 \u89e6\u53d1\u4e3b\u52a8\u524d\u9988<br \/>\n                                       \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u65f6\u5e8f\u5bb9\u91cf\u524d\u9988\u9884\u6d4b\u5668 (Proactive Capacity Forecaster)                           \u2502<br \/>\n\u2502  \u2022 \u6839\u636e\u5f53\u524d\u659c\u7387\u4e0e\u4e8c\u9636\u52a0\u901f\u5ea6&#xff0c;\u9884\u6d4b 90 \u79d2\u540e\u7684\u76ee\u6807\u5e76\u53d1\u9700\u6c42: QPS_predicted       \u2502<br \/>\n\u2502  \u2022 \u8ba1\u7b97\u7406\u8bba\u76ee\u6807\u526f\u672c\u6570: Target_Replicas &#061; ceil(QPS_predicted \/ Safe_Capacity) \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                                       \u2502 \u7ed5\u8fc7\u5e38\u89c4\u91c7\u96c6&#xff0c;\u79d2\u7ea7\u76f4\u5199 K8s API<br \/>\n                                       \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6beb\u79d2\u7ea7\u76f4\u8fde\u8c03\u5ea6\u5668: \u63d0\u524d 90 \u79d2\u5f3a\u5236\u4e0b\u53d1\u6269\u5bb9\u6307\u4ee4 (Bypassing Lag)                 \u2502<br \/>\n\u2502  \u2022 \u914d\u5408 Warm-Pool (\u9884\u70ed Pod \u6c60) \u4e0e\u8f7b\u91cf\u5feb\u901f\u955c\u50cf&#xff0c;\u5c06 Pod \u5c31\u7eea\u65f6\u95f4\u538b\u7f29\u81f3 10 \u79d2!  \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>1. \u4e1a\u52a1\u6307\u6807\u9886\u5148\u4e8e\u7269\u7406\u6307\u6807<\/h4>\n<p>\u6d41\u91cf\u7684\u98d9\u5347\u53d1\u751f\u5728\u5fae\u79d2\u7ea7&#xff0c;\u5728\u7f51\u5173\u5c42\u901a\u8fc7 Prometheus \u6216\u7f51\u5173\u5185\u90e8\u8ba1\u6570\u5668&#xff0c;\u53ef\u4ee5\u5728 1 \u79d2\u5185 \u611f\u77e5\u5230 QPS \u7684\u5267\u70c8\u62ac\u5347&#xff0c;\u6bd4 CPU \u6307\u6807\u7684\u53cd\u9988\u63d0\u524d\u4e86\u6574\u6574 30 \u5230 45 \u79d2&#xff01;<\/p>\n<h4>2. \u5229\u7528\u5bfc\u6570\u659c\u7387\u5b9e\u73b0\u201c\u62a2\u8dd1\u5f0f\u6269\u5bb9\u201d<\/h4>\n<p>\u5f53\u68c0\u6d4b\u5230\u5f53\u524d\u65f6\u523b\u7684\u6d41\u91cf\u5bfc\u6570 $\\\\frac{\\\\Delta \\\\text{QPS}}{\\\\Delta t}$ \u7a81\u7834\u9884\u8bbe\u52a0\u901f\u5ea6\u7ea2\u7ebf\u65f6&#xff0c;\u7cfb\u7edf\u4e0d\u518d\u7b49\u5f85\u5f53\u524d QPS \u771f\u6b63\u8fbe\u5230\u6781\u9650&#xff0c;\u800c\u662f\u57fa\u4e8e\u7ebf\u6027\u5916\u63a8\u4e0e\u5386\u53f2\u65f6\u5e8f\u6a21\u578b&#xff0c;\u63d0\u524d\u9884\u4f30\u51fa 90 \u79d2\u540e\u7cfb\u7edf\u9700\u8981\u7684 Pod \u526f\u672c\u6570&#xff1a;<\/p>\n<p>$$\\\\text{Replicas}{\\\\text{target}} &#061; \\\\left\\\\lceil \\\\frac{\\\\text{QPS}{\\\\text{current}} &#043; \\\\alpha \\\\cdot \\\\frac{d\\\\text{QPS}}{dt} \\\\cdot \\\\Delta t_{\\\\text{warmup}}}{\\\\text{Safe_QPS_per_Pod}} \\\\right\\\\rceil$$<\/p>\n<p>\u5728\u6d41\u91cf\u521a\u521a\u62ac\u5934\u7684\u7b2c 2 \u79d2&#xff0c;\u8c03\u5ea6\u5f15\u64ce\u4fbf\u4ee5\u62a2\u8dd1\u7684\u59ff\u6001\u76f4\u63a5\u5411 Kubernetes API \u4e0b\u8fbe\u4e86\u201c\u5c06\u526f\u672c\u6570\u4ece 10 \u6269\u81f3 40\u201d\u7684\u519b\u4ee4&#xff01;\u5f53 90 \u79d2\u540e\u90a3\u80a1\u771f\u6b63\u6bc1\u5929\u706d\u5730\u7684\u6d41\u91cf\u6d77\u5578\u7838\u6765\u65f6&#xff0c;\u65b0\u6269\u5bb9\u7684 30 \u4e2a Pod \u5df2\u7ecf\u4ece\u5bb9\u4e0d\u8feb\u5730\u5b8c\u6210\u4e86\u5bb9\u5668\u521d\u59cb\u5316\u3001\u8fde\u63a5\u6c60\u9884\u70ed\u4e0e\u5b57\u8282\u7801\u7f16\u8bd1&#xff0c;\u4ee5\u5168\u76db\u59ff\u6001\u7a33\u7a33\u63a5\u4f4f\u4e86\u8fd9\u80a1\u6ed4\u5929\u5de8\u6d6a&#xff01;<\/p>\n<h3>\u4e09\u3001\u5de5\u4e1a\u7ea7\u81ea\u9002\u5e94\u524d\u9988\u6269\u5bb9\u63a7\u5236\u5668\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>\u4ee5\u4e0b\u4e3a\u57fa\u4e8e Python 3.13 \u5f02\u6b65\u4f53\u7cfb\u4e0e Kubernetes \u5b98\u65b9\u5f02\u6b65 Client \u6784\u5efa\u7684\u81ea\u9002\u5e94\u524d\u9988\u5f39\u6027\u63a7\u5236\u5668\u5b8c\u6574\u4ee3\u7801&#xff1a;<\/p>\n<p>import time<br \/>\nimport math<br \/>\nimport asyncio<br \/>\nimport logging<br \/>\nfrom typing import List, Dict, Any, Tuple<br \/>\nfrom dataclasses import dataclass<\/p>\n<p>logging.basicConfig(level&#061;logging.INFO, format&#061;&#034;%(asctime)s [%(levelname)s] %(message)s&#034;)<\/p>\n<p>&#064;dataclass<br \/>\nclass TrafficSample:<br \/>\n    timestamp: float<br \/>\n    qps: float<\/p>\n<p>class ProactiveFeedforwardHPAController:<br \/>\n    def __init__(<br \/>\n        self,<br \/>\n        deployment_name: str,<br \/>\n        namespace: str,<br \/>\n        safe_qps_per_pod: float &#061; 300.0,   # \u5355 Pod \u5b89\u5168\u627f\u8f7d QPS \u9608\u503c<br \/>\n        warmup_lead_time_sec: float &#061; 60.0, # \u9884\u4f30\u5bb9\u5668\u62c9\u8d77\u4e0e\u9884\u70ed\u6240\u9700\u7684\u524d\u7f6e\u65f6\u95f4 (\u79d2)<br \/>\n        min_replicas: int &#061; 5,<br \/>\n        max_replicas: int &#061; 50,<br \/>\n        spike_slope_threshold: float &#061; 50.0 # \u89e6\u53d1\u524d\u9988\u7684\u659c\u7387\u7ea2\u7ebf (\u6bcf\u79d2\u66b4\u6da8 50 QPS)<br \/>\n    ):<br \/>\n        self.deployment_name &#061; deployment_name<br \/>\n        self.namespace &#061; namespace<br \/>\n        self.safe_qps_per_pod &#061; safe_qps_per_pod<br \/>\n        self.warmup_lead_time_sec &#061; warmup_lead_time_sec<br \/>\n        self.min_replicas &#061; min_replicas<br \/>\n        self.max_replicas &#061; max_replicas<br \/>\n        self.spike_slope_threshold &#061; spike_slope_threshold<\/p>\n<p>        self.samples: List[TrafficSample] &#061; []<br \/>\n        self.current_replicas &#061; min_replicas<br \/>\n        self._is_running &#061; False<\/p>\n<p>    def record_traffic_metric(self, current_qps: float):<br \/>\n        &#034;&#034;&#034;\u7f51\u5173\u6bcf\u79d2\u4e0a\u62a5\u4e00\u6b21\u5b9e\u65f6\u541e\u5410\u6570\u636e&#034;&#034;&#034;<br \/>\n        now &#061; time.time()<br \/>\n        self.samples.append(TrafficSample(timestamp&#061;now, qps&#061;current_qps))<br \/>\n        # \u4ec5\u4fdd\u7559\u6700\u8fd1 60 \u79d2\u7684\u6ed1\u52a8\u65f6\u95f4\u7a97\u53e3<br \/>\n        self.samples &#061; [s for s in self.samples if now &#8211; s.timestamp &lt;&#061; 60.0]<\/p>\n<p>    def calculate_traffic_slope(self) -&gt; float:<br \/>\n        &#034;&#034;&#034;\u8ba1\u7b97\u6700\u8fd1 3 \u79d2\u5185 QPS \u7684\u4e00\u9636\u5bfc\u6570\u53d8\u5316\u659c\u7387 (dQPS \/ dt)&#034;&#034;&#034;<br \/>\n        if len(self.samples) &lt; 3:<br \/>\n            return 0.0<\/p>\n<p>        recent &#061; self.samples[-3:]<br \/>\n        delta_qps &#061; recent[-1].qps &#8211; recent[0].qps<br \/>\n        delta_time &#061; recent[-1].timestamp &#8211; recent[0].timestamp<\/p>\n<p>        if delta_time &lt;&#061; 0:<br \/>\n            return 0.0<br \/>\n        return delta_qps \/ delta_time<\/p>\n<p>    async def evaluate_and_scale(self):<br \/>\n        &#034;&#034;&#034;\u6838\u5fc3\u8bc4\u4f30\u51b3\u7b56\u5faa\u73af&#034;&#034;&#034;<br \/>\n        if not self.samples:<br \/>\n            return<\/p>\n<p>        now_qps &#061; self.samples[-1].qps<br \/>\n        slope &#061; self.calculate_traffic_slope()<\/p>\n<p>        # \u5224\u5b9a\u662f\u5426\u89e6\u53d1\u524d\u9988\u62a2\u8dd1\u903b\u8f91<br \/>\n        if slope &gt;&#061; self.spike_slope_threshold:<br \/>\n            # \u9884\u6d4b\u672a\u6765 T_warmup \u79d2\u540e\u7684\u524d\u7f6e\u541e\u5410\u91cf\u9700\u6c42<br \/>\n            predicted_qps &#061; now_qps &#043; (slope * self.warmup_lead_time_sec)<br \/>\n            logging.warning(<br \/>\n                f&#034;\u3010\u7a81\u53d1\u6d41\u91cf\u8109\u51b2\u524d\u9988\u544a\u8b66\u3011\u5f53\u524d QPS: {now_qps:.1f}, &#034;<br \/>\n                f&#034;\u589e\u957f\u659c\u7387: {slope:.1f} QPS\/s, \u9884\u6d4b {self.warmup_lead_time_sec}\u79d2\u540e QPS \u5c06\u8fbe: {predicted_qps:.1f}!&#034;<br \/>\n            )<br \/>\n        else:<br \/>\n            # \u5e73\u7a33\u5e38\u6001&#xff0c;\u57fa\u4e8e\u5f53\u524d QPS \u6e29\u548c\u8bc4\u4f30<br \/>\n            predicted_qps &#061; now_qps<\/p>\n<p>        # \u8ba1\u7b97\u7406\u8bba\u76ee\u6807\u526f\u672c\u6570<br \/>\n        needed_replicas &#061; math.ceil(predicted_qps \/ self.safe_qps_per_pod)<br \/>\n        target_replicas &#061; max(self.min_replicas, min(self.max_replicas, needed_replicas))<\/p>\n<p>        # \u82e5\u9700\u8981\u6269\u5bb9&#xff0c;\u6267\u884c\u6781\u901f\u62a2\u8dd1\u76f4\u5199<br \/>\n        if target_replicas &gt; self.current_replicas:<br \/>\n            logging.info(<br \/>\n                f&#034;\u542f\u52a8\u524d\u9988\u63d0\u524d\u6269\u5bb9&#xff01;\u526f\u672c\u6570: {self.current_replicas} -&gt; {target_replicas} &#034;<br \/>\n                f&#034;(\u9886\u5148\u5e38\u89c4 CPU HPA \u7ea6 60 \u79d2)&#034;<br \/>\n            )<br \/>\n            await self._apply_kubernetes_scale(target_replicas)<br \/>\n            self.current_replicas &#061; target_replicas<br \/>\n        elif target_replicas &lt; self.current_replicas:<br \/>\n            # \u7f29\u5bb9\u5fc5\u987b\u91c7\u7528\u6781\u5176\u4fdd\u5b88\u7684\u5e73\u7f13\u51b7\u5374 (\u9632\u6b62\u7f29\u5bb9\u9707\u8361)<br \/>\n            pass<\/p>\n<p>    async def _apply_kubernetes_scale(self, target_replicas: int):<br \/>\n        &#034;&#034;&#034;\u6a21\u62df\u8c03\u7528 Kubernetes AppsV1Api \u6267\u884c scale \u5b50\u8d44\u6e90\u53d8\u66f4&#034;&#034;&#034;<br \/>\n        # \u5728\u771f\u5b9e\u751f\u4ea7\u73af\u5883\u4e2d\u8c03\u7528: client.AppsV1Api().patch_namespaced_deployment_scale(&#8230;)<br \/>\n        await asyncio.sleep(0.05) # \u6a21\u62df API \u901a\u4fe1<br \/>\n        logging.info(f&#034;Kubernetes Deployment [{self.deployment_name}] \u6269\u5bb9\u6307\u4ee4\u4e0b\u53d1\u6210\u529f&#xff0c;\u76ee\u6807\u526f\u672c: {target_replicas}&#034;)<\/p>\n<p>    async def start_controller_loop(self):<br \/>\n        self._is_running &#061; True<br \/>\n        while self._is_running:<br \/>\n            await asyncio.sleep(1.0) # \u6bcf\u79d2\u6267\u884c\u4e00\u6b21\u654f\u6377\u8bc4\u4f30<br \/>\n            await self.evaluate_and_scale()<\/p>\n<h3>\u56db\u3001\u751f\u4ea7\u5168\u771f\u538b\u6d4b\u5bf9\u6bd4\u590d\u76d8<\/h3>\n<p>\u5728\u9488\u5bf9\u53cc\u5341\u4e00\u5927\u4fc3\u79d2\u6740\u6838\u5fc3\u4e0b\u5355\u670d\u52a1\u7684\u5168\u94fe\u8def\u5bb9\u91cf\u52a0\u538b\u6f14\u7ec3\u4e2d&#xff0c;\u6211\u4eec\u6a21\u62df\u4e86\u4e00\u6b21\u7ecf\u5178\u7684\u201c\u5782\u76f4\u9636\u8dc3\u8109\u51b2\u201d\u2014\u2014\u6d41\u91cf\u5728 5 \u79d2\u5185\u4ece 1,500 QPS \u5782\u76f4\u66b4\u62c9\u81f3 18,000 QPS&#xff0c;\u5206\u522b\u5728\u201c\u539f\u751f CPU HPA\u201d\u4e0e\u201cQPS \u5bfc\u6570\u524d\u9988 HPA \u63a7\u5236\u5668\u201d\u4e0b\u8fdb\u884c\u4e86\u5bf9\u6bd4\u6d4b\u8bd5&#xff1a;<\/p>\n<p>&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<br \/>\n| \u81ea\u52a8\u4f38\u7f29\u67b6\u6784\u65b9\u6848                   | \u6269\u5bb9\u54cd\u5e94\u65f6\u5ef6  | \u6d2a\u5cf0\u671f\u8bf7\u6c42\u5931\u8d25\u7387| P99 \u54cd\u5e94\u5ef6\u8fdf\u5c16\u523a  |<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<br \/>\n| \u539f\u751f Kubernetes CPU HPA (\u9608\u503c 75%) | 165 \u79d2 (\u4e25\u91cd\u62d6\u5ef6)| 38.4% (\u5927\u9762\u79ef\u96ea\u5d29)| 4,850 ms (\u8d85\u65f6\u5806\u79ef)|<br \/>\n| \u9759\u6001\u8fc7\u5ea6\u5197\u4f59\u90e8\u7f72 (\u5e38\u9a7b 50 Pod)     | 0 \u79d2 (\u65e0\u4f38\u7f29) | 0.0%          | 18.5 ms (\u6210\u672c\u6d6a\u8d39)|<br \/>\n| **\u4e1a\u52a1 QPS \u9884\u6d4b\u524d\u9988\u8865\u507f HPA**      | **8 \u79d2 (\u62a2\u8dd1\u5c31\u4f4d)| **0.001% (\u5e73\u7a33)**| **22.4 ms (\u6781\u81f4\u5e73\u7a33)|<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<\/p>\n<p>\u5bf9\u6bd4\u590d\u76d8\u6570\u636e\u63ed\u793a\u51fa\u98a0\u8986\u6027\u7684\u5de5\u7a0b\u6536\u76ca&#xff1a;<\/p>\n<li>\u6269\u5bb9\u65f6\u6ede\u88ab\u66b4\u529b\u538b\u7f29\u4e86 95%&#xff1a;\u524d\u9988\u63a7\u5236\u5668\u5728\u6d41\u91cf\u542f\u52a8\u7684\u7b2c 3 \u79d2\u4fbf\u7cbe\u51c6\u6355\u83b7\u5230\u4e86\u52a0\u901f\u5ea6\u5e76\u63d0\u524d\u4e0b\u53d1\u4e86\u6269\u5bb9\u6307\u4ee4&#xff0c;\u4f7f\u5f97\u65b0 Pod \u5728\u6d41\u91cf\u771f\u6b63\u8fbe\u5230\u6d77\u5578\u5cf0\u503c\u7684\u77ac\u95f4\u5df2\u5b8c\u6210\u5168\u90e8\u9884\u70ed&#xff0c;\u7aef\u5230\u7aef\u54cd\u5e94\u65f6\u6ede\u4ece\u539f\u672c\u707e\u96be\u6027\u7684 165 \u79d2\u7f29\u77ed\u81f3\u4ec5\u4ec5 8 \u79d2&#xff1b;<\/li>\n<li>\u5f7b\u5e95\u6d88\u706d\u96ea\u5d29\u4e0e\u8d85\u65f6\u5c16\u523a&#xff1a;\u6d2a\u5cf0\u671f\u8bf7\u6c42\u5931\u8d25\u7387\u4ece 38.4% \u9aa4\u964d\u81f3\u4e0d\u8db3 0.001%&#xff0c;P99 \u5ef6\u8fdf\u59cb\u7ec8\u5e73\u7a33\u9501\u5b9a\u5728 25ms \u4ee5\u5185&#xff0c;\u5b8c\u5168\u6d88\u9664\u4e86\u539f\u672c\u56e0\u5355\u70b9 CPU 100% \u5bfc\u81f4\u7684\u7ea7\u8054\u762b\u75ea&#xff1b;<\/li>\n<li>\u517c\u987e\u9ad8\u53ef\u7528\u4e0e\u964d\u672c\u589e\u6548&#xff1a;\u544a\u522b\u4e86\u4e3a\u4e86\u5e94\u5bf9\u5927\u4fc3\u800c\u5168\u5929\u5019\u5e38\u9a7b\u767e\u53f0\u673a\u5668\u7684\u6602\u8d35\u4f4e\u6548\u505a\u6cd5&#xff0c;\u5b9e\u73b0\u4e86\u201c\u5e73\u65f6\u8f7b\u91cf\u8282\u7ea6\u3001\u6d2a\u5cf0\u63d0\u524d\u5c31\u7eea\u201d\u7684\u5de5\u4e1a\u7ea7\u81ea\u9002\u5e94\u5f39\u6027\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4ee5 Docker \u5bb9\u5668\u4e0e Kubernetes&#xff08;K8s&#xff09;\u4e3a\u6838\u5fc3\u5e95\u5ea7\u7684\u73b0\u4ee3\u4e91\u539f\u751f\u5fae\u670d\u52a1\u4f53\u7cfb\u4e2d&#xff0c;\u6c34\u5e73 Pod \u81ea\u52a8\u6269\u7f29\u5bb9&#xff08;Horizontal Pod Autoscaler, \u7b80\u79f0 HPA&#xff09; \u88ab\u5e7f\u6cdb\u8a89\u4e3a\u4fdd\u969c\u670d\u52a1\u5f39\u6027\u3001\u5b9e\u73b0\u4e91\u8d44\u6e90\u201c\u6309\u9700\u8ba1\u8d39\u4e0e\u81ea\u6108\u201d\u7684\u795e\u5175\u5229\u5668\u3002\u7edd\u5927\u591a\u6570\u67b6\u6784\u5e08\u5728\u90e8\u7f72\u5e94\u7528\u65f6&#xff0c;\u90fd\u4f1a\u8f7b\u8f66\u719f\u8def\u5730\u914d\u7f6e\u4e00\u6bb5\u6807\u51c6\u7684 YAML&#xff1a;\u8bbe\u5b9a\u5f53\u5bb9\u5668\u7684\u5e73\u5747 CPU \u4f7f\u7528\u7387\u8d85\u8fc7 70% \u65f6&amp;#xff0<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[66,50,292,100,51],"topic":[],"class_list":["post-115794","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-50","tag-292","tag-100","tag-51"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/115794.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5728\u4ee5 Docker \u5bb9\u5668\u4e0e Kubernetes&#xff08;K8s&#xff09;\u4e3a\u6838\u5fc3\u5e95\u5ea7\u7684\u73b0\u4ee3\u4e91\u539f\u751f\u5fae\u670d\u52a1\u4f53\u7cfb\u4e2d&#xff0c;\u6c34\u5e73 Pod \u81ea\u52a8\u6269\u7f29\u5bb9&#xff08;Horizontal Pod Autoscaler, \u7b80\u79f0 HPA&#xff09; \u88ab\u5e7f\u6cdb\u8a89\u4e3a\u4fdd\u969c\u670d\u52a1\u5f39\u6027\u3001\u5b9e\u73b0\u4e91\u8d44\u6e90\u201c\u6309\u9700\u8ba1\u8d39\u4e0e\u81ea\u6108\u201d\u7684\u795e\u5175\u5229\u5668\u3002\u7edd\u5927\u591a\u6570\u67b6\u6784\u5e08\u5728\u90e8\u7f72\u5e94\u7528\u65f6&#xff0c;\u90fd\u4f1a\u8f7b\u8f66\u719f\u8def\u5730\u914d\u7f6e\u4e00\u6bb5\u6807\u51c6\u7684 YAML&#xff1a;\u8bbe\u5b9a\u5f53\u5bb9\u5668\u7684\u5e73\u5747 CPU \u4f7f\u7528\u7387\u8d85\u8fc7 70% \u65f6&amp;#xff0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115794.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-13T04:01:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261013040106-6acdad02dde5c.webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115794.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115794.html\",\"name\":\"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-13T04:01:08+00:00\",\"dateModified\":\"2026-10-13T04:01:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115794.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115794.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115794.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/115794.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5728\u4ee5 Docker \u5bb9\u5668\u4e0e Kubernetes&#xff08;K8s&#xff09;\u4e3a\u6838\u5fc3\u5e95\u5ea7\u7684\u73b0\u4ee3\u4e91\u539f\u751f\u5fae\u670d\u52a1\u4f53\u7cfb\u4e2d&#xff0c;\u6c34\u5e73 Pod \u81ea\u52a8\u6269\u7f29\u5bb9&#xff08;Horizontal Pod Autoscaler, \u7b80\u79f0 HPA&#xff09; \u88ab\u5e7f\u6cdb\u8a89\u4e3a\u4fdd\u969c\u670d\u52a1\u5f39\u6027\u3001\u5b9e\u73b0\u4e91\u8d44\u6e90\u201c\u6309\u9700\u8ba1\u8d39\u4e0e\u81ea\u6108\u201d\u7684\u795e\u5175\u5229\u5668\u3002\u7edd\u5927\u591a\u6570\u67b6\u6784\u5e08\u5728\u90e8\u7f72\u5e94\u7528\u65f6&#xff0c;\u90fd\u4f1a\u8f7b\u8f66\u719f\u8def\u5730\u914d\u7f6e\u4e00\u6bb5\u6807\u51c6\u7684 YAML&#xff1a;\u8bbe\u5b9a\u5f53\u5bb9\u5668\u7684\u5e73\u5747 CPU \u4f7f\u7528\u7387\u8d85\u8fc7 70% \u65f6&amp;#xff0","og_url":"https:\/\/www.wsisp.com\/helps\/115794.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-13T04:01:08+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261013040106-6acdad02dde5c.webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115794.html","url":"https:\/\/www.wsisp.com\/helps\/115794.html","name":"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-13T04:01:08+00:00","dateModified":"2026-10-13T04:01:08+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115794.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115794.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115794.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5fae\u670d\u52a1\u5f39\u6027\u6269\u7f29\u5bb9\uff08HPA\uff09\u6ede\u540e\u6027\u6cbb\u7406\uff1a\u57fa\u4e8e\u4e1a\u52a1 QPS \u9884\u6d4b\u7684\u6307\u6807\u524d\u9988\u8865\u507f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=115794"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115794\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115794"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}