{"id":17561,"date":"2025-06-05T10:39:16","date_gmt":"2025-06-05T02:39:16","guid":{"rendered":"https:\/\/92it.top\/?p=17561"},"modified":"2025-06-05T10:39:16","modified_gmt":"2025-06-05T02:39:16","slug":"%e4%bd%a0%e7%ba%bf%e4%b8%8a-qps-%e6%98%af%e5%a4%9a%e5%b0%91%ef%bc%9f%e4%bd%a0%e6%80%8e%e4%b9%88%e7%9f%a5%e9%81%93%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=17561","title":{"rendered":"\u4f60\u7ebf\u4e0a QPS \u662f\u591a\u5c11\uff1f\u4f60\u600e\u4e48\u77e5\u9053\u7684\uff1f"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=Mzk3NTMwOTExNg==&amp;mid=2247485826&amp;idx=1&amp;sn=f49099c9bf937ff7f13c42ce8c7a542b&amp;chksm=c56c0b57ca7422d4e692add2ff774e414dff3bd7a5ad73943c6781266fc10038e1aaa036e3a0&amp;mpshare=1&amp;scene=1&amp;srcid=0605udPwAUmIrVFacLAyyvLE&amp;sharer_shareinfo=57455d185a4af558185808ac812214b7&amp;sharer_shareinfo_first=f4f2126caa08bdbff7056db6699b887f&amp;exportkey=n_ChQIAhIQlELXGq5dkx%2B%2FsZXcCMZjthL0AQIE97dBBAEAAAAAAO5mDqO4hj0AAAAOpnltbLcz9gKNyK89dVj0T7hCoSYZOrADnoIPqdAgfWtL8LyTVYg9XYBp7zUqX%2BTKJMNQjViAuR9CGB92%2BvAzMcHdlI9BdfrfEsalPvOy8Re1FKHEc3I8nAVjjA%2FolzM1m%2BxulnPStE%2Bg80PytAK6y9p%2FaC0gAo4WdzBkCoVxBlHiYW85OCMfH9nAZ%2Bs2niSjHRkOY0IvuSp7z2D4v2VfZzYiIBNHO7RrjcYc6L6RlqTcdFrWj8QehxER4UQnYnjDFu62O0tXmW63iAj3YbMnfxOR0iIc7N%2BJWiZIK20%3D&amp;acctmode=0&amp;pass_ticket=RqV%2B5mtavIlpQ3v3kF3K4tlch2afX8jNwGuY6EPUXxH1M%2BQMHxLhXt33N42IToLE&amp;wx_header=0#rd\">\u9762\u8bd5\u5b98\u6700\u7231\u95ee\uff1a\u4f60\u7ebf\u4e0a QPS \u662f\u591a\u5c11\uff1f\u4f60\u600e\u4e48\u77e5\u9053\u7684\uff1f<\/a><\/p>\n\n\n\n<p><strong>\u8bf4\u5728\u524d\u9762<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u65e0\u6570\u5c0f\u4f19\u4f34\u4e3a\u4e86\u62ff\u9ad8\u85aa\uff0c\u75af\u72c2\u5377\u5927\u5382\u9762\u8bd5\u3001\u5377\u67b6\u6784\u5e08\u9762\u7ecf\u3002\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u51e0\u4e4e\u6210\u4e86\u9762\u8bd5\u5fc5\u8003\u9898\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u201c\u4f60\u4eec\u7cfb\u7edfQPS\u591a\u5c11\uff1f\u4f60\u600e\u4e48\u77e5\u9053\u7684\uff1f\u5982\u679c\u6bcf\u5929\u51e0\u5343\u4e07\u8bf7\u6c42\uff0c\u7cfb\u7edf\u600e\u4e48\u90e8\u7f72\uff1f\u201d<\/pre>\n\n\n\n<p>\u8fd9\u9898\u582a\u79f0\u9762\u8bd5\u754c\u7684\u201c\u9489\u5b50\u6237\u201d\uff0c<strong>10\u4e2a\u9762\u8bd59\u4e2a\u95ee<\/strong>\uff01<\/p>\n\n\n\n<p><strong>\u4e00\u3001QPS\u626b\u76f2<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>1.1 \u4ec0\u4e48\u662fQPS\uff1f<\/strong><\/p>\n\n\n\n<p><strong>QPS = \u6bcf\u79d2\u67e5\u8be2\u6570<\/strong>\uff08Query Per Second\uff09\uff0c\u7b80\u5355\u8bf4\u5c31\u662f<strong>\u670d\u52a1\u56681\u79d2\u80fd\u63a5\u591a\u5c11\u6d3b<\/strong>\u3002<br>\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5c0f\u644a\u714e\u997c\uff1a\u8001\u677f1\u5206\u949f\u80fd\u505a10\u4e2a\u714e\u997c \u2192\u00a0<strong>QPS\u22480.17<\/strong>\uff0810\/60\uff09<\/li>\n\n\n\n<li>\u80af\u5fb7\u57fa\u7a97\u53e3\uff1a1\u5206\u949f\u80fd\u51fa\u991050\u4efd \u2192\u00a0<strong>QPS\u22480.83<\/strong><\/li>\n<\/ul>\n\n\n\n<p>QPS\u8d8a\u9ad8\uff0c\u8bf4\u660e\u7cfb\u7edf\u8d8a\u80fd\u625b\uff01<\/p>\n\n\n\n<p><strong>1.2 QPS\u3001TPS\u3001RT\u7684\u5173\u7cfb<\/strong><\/p>\n\n\n\n<p>\ud83d\udd39\u00a0TPS\uff08\u6bcf\u79d2\u4e8b\u52a1\u6570\uff09<\/p>\n\n\n\n<ul>\n<li>\u4e8b\u52a1 = \u4e00\u5957\u5b8c\u6574\u64cd\u4f5c\uff08\u6bd4\u5982\u4e0b\u5355\uff1a\u9009\u5546\u54c1\u2192\u652f\u4ed8\u2192\u6263\u5e93\u5b58\uff09<\/li>\n\n\n\n<li><strong>TPS = 1\u79d2\u80fd\u5b8c\u6210\u591a\u5c11\u5957\u5b8c\u6574\u64cd\u4f5c<\/strong><\/li>\n<\/ul>\n\n\n\n<p>\ud83d\udd39\u00a0RT\uff08\u54cd\u5e94\u65f6\u95f4\uff09<\/p>\n\n\n\n<ul>\n<li>\u4ece\u4f60\u70b9\u5916\u5356\u5230\u62ff\u5230\u9910\u7684\u65f6\u95f4 \u2192\u00a0<strong>RT=30\u5206\u949f<\/strong><\/li>\n\n\n\n<li>\u7cfb\u7edf\u5904\u7406\u4e00\u4e2a\u8bf7\u6c42\u7684\u65f6\u95f4 \u2192\u00a0<strong>RT=200ms<\/strong><\/li>\n<\/ul>\n\n\n\n<p>\u4e09\u8005\u7684\u6570\u5b66\u5173\u7cfb<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">QPS = \u5e76\u53d1\u6570 \/ RT  \nTPS = QPS \u00d7 \u6bcf\u4e2a\u8bf7\u6c42\u7684\u4e8b\u52a1\u6570  <\/pre>\n\n\n\n<p>\u4e3e\u4e2a\u6817\u5b50\uff1a<\/p>\n\n\n\n<ul>\n<li>\u7cfb\u7edfRT=50ms\uff0c100\u4eba\u540c\u65f6\u70b9\u5916\u5356 \u2192 QPS = 100 \/ 0.05 = 2000<\/li>\n\n\n\n<li>\u6bcf\u4e2a\u4e0b\u5355\u8bf7\u6c42\u5305\u542b3\u4e2a\u4e8b\u52a1\uff08\u6263\u5e93\u5b58\u3001\u652f\u4ed8\u3001\u53d1\u77ed\u4fe1\uff09 \u2192 TPS = 2000 \u00d7 3 = 6000<\/li>\n<\/ul>\n\n\n\n<p><strong>1.3 \u5fc5\u987b\u77e5\u9053\u7684\u6027\u80fd\u516c\u5f0f<\/strong><\/p>\n\n\n\n<p>\ud83d\udcc8\u00a0\u4e8c\u516b\u5b9a\u5f8b\u7b97\u5cf0\u503cQPS<\/p>\n\n\n\n<p>\u5047\u8bbe\u7cfb\u7edf\u6bcf\u59291000\u4e07\u8bf7\u6c42\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u5cf0\u503cQPS = (\u603b\u8bf7\u6c42 \u00d7 80%) \/ (24h \u00d7 20% \u00d7 3600\u79d2)  \n= (10,000,000 \u00d7 0.8) \/ (6 \u00d7 3600)  \n\u2248 370 QPS  <\/pre>\n\n\n\n<p>\u8fd9\u610f\u5473\u7740\uff1a\u7cfb\u7edf\u5fc5\u987b\u80fd\u7a33\u5b9a\u625b\u4f4f370 QPS\uff0c\u5426\u5219\u9ad8\u5cf0\u671f\u5fc5\u5d29\uff01<\/p>\n\n\n\n<p><strong>\u4e8c\u3001\u5b9e\u6218\uff01\u76d1\u63a7QPS\u76844\u6b65\u5927\u6cd5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>2.1 \u7b2c\u4e00\u6b65\uff1a\u7ed9Spring Boot\u88c5\u201c\u76d1\u63a7\u63a2\u5934\u201d<\/strong><\/p>\n\n\n\n<p><strong>\u52a0\u4f9d\u8d56<\/strong><\/p>\n\n\n\n<p>\u5728\u9879\u76ee\u7684<code>pom.xml<\/code>\u91cc\u585e\u4e24\u4e2a\u201c\u76d1\u63a7\u795e\u5668\u201d\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!-- \u5065\u5eb7\u68c0\u67e5 -->  \n&lt;dependency>  \n    &lt;groupId>org.springframework.boot&lt;\/groupId>  \n    &lt;artifactId>spring-boot-starter-actuator&lt;\/artifactId>  \n&lt;\/dependency>  \n&lt;!-- Prometheus\u6570\u636e\u91c7\u96c6 -->  \n&lt;dependency>  \n    &lt;groupId>io.micrometer&lt;\/groupId>  \n    &lt;artifactId>micrometer-registry-prometheus&lt;\/artifactId>  \n&lt;\/dependency> <\/pre>\n\n\n\n<p><strong>\u6539\u914d\u7f6e<\/strong><\/p>\n\n\n\n<p><code>application.yml<\/code>\u91cc\u5f00\u653e\u76d1\u63a7\u7aef\u53e3\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">management:  \n  endpoints:  \n    web:  \n      exposure:  \n        include: \"*\"  # \u5f00\u653e\u6240\u6709\u76d1\u63a7\u6307\u6807  \n  metrics:  \n    web:  \n      server:  \n        request:  \n          metric-name: http.server.requests # \u7edf\u4e00\u6307\u6807\u540d  <\/pre>\n\n\n\n<p><strong>\u542f\u52a8\u9879\u76ee\uff0c\u67e5\u770b\u6307\u6807<\/strong><\/p>\n\n\n\n<p>\u8bbf\u95ee\u00a0<code>http:\/\/\u4f60\u7684IP:\u7aef\u53e3\/actuator\/prometheus<\/code>\uff0c\u4f60\u4f1a\u770b\u5230\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http_server_requests_seconds_count{uri=\"\/api\/order\",status=\"200\"} 358  \nhttp_server_requests_seconds_sum{uri=\"\/api\/order\",status=\"200\"} 28.5  <\/pre>\n\n\n\n<p>\u8fd9\u8868\u793a\uff1a<\/p>\n\n\n\n<ul>\n<li><code>\/api\/order<\/code>\u63a5\u53e3\u88ab\u8c03\u7528\u4e86358\u6b21\uff08<code>count<\/code>\uff09<\/li>\n\n\n\n<li>\u603b\u8017\u65f628.5\u79d2\uff08<code>sum<\/code>\uff09<\/li>\n\n\n\n<li>\u5e73\u5747RT = 28.5s \/ 358 \u2248 80ms<\/li>\n<\/ul>\n\n\n\n<p><strong>2.2 \u7b2c\u4e8c\u6b65\uff1a\u90e8\u7f72Prometheus\uff08\u76d1\u63a7\u6570\u636e\u4e2d\u5fc3\uff09<\/strong><\/p>\n\n\n\n<p><strong>\u5b89\u88c5Prometheus<\/strong><\/p>\n\n\n\n<p>\u53bb\u5b98\u7f51\u4e0b\u4e2a\u538b\u7f29\u5305\uff0c\u89e3\u538b\u540e\u6539<code>prometheus.yml<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">scrape_configs:  \n  - job_name: '\u4f60\u7684\u670d\u52a1'  \n    metrics_path: '\/actuator\/prometheus'  \n    static_configs:  \n      - targets: ['\u4f60\u7684IP:\u7aef\u53e3'] # \u6539\u6210\u4f60\u7684\u670d\u52a1\u5730\u5740  <\/pre>\n\n\n\n<p><strong>\u542f\u52a8\u547d\u4ee4<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/prometheus --config.file=prometheus.yml  <\/pre>\n\n\n\n<p>\u8bbf\u95ee\u00a0<code>http:\/\/localhost:9090<\/code>\u00a0\u5c31\u80fd\u770b\u5230\u76d1\u63a7\u6570\u636e\u5566\uff01<\/p>\n\n\n\n<p><strong>2.3 \u7b2c\u4e09\u6b65\uff1a\u7528Grafana\u641e\u4e2a\u70ab\u9177\u770b\u677f<\/strong><\/p>\n\n\n\n<p><strong>&nbsp;\u914d\u7f6e\u6570\u636e\u6e90<\/strong><\/p>\n\n\n\n<ol>\n<li>\u5b89\u88c5Grafana\u540e\uff0c\u8fdb\u5165\u9875\u9762<\/li>\n\n\n\n<li>\u5de6\u4fa7\u83dc\u5355 \u2192 \u9f7f\u8f6e\u56fe\u6807 \u2192 Data Sources \u2192 \u9009Prometheus<\/li>\n\n\n\n<li>\u586b\u5730\u5740\u00a0<code>http:\/\/localhost:9090<\/code>\u00a0\u2192 Save &amp; Test<\/li>\n<\/ol>\n\n\n\n<p><strong>&nbsp;\u521b\u5efaQPS\u76d1\u63a7\u56fe<\/strong><\/p>\n\n\n\n<ol>\n<li>\u65b0\u5efaDashboard \u2192 Add panel<\/li>\n\n\n\n<li>\u8f93\u5165PromQL\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">rate(http_server_requests_seconds_count{uri=\"\/api\/order\"}[5m])  <\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u516c\u5f0f\u7684\u610f\u601d\u662f\uff1a<strong>\u7edf\u8ba15\u5206\u949f\u5185\uff0c\/api\/order\u63a5\u53e3\u6bcf\u79d2\u7684\u8bf7\u6c42\u6570<\/strong><\/p>\n\n\n\n<ol>\n<li>\u8bbe\u7f6e\u56fe\u8868\u540d\u79f0 \u2192 Apply<\/li>\n<\/ol>\n\n\n\n<p>\u6548\u679c\u56fe\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"633\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-1024x633.png\" alt=\"\" class=\"wp-image-17562\" style=\"width:524px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-1024x633.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-300x185.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-768x475.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-830x513.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-230x142.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-350x216.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57-480x297.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-57.png 1336w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>2.4 \u7b2c\u56db\u6b65\uff1a\u9ad8\u7ea7\u64cd\u4f5c\u2014\u2014\u533a\u5206\u4e0d\u540c\u63a5\u53e3<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u7cfb\u7edf\u6709\u591a\u4e2a\u63a5\u53e3\uff08\u6bd4\u5982\u8ba2\u5355\u3001\u652f\u4ed8\u3001\u7528\u6237\uff09\uff0c\u53ef\u4ee5\u5728Grafana\u91cc\uff1a<\/p>\n\n\n\n<ol>\n<li>\u4f7f\u7528<code>legend<\/code>\u5b57\u6bb5\u663e\u793a<code>uri<\/code>\u6807\u7b7e<\/li>\n\n\n\n<li>\u6dfb\u52a0\u591a\u4e2aPromQL\uff0c\u6309\u63a5\u53e3\u62c6\u5206<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">rate(http_server_requests_seconds_count{uri=~\"\/api\/.*\"}[5m])  <\/pre>\n\n\n\n<p><strong>\u6700\u7ec8\u6548\u679c\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u6e05\u6670\u770b\u5230\u54ea\u4e2a\u63a5\u53e3\u6700\u5fd9<\/li>\n\n\n\n<li>\u5feb\u901f\u5b9a\u4f4d\u6027\u80fd\u74f6\u9888<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"229\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-1024x229.png\" alt=\"\" class=\"wp-image-17563\" style=\"width:528px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-1024x229.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-300x67.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-768x172.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-830x186.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-230x51.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-350x78.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58-480x107.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2025\/06\/image-58.png 1376w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>\u4e09\u3001\u5343\u4e07\u7ea7\u6d41\u91cf\u7684\u90e8\u7f72\u79d8\u7c4d<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>3.1 \u521d\u7ea7\u65b9\u6848\uff1a\u5355\u4f53\u67b6\u6784\u5347\u7ea7<\/strong><\/p>\n\n\n\n<p>\u7eb5\u5411\u6269\u5bb9\uff08Scale Up\uff09<\/p>\n\n\n\n<ul>\n<li>\u5347\u7ea7\u670d\u52a1\u5668\uff1aCPU\u4ece4\u6838\u219216\u6838\uff0c\u5185\u5b588G\u219264G<\/li>\n\n\n\n<li>\u9002\u7528\u573a\u666f\uff1a\u521d\u671f\u6d41\u91cf\u5c0f\uff08\u65e5\u6d3b&lt;10\u4e07\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u7f3a\u70b9\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5355\u70b9\u6545\u969c \u2192 \u670d\u52a1\u5668\u4e00\u6302\uff0c\u5168\u7ebf\u5d29\u6e83<\/li>\n\n\n\n<li>\u6210\u672c\u9ad8 \u2192 \u9876\u7ea7\u914d\u7f6e\u7684\u670d\u52a1\u5668\u4ef7\u683c\u6307\u6570\u7ea7\u4e0a\u6da8<\/li>\n<\/ul>\n\n\n\n<p><strong>3.2 \u8fdb\u9636\u65b9\u6848\uff1a\u5fae\u670d\u52a1\u62c6\u5206<\/strong><\/p>\n\n\n\n<p>\u62c6\u5206\u7b56\u7565<\/p>\n\n\n\n<ol>\n<li><strong>\u6309\u4e1a\u52a1\u62c6\u5206<\/strong>\uff1a\u8ba2\u5355\u670d\u52a1\u3001\u7528\u6237\u670d\u52a1\u3001\u652f\u4ed8\u670d\u52a1<\/li>\n\n\n\n<li><strong>\u8bfb\u5199\u5206\u79bb<\/strong>\uff1a\u8ba2\u5355\u8bfb\u5e93\u3001\u8ba2\u5355\u5199\u5e93<\/li>\n\n\n\n<li><strong>\u70ed\u70b9\u9694\u79bb<\/strong>\uff1a\u628a\u79d2\u6740\u529f\u80fd\u72ec\u7acb\u6210\u5355\u72ec\u670d\u52a1<\/li>\n<\/ol>\n\n\n\n<p>\u6280\u672f\u9009\u578b<\/p>\n\n\n\n<ul>\n<li>\u670d\u52a1\u6ce8\u518c\uff1aNacos\u3001Consul<\/li>\n\n\n\n<li>\u670d\u52a1\u901a\u4fe1\uff1aOpenFeign\u3001gRPC<\/li>\n\n\n\n<li>\u8d1f\u8f7d\u5747\u8861\uff1aRibbon\u3001Spring Cloud LoadBalancer<\/li>\n<\/ul>\n\n\n\n<p><strong>3.3 \u9ad8\u7ea7\u65b9\u6848\uff1a\u5f39\u6027\u4f38\u7f29<\/strong><\/p>\n\n\n\n<p>K8s + \u4e91\u670d\u52a1<\/p>\n\n\n\n<ol>\n<li>\u7528Kubernetes\u90e8\u7f72\u670d\u52a1<\/li>\n\n\n\n<li>\u8bbe\u7f6eHPA\uff08\u81ea\u52a8\u6269\u7f29\u5bb9\uff09\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: autoscaling\/v2  \nkind: HorizontalPodAutoscaler  \nspec:  \n  scaleTargetRef:  \n    apiVersion: apps\/v1  \n    kind: Deployment  \n    name: order-service  \n  minReplicas: 2  \n  maxReplicas: 10  \n  metrics:  \n  - type: Resource  \n    resource:  \n      name: cpu  \n      target:  \n        type: Utilization  \n        averageUtilization: 80  <\/pre>\n\n\n\n<p><strong>\u6548\u679c\uff1a<\/strong>\u00a0CPU\u8d85\u8fc780%\u65f6\uff0c\u81ea\u52a8\u65b0\u589ePod\uff0c\u6700\u591a10\u4e2a\u5b9e\u4f8b<\/p>\n\n\n\n<p><strong>3.4 \u5168\u94fe\u8def\u4f18\u5316<\/strong><\/p>\n\n\n\n<p><strong>\u5206\u5c42\u4f18\u5316\u7b56\u7565<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5c42\u7ea7<\/th><th>\u4f18\u5316\u624b\u6bb5<\/th><th>\u6548\u679c<\/th><\/tr><\/thead><tbody><tr><td><strong>\u7f51\u5173\u5c42<\/strong><\/td><td>Nginx\u9650\u6d41 + \u7f13\u5b58\u9759\u6001\u8d44\u6e90<\/td><td>\u51cf\u5c1150%\u540e\u7aef\u8bf7\u6c42<\/td><\/tr><tr><td><strong>\u670d\u52a1\u5c42<\/strong><\/td><td>\u7ebf\u7a0b\u6c60\u9694\u79bb + \u7194\u65ad\u964d\u7ea7<\/td><td>\u9632\u6b62\u96ea\u5d29\uff0c\u63d0\u5347\u53ef\u7528\u6027<\/td><\/tr><tr><td><strong>\u7f13\u5b58\u5c42<\/strong><\/td><td>Redis\u96c6\u7fa4 + \u70ed\u70b9\u6570\u636e\u672c\u5730\u7f13\u5b58<\/td><td>\u964d\u4f4eDB\u538b\u529b90%<\/td><\/tr><tr><td><strong>DB\u5c42<\/strong><\/td><td>\u5206\u5e93\u5206\u8868 + \u8bfb\u5199\u5206\u79bb<\/td><td>\u63d0\u5347\u67e5\u8be2\u901f\u5ea6300%<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u56db\u3001\u9762\u8bd5\u6ee1\u5206\u6307\u5357<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>4.1 \u6ee1\u5206\u56de\u7b54\u6a21\u677f<\/strong><\/p>\n\n\n\n<p><strong>\u9762\u8bd5\u5b98\uff1a<\/strong>&nbsp;\u4f60\u4eec\u7cfb\u7edfQPS\u591a\u5c11\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6211\u4eec\u7684\u8ba2\u5355\u7cfb\u7edf\u5cf0\u503cQPS\u57281200\u5de6\u53f3\uff0c\u901a\u8fc7Prometheus+Grafana\u5b9e\u65f6\u76d1\u63a7\u3002<br>\u4e3a\u4e86\u652f\u6491\u6bcf\u59292000\u4e07\u8bf7\u6c42\uff0c\u505a\u4e86\u4e09\u65b9\u9762\u4f18\u5316\uff1a<br><br>    \u670d\u52a1\u5c42\uff1a\u8ba2\u5355\u670d\u52a1\u62c6\u5206\u4e3a8\u4e2aPod\uff0cHPA\u6839\u636eCPU\u81ea\u52a8\u6269\u7f29<br>    \u7f13\u5b58\u5c42\uff1aRedis\u96c6\u7fa4\u7f13\u5b58\u70ed\u70b9\u8ba2\u5355\uff0c\u547d\u4e2d\u738785%<br>    DB\u5c42\uff1aMySQL\u520616\u4e2a\u5e93\uff0c\u901a\u8fc7ShardingSphere\u8def\u7531<br>    \u8fd9\u662f\u6211\u4eec\u7684\u76d1\u63a7\u770b\u677f\u622a\u56fe\uff0c\u53ef\u4ee5\u770b\u5230......\uff08\u62ff\u51fa\u624b\u673a\u5c55\u793a\uff09<\/pre>\n\n\n\n<p><strong>\u9762\u8bd5\u5b98OS\uff1a<\/strong>\u00a0\u8fd9\u54e5\u4eec\u662f\u771f\u5e72\u8fc7\uff01<\/p>\n\n\n\n<p><strong>4.2 \u9632\u5751\u6307\u5357<\/strong><\/p>\n\n\n\n<p>\u5343\u4e07\u522b\u8bf4<\/p>\n\n\n\n<ul>\n<li>\u201cQPS\u5927\u6982\u51e0\u5343\u5427\uff0c\u6ca1\u5177\u4f53\u6d4b\u8fc7\u201d \u2192 \u4e0d\u4e13\u4e1a<\/li>\n\n\n\n<li>\u201c\u76f4\u63a5\u52a0\u670d\u52a1\u5668\u641e\u5b9a\u201d \u2192 \u7f3a\u4e4f\u6280\u672f\u6df1\u5ea6<\/li>\n<\/ul>\n\n\n\n<p>\u52a0\u5206\u8bdd\u672f<\/p>\n\n\n\n<ul>\n<li>\u201c\u6211\u4eec\u901a\u8fc7\u5168\u94fe\u8def\u538b\u6d4b\u786e\u5b9a\u4e86\u7cfb\u7edf\u74f6\u9888\u201d<\/li>\n\n\n\n<li>\u201c\u7528Sentinel\u505a\u4e86\u6162\u8c03\u7528\u7194\u65ad\uff0c\u9632\u6b62\u7ea7\u8054\u6545\u969c\u201d<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4e94\u3001\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u00a0\u8981\u60f3QPS\u7b54\u5f97\u597d\uff0c\u4e09\u677f\u65a7\u4e0d\u80fd\u5c11\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u76d1\u63a7<\/strong>\uff1aPrometheus+Granfana\u5b9e\u65f6\u8ffd\u8e2a<\/li>\n\n\n\n<li><strong>\u4f18\u5316<\/strong>\uff1a\u7f13\u5b58\u3001\u5206\u5e93\u3001\u9650\u6d41\u7ec4\u5408\u62f3<\/li>\n\n\n\n<li><strong>\u90e8\u7f72<\/strong>\uff1aK8s\u5f39\u6027\u4f38\u7f29\u5e94\u5bf9\u6d41\u91cf\u9ad8\u5cf0<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1a\u9762\u8bd5\u5b98\u6700\u7231\u95ee\uff1a\u4f60\u7ebf\u4e0a QPS \u662f\u591a\u5c11\uff1f\u4f60\u600e\u4e48\u77e5\u9053\u7684\uff1f \u8bf4\u5728\u524d\u9762 \u65e0\u6570\u5c0f\u4f19\u4f34\u4e3a\u4e86\u62ff\u9ad8\u85aa\uff0c\u75af\u72c2\u5377\u5927\u5382\u9762\u8bd5\u3001\u5377 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/17561"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17561"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/17561\/revisions"}],"predecessor-version":[{"id":17564,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/17561\/revisions\/17564"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}