node和tomcat压力测试性能比较,结果不明显啊
发布于 11 年前 作者 lixld 7353 次浏览 最后一次编辑是 8 年前

测试环境:linux 单核双cpu [root[[[[[[[[[[[[[[[[[[[[[@bi-01](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01)](/user/bi-01) node-v0.10.25]# free -m total used free shared buffers cached Mem: 7928 5035 2893 0 215 3778 -/+ buffers/cache: 1041 6886 Swap: 8095 0 8095

测试工具:apache自带测试工具ab

测试内容:没有业务,纯访问量测试,只是简单返回hello word!

测试压力:1000并发,1000次请求,内网测试

============================================================================================ tomcat结果: C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 1000 -c 1000 htt p://10.10.110.169:8280/test.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 10.10.110.169 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests

Server Software: Apache-Coyote/1.1 Server Hostname: 10.10.110.169 Server Port: 8280

Document Path: /test.jsp/ Document Length: 982 bytes

Concurrency Level: 1000 Time taken for tests: 0.777 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Non-2xx responses: 1000 Total transferred: 1151000 bytes HTML transferred: 982000 bytes Requests per second: 1286.93 [#/sec] (mean) Time per request: 777.045 [ms] (mean) Time per request: 0.777 [ms] (mean, across all concurrent requests) Transfer rate: 1446.54 [Kbytes/sec] received

=========================================================================================== node结果: C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 1000 -c 1000 htt p://10.10.110.169:3000/ 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 10.10.110.169 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests

Server Software: Server Hostname: 10.10.110.169 Server Port: 3000

Document Path: / Document Length: 11 bytes

Concurrency Level: 1000 Time taken for tests: 0.633 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 112000 bytes HTML transferred: 11000 bytes Requests per second: 1579.69 [#/sec] (mean) Time per request: 633.036 [ms] (mean) Time per request: 0.633 [ms] (mean, across all concurrent requests) Transfer rate: 172.78 [Kbytes/sec] received

感觉二者通吐量(Requests per second)没是太明显的提升啊!倒是发现个问题:为什么tomcat的(Transfer rate)这个指标这么大呢,而node很小

最后我想说:为什么这个编辑器都不能贴图????太弱了吧!亲

12 回复

好纠结啊!自己顶起来

内存呢?node 小很多吧?

应该是8G,你看看参数,我贴出来了

难道没人测试过?都是一直在叫喊node性能高?没人动手测过?不是吧

目测该贴会变成笔记本性能帖。好吧,我认输,Core i5 Concurrency Level: 1000 Time taken for tests: 60.254 seconds Complete requests: 47000 Failed requests: 0 Write errors: 0 Total transferred: 7003000 bytes HTML transferred: 2303000 bytes Requests per second: 780.04 [#/sec] (mean) Time per request: 1281.993 [ms] (mean) Time per request: 1.282 [ms] (mean, across all concurrent requests) Transfer rate: 113.50 [Kbytes/sec] received

不过这种测试实际意义不大,底层和CPU过载都不一样。 libevent领先pthread一代,耗时上看不出,看CPU负荷就知道了。

-n1000 -c 1000 达不到并发的效果 并发是一种持续请求中同时请求的一种快照,至少-n 20000 再能看出点名堂

请赐教!说的具体点。。。

按照你的说去20000个请求去测试了。。 tomcat: Non-2xx responses: 20000 Total transferred: 23020000 bytes HTML transferred: 19640000 bytes Requests per second: 806.73 [#/sec] (mean) Time per request: 1239.571 [ms] (mean) Time per request: 1.240 [ms] (mean, across all concurrent requests) Transfer rate: 906.78 [Kbytes/sec] received

node: Concurrency Level: 1000 Time taken for tests: 20.382 seconds Complete requests: 20000 Failed requests: 0 Write errors: 0 Total transferred: 2240000 bytes HTML transferred: 220000 bytes Requests per second: 981.25 [#/sec] (mean) Time per request: 1019.108 [ms] (mean) Time per request: 1.019 [ms] (mean, across all concurrent requests) Transfer rate: 107.32 [Kbytes/sec] received

反倒不如tomcat了,作何解释。。。

@lixld 赐教谈不上。 个人理解:libevent叫你去拿快递。pthread楼下等快递。 即便如此,性能再高的平台也始终绕不过能量守恒定律。

那就是真实的情况,参考http://www.techempower.com/benchmarks/https://github.com/RestExpress/RestExpress/wiki/Echo-Benchmark-Results

各位同志们我知道什么情况了,测试的结果是对的,node确实是比javeEE的通吐量高20%,只有这么点,所以楼上的仁兄说的是对的,我之所以怀疑是因为很少有人用node和tomcat比的,很好有这方面的数据,网上的大都是很nginx+PHP, 或者python等比。 这里有个链接大家可以看看: http://www.csdn.net/article/2013-10-28/2817306-performance-comparison-between-node-and-javaee

总结下:个人认为tomcat7已经进行了很好的优化,所以性能也有明显提升,以至于差node也不是太多。不过至于我本地的生产环境,并发的峰值能达到多少没有测试出来,需要真实的生产环境测试才行。总是测试挺费劲,比起开发那是另外一种痛苦

回到顶部