Docs/linux基础/优化Haproxy/5.html
2022-10-18 16:59:37 +08:00

165 lines
No EOL
6.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="tool" content="leanote-desktop-app">
<title>5</title>
<style>
*{font-family:"lucida grande","lucida sans unicode",lucida,helvetica,"Hiragino Sans GB","Microsoft YaHei","WenQuanYi Micro Hei",sans-serif;}
body {
margin: 0;
}
/*公用文字样式*/
h1{font-size:30px}h2{font-size:24px}h3{font-size:18px}h4{font-size:14px}
.note-container{
width:850px;
margin:auto;
padding: 10px 20px;
box-shadow: 1px 1px 10px #eee;
}
#title {
margin: 0;
}
table {
margin-bottom: 16px;
border-collapse: collapse;
}
table th, table td {
padding: 6px 13px;
border: 1px solid #ddd;
}
table th {
font-weight: bold;
}
table tr {
background-color: none;
border-top: 1px solid #ccc;
}
table tr:nth-child(2n) {
background-color: rgb(247, 247, 249);
}
.mce-item-table, .mce-item-table td, .mce-item-table th, .mce-item-table caption {
border: 1px solid #ddd;
border-collapse: collapse;
padding: 6px 13px;
}
blockquote {
border-left-width:10px;
background-color:rgba(128,128,128,0.05);
border-top-right-radius:5px;
border-bottom-right-radius:5px;
padding:15px 20px;
border-left:5px solid rgba(128,128,128,0.075);
}
blockquote p {
margin-bottom:1.1em;
font-size:1em;
line-height:1.45
}
blockquote ul:last-child,blockquote ol:last-child {
margin-bottom:0
}
pre {
padding: 18px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
border-radius: 3px;
display: block;
}
code {
padding: 2px 4px;
font-size: 90%;
color: #c7254e;
white-space: nowrap;
background-color: #f9f2f4;
border-radius: 4px;
}
.footnote {
vertical-align: top;
position: relative;
top: -0.5em;
font-size: .8em;
}
hr {
margin:2em 0
}
img {
max-width:100%
}
pre {
word-break:break-word
}
p,pre,pre.prettyprint,blockquote {
margin:0 0 1.1em
}
hr {
margin:2em 0
}
img {
max-width:100%
}
.sequence-diagram,.flow-chart {
text-align:center;
margin-bottom:1.1em
}
.sequence-diagram text,.flow-chart text {
font-size:15px !important;
font-family:"Source Sans Pro",sans-serif !important
}
.sequence-diagram [fill="#ffffff"],.flow-chart [fill="#ffffff"] {
fill:#f6f6f6
}
.sequence-diagram [stroke="#000000"],.flow-chart [stroke="#000000"] {
stroke:#3f3f3f
}
.sequence-diagram text[stroke="#000000"],.flow-chart text[stroke="#000000"] {
stroke:none
}
.sequence-diagram [fill="#000"],.flow-chart [fill="#000"],.sequence-diagram [fill="#000000"],.flow-chart [fill="#000000"],.sequence-diagram [fill="black"],.flow-chart [fill="black"] {
fill:#3f3f3f
}
ul,ol {
margin-bottom:1.1em
}
ul ul,ol ul,ul ol,ol ol {
margin-bottom:1.1em
}
kbd {
padding:.1em .6em;
border:1px solid rgba(63,63,63,0.25);
-webkit-box-shadow:0 1px 0 rgba(63,63,63,0.25);
box-shadow:0 1px 0 rgba(63,63,63,0.25);
font-size:.7em;
font-family:sans-serif;
background-color:#fff;
color:#333;
border-radius:3px;
display:inline-block;
margin:0 .1em;
white-space:nowrap
}
.toc ul {
list-style-type:none;
margin-bottom:15px
}
</style>
<!-- 该css供自定义样式 -->
<link href="../leanote-html.css" rel="stylesheet">
</head>
<body>
<div class="note-container">
<h1 class="title" id="leanote-title">5</h1>
<div class="content-html" id="leanote-content"><p>从中我们可以清晰看出在6核心机器上最大每秒请求数从20k降低到了8k。显然增加了休眠时间之后由于大量的TCP连接数对结果产生了较大影响。不过此时总的连接数已经接近我们期望的700k的水位。</p><h2>里程碑 #1</h2><p>我们如何增加TCP连接数非常简单只需要通过sleep参数增加休眠时间。我们持续增加该参数最终停留在60秒既最终平均延迟在30秒左右。</p><p>Vegeta提供了一个有趣的参数请求成功率。我们发现在该休眠时间下只有50%的请求成功率。参见下面数据:</p><p>&nbsp;<img id="__LEANOTE_D_IMG_1505975516327" src="5_files/59c3ceadd01cce1c4d000035.png" alt="" width="550" data-mce-src="/api/file/getImage?fileId=59c3ceadd01cce1c4d000035"></p><p>通过设置60000毫秒休眠时间我们达到了高达400k TCP连接数同时每秒请求数8k的结果。图表中60000R中的R代表随机。</p><p>对此我们发现的第一个问题是Vegeta的默认请求超时时间是30秒因此会有50%的请求失败。因此我们将这个超时时间设置撑了70s以避免在后续测试到再次遇到。&nbsp;<img id="__LEANOTE_D_IMG_1505975516328" src="5_files/59c3ceadd01cce1c4d000036.png" alt="" width="550" data-mce-src="/api/file/getImage?fileId=59c3ceadd01cce1c4d000036"></p><p>修改了客户端超时时间之后我们很容易的达到了700k个连接。唯一的问题是连接数这个数据不稳定只是峰值数据能够达到。因此系统峰值连接数能够达到600k到700k但是并不能长时间维持。</p><p>我们希望能够达到这样的效果:</p><p><img id="__LEANOTE_D_IMG_1505975516329" src="5_files/59c3ceadd01cce1c4d000037.png" alt="" width="550" data-mce-src="/api/file/getImage?fileId=59c3ceadd01cce1c4d000037"></p><p>该图展示了连接数稳定维持在780k。上面表格数据中每秒钟请求数非常高但在实际生产环境中单台HAProxy机器上的请求数要少很多大约在300左右</p><p>但是我们如果大幅削减生产环境中的HAProxy机器目前大约在30台这意味着集群每秒请求数为30*300大约9k首先遇到的瓶颈会是TCP连接数而不是CPU。</p><blockquote><p>因此我们决定尝试验证每秒请求数900、网络带宽30MB/s和2.1M TCP连接数的场景下验证。我们使用该场景是因为这是生产环境单台HAProxy机器压力的3倍。</p></blockquote><p>另外目前仅仅给HAProxy分配了6个内核。我们希望测试分配3个内核时的性能因为这是我们模拟生产环境机器配置的最简单方式前面提到过我们的生产环境机器配置是4核30GB内存。因此设置<code>nbproc = 3</code>是最方便的方式。</p><pre>记住现在我们使用的机器是16核30GB内存其中3个内核分配给HAProxy。</pre></div>
</div>
<!-- 该js供其它处理 -->
<script src="../leanote-html.js"></script>
</body>
</html>