<!DOCTYPE html> <html> <head> <title>高并发和大流量解决方案</title> </head> <body>
<center> <p style="max-width: 100%; min-height: 1em; color: #3e3e3e; font-size: 16px; white-space: normal; line-height: 25.6px; background-color: #ffffff; box-sizing: border-box !important; word-wrap: break-word !important;"><img class="__bg_gif" data-ratio="0.13172043010752688" data-src="https://mmbiz.qpic.cn/mmbiz/QibLP1rpwH8sYPCicktMM1yia3vo4v3k9ssiaEZXbTu2fkQicEHe46BdZuW7icruIo9j4QExzqe5rude9MkwF2OCdRdA/640?wx_fmt=gif" data-type="gif" data-w="744" style="box-sizing: border-box !important; word-wrap: break-word !important; visibility: visible !important; width: auto !important;" width="auto" /></p>
<section class="" label="Powered by bj.96weixin.com" style="max-width: 100%; color: #3e3e3e; white-space: normal; background-color: #ffffff; box-sizing: border-box !important; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-top: 40px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 20px; padding-left: 20px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; vertical-align: top; background-color: #141510; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; margin-bottom: 15px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; color: #ffffff; text-align: center; letter-spacing: 3px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">#高并发架构相关概念#</strong></p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-bottom: 20px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; word-wrap: break-word !important; border: 2px dashed #c9c6c6;"><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; line-height: 1.6; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">并发:</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; word-wrap: break-word !important;"> <p style="font-size: 14px; max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">在操作系统中,是指一个时间段中有几个程序都处于已启动运行到运行完毕之间,且这几个程序都是在同一个处理机上运行,但任意一个时刻上只有一个程序在处理机上运行。</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; word-wrap: break-word !important; border: 2px dashed #c9c6c6;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; line-height: 1.6; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">我们说的高并发是什么?</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; font-size: 14px; text-align: justify; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">上面的定义明显不是我们通常所言的并发,在互联网时代,所讲的并发、高并发,通常是指并发访问。也就是在某个时间点,有多少个访问同时到来通常如果一个系统的日PV在千万以上,有可能是一个高并发的系统,但是有的公司完全不走技术路线,全靠机器堆,这不在我们的讨论范围。</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-top: 20px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; word-wrap: break-word !important; border: 2px dashed #a0a0a0;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">高并发的问题,我们具体该关心什么?</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 10px; padding-left: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 646px; vertical-align: top; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 5px; margin-bottom: 5px; max-width: 100%; box-sizing: border-box; transform: translate3d(0px, 0px, 0px); word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; color: #0d0d0d; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS:</strong>每秒钟请求或者查询的数量,在互联网领域,指每秒响应请求数(指HTTP请求)</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 10px; padding-left: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 646px; vertical-align: top; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 5px; margin-bottom: 5px; max-width: 100%; box-sizing: border-box; transform: translate3d(0px, 0px, 0px); word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; color: #0d0d0d; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">吞吐量</strong><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">:</strong>单位时间内处理的请求数量(通常由QPS与并发数决定)</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 10px; padding-left: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 646px; vertical-align: top; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 5px; margin-bottom: 5px; max-width: 100%; box-sizing: border-box; transform: translate3d(0px, 0px, 0px); word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; color: #0d0d0d; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">响应时间:</strong>从请求发出到收到响应花费的时间,例如系统处理一个HTTP请求需要100ms,这个100ms就是系统的响应时间</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 10px; padding-left: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 646px; vertical-align: top; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 5px; margin-bottom: 5px; max-width: 100%; box-sizing: border-box; transform: translate3d(0px, 0px, 0px); word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; color: #0d0d0d; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">PV:</strong>综合浏览量(Page View),即页面浏览量或者点击量,一个访客在24小时内访问的页面数量,同一个人浏览你的网站同一页面,只记作一次PV</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 10px; padding-left: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 646px; vertical-align: top; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 5px; margin-bottom: 5px; max-width: 100%; box-sizing: border-box; transform: translate3d(0px, 0px, 0px); word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; color: #0d0d0d; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">UV:</strong>独立访问(UniQue Visitor),即一定时间范围内相同访客多次访问网站,只计算为1个独立访客</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 10px; padding-left: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 646px; vertical-align: top; border-width: 0px; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 5px; margin-bottom: 5px; max-width: 100%; box-sizing: border-box; transform: translate3d(0px, 0px, 0px); word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; color: #0d0d0d; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">带宽:</strong>计算带宽大小需关注两个指标,峰值流量和页面的平均大小</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; text-align: justify; word-wrap: break-word !important;">日网站带宽=PV/统计时间(换算到秒)平均页面大小(单位KB)8</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">峰值一般是平均值的倍数,根据实际情况来定</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">QPS不等于并发连接数</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">QPS是每秒HTTP请求数量,并发连接数是系统同时处理的请求数量</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">(总PV数80%)/(6小时秒数20%)=峰值每秒请求数(QPS)</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">80%的访问量集中在20%的时间!!!</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-top: 20px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; box-shadow: #000000 0px 0px 0px; word-wrap: break-word !important; border: 2px dashed #a0a0a0;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS达到极限,各种情况如何处理?</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; color: #0d0d0d; font-size: 13px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">随着QPS的增长,每个阶段需要根据实际情况来进行优化,优化的方案也与硬件条件、网络带宽息息相关。</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS达到50</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; color: #0d0d0d; font-size: 13px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">可以称之为小型网站,一般的服务器就可以应付</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS达到100</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; color: #0d0d0d; font-size: 13px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">假设关系型数据库的每次请求在0.01秒完成</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">假设单页面只有一个SQL查询,那么100QPS意味这1秒钟完成100次请求,但是此时我们并不能保证数据库查询能完成100次</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">方案:数据库缓存层、数据库的负载均衡</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS达到800</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; color: #0d0d0d; font-size: 13px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">假设我们使用百兆带宽,意味着网站出口的实际带宽是8M左右</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">假设每个页面只有10k,在这个并发条件下,百兆带宽已经吃完</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">方案:CDN加速、负载均衡</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS达到1000</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; color: #0d0d0d; font-size: 13px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">假设使用Memcache缓存数据库查询数据,每个页面对Memcache的请求远大于直接对DB的请求</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">Memcache的悲观并发数在2W左右,但有可能在之前内网带宽已经吃光,表现出不稳定</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">方案:静态HTML缓存</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">QPS达到2000</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; color: #0d0d0d; font-size: 13px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">这个级别下,文件系统访问锁都成为灾难</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">方案:做业务分离,分布式存储</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><mpcpc js_editor_cpcad="" class="js_cpc_area res_iframe cpc_iframe" data-category_id_list="12|15|14|17|16|8|9|10|24|37|11|35|29|25|7|26|5" src="/cgi-bin/readtemplate?t=tmpl/cpc_tmpl"></mpcpc></p>
</section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding-right: 20px; padding-left: 20px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; vertical-align: top; background-color: #141510; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; margin-bottom: 15px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: center; color: #ffffff; letter-spacing: 3px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">#三种</strong><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">高并发解决方案</strong><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">#</strong></p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"></p>
</section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; word-wrap: break-word !important; border: 2px dashed #c9c6c6;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; line-height: 1.6; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">一、数据库缓存层的优化</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">什么是数据库缓存?</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">MySQL等一些常见的关系型数据库的数据都存储在磁盘中,在高并发场景下,业务应用对MySQL产生的增、删、改、查的操作造成巨大的I/O开销和查询压力,这无疑对数据库和服务器都是一种巨大的压力,为了解决此类问题,缓存数据的概念应运而生</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">为什么是要使用缓存?</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">缓存数据是为了让客户端很少甚至不访问数据库服务器进行数据的查询,高并发下,能最大程度的降低对数据库服务器的访问压力极大地解决数据库服务器的压力</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">提高应用数据的响应速度</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">用户请求-->数据查询-->连接数据库服务器并查询数据-->将数据缓存起来(HTML、内存、JSON、序列化数据)-->显示给客户端</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">用户再次请求或者新用户访问-->数据查询-->直接从缓存中获取数据-->显示给客户端</p>
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; word-wrap: break-word !important; border: 2px dashed #c9c6c6;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; line-height: 1.6; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">二、CDN加速</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">什么是CDN?</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><span style="max-width: 100%; box-sizing: border-box; letter-spacing: 0px; word-wrap: break-word !important;">CDN的全称是Content Delivery Network,即内容分发网络,尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输的更快、更稳定</span></p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">在网络各处放置节点服务器所构成的在现有的互联网基础之上的一层智能虚拟网络</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">CDN系统能够实时地根据网络流量和各节点的连接、负载状况以及到用户的距离和响应时间等综合信息将用户的请求重新导向离用户最近的服务节点上</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">使用CDN的优势?</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">本地Cache加速,提高了企业站点(尤其含有大量图片和静态页面站点)的访问速度</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">跨运营商的网络加速,保证不同网络的用户都得到良好的访问质量</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">远程访问用户根据DNS负载均衡技术智能自动选择Cache服务器</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">自动生成服务器的远程Mirror(镜像)cache服务器,远程用户访问时从cache服务器上读取数据,减少远程访问的带宽,分担网络流量,减轻原站点WEB服务器负载等功能</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">广泛分布的CDN节点加上节点之间的智能冗余机制,可以有效地预防黑客入侵</p> <img class="" data-copyright="0" data-ratio="0.6019417475728155" data-s="300,640" data-src="https://mmbiz.qpic.cn/mmbiz_jpg/QibLP1rpwH8sqPk5gTlK6sAC2qVkEGTiauu88SnnmgDIn4zVBdWoImQvdmaiaahSRIicJia7PiapNg3yAlic9YdbpAyMw/640?wx_fmt=jpeg" data-type="jpeg" data-w="515" />
</section></section></section></section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"></p>
</section></section></section><section class="" powered-by="xiumi.us" style="font-size: 16px; max-width: 100%; box-sizing: border-box; color: #3e3e3e; white-space: normal; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="padding: 10px; max-width: 100%; box-sizing: border-box; display: inline-block; width: 670px; background-color: #feffff; border-radius: 11px; word-wrap: break-word !important; border: 2px dashed #c9c6c6;"><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-bottom: 10px; max-width: 100%; box-sizing: border-box; text-align: center; font-size: 13px; word-wrap: break-word !important;"><section class="" style="padding: 3px; max-width: 100%; box-sizing: border-box; display: inline-block; border-bottom: 5px solid #314659; font-size: 15px; color: #314659; line-height: 1.6; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">三、Web服务器的负载均衡、请求分发</strong></p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">七层负载均衡的实现</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">基于URL等应用信息的负载均衡</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">Nginx的proxy是它一个很强大的功能,实现了7层负载均衡</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">Nginx实现的优点</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">功能强大,性能卓越,运行稳定</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">配置简单灵活</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">能够自动剔除工作不正常的后端服务器</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">上传文件使用异步模式</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">支持多种分配策略,可以分配权重,分配方式灵活</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">Nginx负载均衡</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">内置策略,扩展策略</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">内置策略:IP Hash、加权轮询</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">扩展策略:fair策略、通用hash、一致性hash</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">加权轮询策略</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">首先将请求都分给高权重的机器,直到该机器的权值降到了比其他机器低,才开始将请求分给下一个高权重的机器</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">当所有后端机器都down掉时,Nginx会立即将所有机器的标志位清成初始状态,以避免造成所有的机器都处于timeout的状态</p>
</section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="margin-top: 10px; max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: top; word-wrap: break-word !important;"><section style="max-width: 100%; box-sizing: border-box; width: 0.5em; height: 0.5em; display: inline-block; vertical-align: middle; border-radius: 100%; background-color: #a0a0a0; word-wrap: break-word !important;"></section><section class="" style="max-width: 100%; box-sizing: border-box; display: inline-block; vertical-align: middle; font-size: 14px; color: #646464; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;"><strong style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;">IP Hash策略</strong></p>
</section></section></section></section><section class="" powered-by="xiumi.us" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; word-wrap: break-word !important;"><section class="" style="max-width: 100%; box-sizing: border-box; text-align: justify; font-size: 14px; word-wrap: break-word !important;"> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">Nginx内置的另一个负载均衡的策略,流程和轮询很类似,只是七种的算法和具体的策略有些变化</p> <p style="max-width: 100%; box-sizing: border-box; min-height: 1em; word-wrap: break-word !important;">IP Hash算法是一种变相的轮询算法</p>
</section></section></section></section></section></section></section></section> <p style="max-width: 100%; min-height: 1em; color: #3e3e3e; font-size: 16px; white-space: normal; background-color: #ffffff; box-sizing: border-box !important; word-wrap: break-word !important;"><img class="" data-copyright="0" data-ratio="0.6564748201438849" data-s="300,640" data-src="https://mmbiz.qpic.cn/mmbiz_png/QibLP1rpwH8t3BQOcIXEn5HibW3G1DqSBbzcgTsuibWiaWWn3C3pubycO4zRt3KVRzOFyS2NanJYhibqdAW3c485YBA/640?wx_fmt=png" data-type="png" data-w="556" style="box-sizing: border-box !important; word-wrap: break-word !important; visibility: visible !important; width: auto !important;" width="auto" /></p> </center>
</body> </html>