论坛首页 Java企业应用论坛

tomcat 优化到每秒并发1000

浏览 185554 次
该帖已经被评为精华帖
作者 正文
   发表时间:2009-01-06  
robbin 写道
codeutil 写道

楼主用的cpu 貌似32位的,操作系统 是windows
robbin用的cpu 貌似64位的,操作系统 是linux.

java在linux及64位下可以发挥的非常好。



嘿嘿,俺是64位的CPU,64位的Linux操作系统,再配上64位的JDK,齐活了,那性能真不是盖的!



对robin的回答失望。。。。64位JDK的性能, 任何BENCHMARK都没有超过同一系统下的32位JDK。
0 请登录后投票
   发表时间:2009-01-07  
sdh5724 写道
64位JDK的性能, 任何BENCHMARK都没有超过同一系统下的32位JDK。

有数据支持吗?

这里有其他人作的64位JRE和32位JRE对比:
64bit java 6 on ubuntu 64:
http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=java&lang2=java

32bit java 6 on ubuntu 32:
http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=java&lang2=java

每一项都是64位的比32要快
0 请登录后投票
   发表时间:2009-01-07  
在4G内存Linux下跑楼主这个测试1000并发是很容易完成的,然而我多次测试中,发现结果很不稳定,ab -n 10000 -c 1000测试结果中,Requests per second结果变化很大,好的时候有1500左右,差的200多。

在这种压力的测试下,CPU不会成为瓶颈。实践中发现最大的影响大概是大量端口处于TIME_WAIT,所以需要调整内核快速回收端口和重用这些端口。

我把tomcat和ab分别运行在不同的机器上,ab -n 10000 -c 1000测试结果比较均匀,基本维持在1400上。另外,测试过程中发现minSpareThreads和maxSpareThreads对测试结果是有影响的,不管是apahe还是tomcat。
0 请登录后投票
   发表时间:2009-01-08  
netrice 写道
我的测试环境貌似还可以..
同时开3个ab,参数如下
ab -n 10000 -c 1000 http://172.16.88.96:82/wb/main/book.jspx
一共失败了4个,测试的页面是一个集Strut 1.3+spring2+hibernate3外加hsqldb内存数据库的测试环境
,页面生成的是个很小的json数据,不知道是不是因为页面很小的缘故...
{pageSize:1,root:[{"content":"1","id":1,"price":"1.0000","name":"1"}]}


D:\Apache2\bin>ab -n 10000 -c 1000 http://172.16.88.96:82/wb/main/book.jspx
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.88.96 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests


实际上和tomcat处理页面的时间是很有关系!


Server Software:        Apache-Coyote/1.1
Server Hostname:        172.16.88.96
Server Port:            82

Document Path:          /wb/main/book.jspx
Document Length:        72 bytes

Concurrency Level:      1000
Time taken for tests:   51.843750 seconds
Complete requests:      10000
Failed requests:        1
   (Connect: 1, Length: 0, Exceptions: 0)
Write errors:           0
Total transferred:      4020000 bytes
HTML transferred:       720000 bytes
Requests per second:    192.89 [#/sec] (mean)
Time per request:       5184.375 [ms] (mean)
Time per request:       5.184 [ms] (mean, across all concurrent requests)
Transfer rate:          75.71 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    4  46.3      0    1000
Processing:   156 4764 1780.7   4469    8546
Waiting:       15 2613 1727.6   2250    7453
Total:        156 4768 1781.5   4484    8546

Percentage of the requests served within a certain time (ms)
  50%   4484
  66%   5734
  75%   6296
  80%   6609
  90%   7078
  95%   7578
  98%   8031
  99%   8078
100%   8546 (longest request)

0 请登录后投票
   发表时间:2009-01-08  
我认为4G的内存也好,10G内存也好,从硬件方面来说不是问题,关键是你的Tomcat有没有正确的使用这些资源,比如说,你分配给Tomcat的1400M内存,Tomcat有没有如数得到期,也就是说你对Tomcat的每项优化有没有配置成功,我记得以前我对Tomcat的内存设置最多只配过1G的内存,超过Tomcat就启不来(不晓得是不是我那里配得有问题),Tomcat为5.0.28
0 请登录后投票
   发表时间:2009-01-08  
zl5897 写道
在4G内存Linux下跑楼主这个测试1000并发是很容易完成的,然而我多次测试中,发现结果很不稳定,ab -n 10000 -c 1000测试结果中,Requests per second结果变化很大,好的时候有1500左右,差的200多。

在这种压力的测试下,CPU不会成为瓶颈。实践中发现最大的影响大概是大量端口处于TIME_WAIT,所以需要调整内核快速回收端口和重用这些端口。

我把tomcat和ab分别运行在不同的机器上,ab -n 10000 -c 1000测试结果比较均匀,基本维持在1400上。另外,测试过程中发现minSpareThreads和maxSpareThreads对测试结果是有影响的,不管是apahe还是tomcat。


ab -k -n 10000 -c 1000  这样就能保持连接了。  一般, 压力特别高访问系统, 需要在系统里降低TIME_WAIT的设置时间, 这个在linux下大约是60秒, 可以降低到15-20ms, 不建议降到太小, 会造成问题的。
0 请登录后投票
   发表时间:2009-01-14   最后修改:2009-01-14
我随便在自己的破笔记本上跑了一下就是1600左右,

Requests per second:    1645.25 [#/sec] (mean)

我都没改connector,全默认
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />



C:\Projects\Apache2.2\bin>ab -n 10000 -c 800 http://16.157.53.105:8080/index.jsp
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 16.157.53.105 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache-Coyote/1.1
Server Hostname:        16.157.53.105
Server Port:            8080

Document Path:          /index.jsp
Document Length:        8339 bytes

Concurrency Level:      800
Time taken for tests:   6.078 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      84660000 bytes
HTML transferred:       83390000 bytes
Requests per second:    1645.25 [#/sec] (mean)
Time per request:       486.247 [ms] (mean)
Time per request:       0.608 [ms] (mean, across all concurrent requests)
Transfer rate:          13602.27 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.4      0      16
Processing:    31  466  93.7    469     703
Waiting:       16  233 131.4    234     656
Total:         31  466  93.8    469     703

Percentage of the requests served within a certain time (ms)
  50%    469
  66%    469
  75%    484
  80%    516
  90%    562
  95%    625
  98%    672
  99%    687
100%    703 (longest request)
0 请登录后投票
   发表时间:2009-02-27  
ab -n 100000 -c 1000 http://127.0.0.1:8080/index.jsp

Server Software:        Apache-Coyote/1.1
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /index.jsp
Document Length:        8339 bytes

Concurrency Level:      1000
Time taken for tests:   15.933597 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      846625398 bytes
HTML transferred:       833925017 bytes
Requests per second:    6276.05 [#/sec] (mean)
Time per request:       159.336 [ms] (mean)
Time per request:       0.159 [ms] (mean, across all concurrent requests)
Transfer rate:          51889.23 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   55 605.3      0    9001
Processing:     0   36 404.1     14   12915
Waiting:        0   35 404.1     13   12915
Total:          7   92 886.9     14   15915

Percentage of the requests served within a certain time (ms)
  50%     14
  66%     14
  75%     14
  80%     14
  90%     14
  95%     16
  98%     26
  99%   3000
100%  15915 (longest request)
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics