系统配置:
CPU: AMD Opteron 2GHz × 2
内存: 4G RAM (其中MySQL使用了2G)
OS: SuSE Linux Enterprise Server SP3 x86_64 bit, Kernel 2.6.5
JDK: Sun HotSpot 1.5.0-10 x86_64 bit
Tomcat: 5.5.12 (APR)
Tomcat配置:
server.xml
- <Connector port="8080" maxHttpHeaderSize="8192" useBodyEncodingForURI="true"
- maxThreads="1000" minSpareThreads="25" maxSpareThreads="75"
- enableLookups="false" redirectPort="8443" acceptCount="100"
- compression="on" compressionMinSize="2048"
- compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
- connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8"/>
<Connector port="8080" maxHttpHeaderSize="8192" useBodyEncodingForURI="true" maxThreads="1000" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" compression="on" compressionMinSize="2048" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8"/>
catalina.sh这个文件啥都没有改,懒得指定JVM参数进行优化了。
测试文件就用你贴出来的那个,用ab并发1000个请求,发送10000个请求,轻轻松松跑完测试,没有一个request fail。
我特别需要声明的是,这台服务器的CPU是很古老的型号了,而且上面还跑着异常繁忙的JavaEye后台数据库。因此在这台服务器上面做测试,性 能数据受到影响是可以预见的。而且我没有对JVM参数做任何优化,也没有对Tomcat进行任何特别的优化。即便如此,轻松的支撑1000个并发,这还是 直接用ab去压tomcat,没有走lighttpd。我另外也测试了一下走lighttpd,速度稍微慢一点,但是1000并发也毫无问题。
————————————————————————————————
现在系统部署只能达到240+ , tomcat + apache 也只能到 900 + ,看到robbin的发帖能达到1000 ,不知道该如何配置,特来请教:
附带环境配置如下:
环境配置如下: (jdk没有用 -server)
- windows 2003 企业版 sp2
- Intel(R) Xeon(R) 4 CPU 5130 @ 2.0GHz 4.00GB 内存
- apache_2.2.8-win32-x86
- mod_jk-apache-2.0.59
- jdk-1_5_0_14-windows-i586-p.exe -client
- Tomcat-6.0.16 + apr
windows 2003 企业版 sp2 Intel(R) Xeon(R) 4 CPU 5130 @ 2.0GHz 4.00GB 内存 apache_2.2.8-win32-x86 mod_jk-apache-2.0.59 jdk-1_5_0_14-windows-i586-p.exe -client Tomcat-6.0.16 + apr
server.xml
- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="2000" minSpareThreads="1000"/>
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="2000"
- redirectPort="8443" enableLookups="false"
- acceptCount="5000" maxThreads="2000"/>
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="2000" minSpareThreads="1000"/> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="2000" redirectPort="8443" enableLookups="false" acceptCount="5000" maxThreads="2000"/>
catalina.bat
- set JAVA_OPTS=-Xms1400m -Xmx1400m -Djava.awt.headless=true
set JAVA_OPTS=-Xms1400m -Xmx1400m -Djava.awt.headless=true
index.jsp (除了下面这些代码,还有200行html代码,没有一个图片)
- <%
- for(int i=0;i<1000;i++){
- request.setAttribute("key_"+i,"value_"+i);
- }
- for(int i=0;i<100;i++){
- request.getSession().setAttribute("key_"+i,"value_"+i);
- }
- %>
- <br />
- <%=request.getSession().getAttribute("key_0")%>
- <%=request.getSession().getAttribute("key_0")%>
- <%=request.getSession().getAttribute("key_0")%>
- <%=request.getSession().getAttribute("key_0")%>
- <%=request.getSession().getAttribute("key_0")%>
- <%=request.getSession().getAttribute("key_0")%>
<% for(int i=0;i<1000;i++){ request.setAttribute("key_"+i,"value_"+i); } for(int i=0;i<100;i++){ request.getSession().setAttribute("key_"+i,"value_"+i); } %> <br /> <%=request.getSession().getAttribute("key_0")%> <%=request.getSession().getAttribute("key_0")%> <%=request.getSession().getAttribute("key_0")%> <%=request.getSession().getAttribute("key_0")%> <%=request.getSession().getAttribute("key_0")%> <%=request.getSession().getAttribute("key_0")%>
tomat 启动信息如下:
-----------------------------------------------------------------------------------------
单独测试tomcat基本上只能达到240+左右的并发,tomcat+apache 900+并发,如果是静态页面tomcat并发1000+没有任何问题。
tomcat基本上都保持在 20% - 45% 之间 , 内存在 80M -- 600M +之间 ,根据并发和请求的大小,内存的变法比较明显,cpu基本保存在这里,apache占用的cpu基本上是在 15% - 40%。