httpd加tomcat做负载均衡,采用session复制方式共享session,采用http-proxy连接方式,打开status mod
一、没有做httpd和tomcat的启动参数修改,包括jvm内存和连接数限制的修改
<wbr><wbr><wbr>用ab测试:-n2650 -c265 http://localhost/test/page1.html。没有问题,吞吐量为290kb左右。</wbr></wbr></wbr>
<wbr><wbr><wbr>再测试:-n2660 -c266 http://localhost/test/page1.html。</wbr></wbr></wbr>
报错:
<wbr><wbr><wbr><wbr><wbr><wbr><wbr>Completed 266 requests</wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr>Test aborted after 10 failures</wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr><wbr>apr_socket_connect(): 由于目标机器积极拒绝,无法连接。 <wbr><wbr>(730061)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr>Total of 448 requests completed<br><wbr><wbr><wbr>估计是httpd默认最大线程数是265。</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
二、调整httpd的httpd.conf里的参数,找到#Include conf/extra/httpd-mpm.conf,将其注释去掉,引入mpm_winnt_module来做MPM,将httpd-mpm.conf中mpm_winnt_module里的参数调整为:
<wbr><wbr><wbr>ThreadsPerChild 1920<br><wbr><wbr><wbr>MaxRequestsPerChild 0</wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr>注意,一般windows系统每个进程可以启动的最大线程数为1920个,也就是ThreadsPerChild最大值为1920。测试结果可以支持到1000个并发,吞吐量为200kb左右。1200个并发系统报错:</wbr></wbr></wbr>
<wbr><img src="https://img-blog.csdn.net/20140410105443734" alt=""></wbr>
<wbr><span style="color:#ff0000"><strong>到目前为止还没找到可以支持1200个并发以上的方法。。。。</strong></span></wbr>
三、对两个tomcat jvm参数进行设置,min 480m, max 480m
<wbr><wbr><wbr>结果可以支持1000个并发,吞吐量还是200kb左右。</wbr></wbr></wbr>
<wbr></wbr>
<wbr></wbr>
<wbr></wbr>
附:tomcat配置文件中连接参数:
<wbr>maxThreads="600" <wbr><wbr><wbr><wbr><wbr><wbr><wbr>///最大线程数 <wbr><wbr><br><wbr>minSpareThreads="100"///初始化时创建的线程数 <wbr><wbr><br><wbr>maxSpareThreads="500"///一旦创建的线程超过这个值,Tomcat就会关闭不再需要的socket线程。 <wbr><wbr><br><wbr>acceptCount="700"//指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理 <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>