一直以来都认为 Netty 的性能会非常优秀,打算在适当的时候使用它来开发一些要求超高新能的服务。
今天兴致勃勃的写了个简单的 HTTP 服务,同样也用 tomcat 写了一个对比的 jsp 页面。结果测试下来,感觉 Netty 的性能提升并不显著。Netty 中采用的是 NIO 模式。Tomcat 采用了缺省配置。
看来采用 Netty 还要再慎重测试一下。当然这个测试结果也不是特别的严谨。这个结论不是最终结论。
Netty 测试结果
ab -n 10000 -c 10 http://192.168.1.237:8080/
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 192.168.1.237 (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
Server Software:
Server Hostname: 192.168.1.237
Server Port: 8080
Document Path: /
Document Length: 151 bytes
Concurrency Level: 10
Time taken for tests: 5.641704 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2110000 bytes
HTML transferred: 1510000 bytes
Requests per second: 1772.51 [#/sec] (mean)
Time per request: 5.642 [ms] (mean)
Time per request: 0.564 [ms] (mean, across all concurrent requests)
Transfer rate: 365.14 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.4 0 23
Processing: 1 4 2.1 4 37
Waiting: 0 3 1.9 3 26
Total: 2 4 2.7 5 38
Percentage of the requests served within a certain time (ms)
50% 5
66% 5
75% 5
80% 6
90% 6
95% 8
98% 12
99% 16
100% 38 (longest request)
ab -k -n 10000 -c 10 http://192.168.1.237:8080/
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 192.168.1.237 (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
Server Software:
Server Hostname: 192.168.1.237
Server Port: 8080
Document Path: /
Document Length: 151 bytes
Concurrency Level: 10
Time taken for tests: 1.546421 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 10000
Total transferred: 2560768 bytes
HTML transferred: 1510453 bytes
Requests per second: 6466.54 [#/sec] (mean)
Time per request: 1.546 [ms] (mean)
Time per request: 0.155 [ms] (mean, across all concurrent requests)
Transfer rate: 1616.64 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 0 1 1.9 1 37
Waiting: 0 0 2.1 1 37
Total: 0 1 1.9 1 38
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 2
95% 2
98% 5
99% 10
100% 38 (longest request)
Tomcat 测试结果
ab -n 10000 -c 10 http://192.168.1.237:8080/TestWeb/a.jsp
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 192.168.1.237 (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
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.1.237
Server Port: 8080
Document Path: /TestWeb/a.jsp
Document Length: 151 bytes
Concurrency Level: 10
Time taken for tests: 5.767970 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 3900000 bytes
HTML transferred: 1510000 bytes
Requests per second: 1733.71 [#/sec] (mean)
Time per request: 5.768 [ms] (mean)
Time per request: 0.577 [ms] (mean, across all concurrent requests)
Transfer rate: 660.20 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.3 1 19
Processing: 0 4 8.8 3 174
Waiting: 0 3 8.6 2 173
Total: 1 5 8.9 4 174
Percentage of the requests served within a certain time (ms)
50% 4
66% 4
75% 5
80% 5
90% 8
95% 10
98% 16
99% 26
100% 174 (longest request)
ab -k -n 10000 -c 10 http://192.168.1.237:8080/TestWeb/a.jsp
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 192.168.1.237 (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
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.1.237
Server Port: 8080
Document Path: /TestWeb/a.jsp
Document Length: 151 bytes
Concurrency Level: 10
Time taken for tests: 2.93494 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 9904
Total transferred: 3949520 bytes
HTML transferred: 1510000 bytes
Requests per second: 4776.70 [#/sec] (mean)
Time per request: 2.093 [ms] (mean)
Time per request: 0.209 [ms] (mean, across all concurrent requests)
Transfer rate: 1841.90 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 4
Processing: 0 1 7.4 1 232
Waiting: 0 1 7.4 1 232
Total: 0 1 7.4 1 232
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 2
80% 2
90% 3
95% 4
98% 8
99% 12
100% 232 (longest request)
[root@centos ~]# ab -k -n 10000 -c 10 http://192.168.1.237:8080/TestWeb/a.jsp
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 192.168.1.237 (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
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.1.237
Server Port: 8080
Document Path: /TestWeb/a.jsp
Document Length: 151 bytes
Concurrency Level: 10
Time taken for tests: 2.179860 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 9904
Total transferred: 3950705 bytes
HTML transferred: 1510453 bytes
Requests per second: 4587.45 [#/sec] (mean)
Time per request: 2.180 [ms] (mean)
Time per request: 0.218 [ms] (mean, across all concurrent requests)
Transfer rate: 1769.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 8
Processing: 0 1 10.5 1 329
Waiting: 0 1 10.5 1 329
Total: 0 1 10.5 1 329
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 2
80% 2
90% 3
95% 4
98% 7
99% 13
100% 329 (longest request)
分享到:
相关推荐
从测试结果看,Netty性能是非常高的,在所有使用默认配置的情况下,单台服务器能够达到4万次请求解析,作为RPC框架是足够用的。
总结了netty和tomcat的差异,入门级的比较,希望对读者有点帮助
websocket+tomcat+jetty+netty
基于netty手写实现简易版tomcat,netty实现http服务器容器的demo
jar包直接运行,对外提供web服务,netty负责http协议,配合springMVC,再也不用tomcat了,因为没办法支持jsp,适合纯web服务的项目。
...
。。。
Netty管道测试代码
Tomcat利用webSocket建立常连接 jar包
自己写的一个基于Netty的tcp调试工具, 运行于Window平台
整合dubbo Zookeeper netty http https等框架打造高性能的web访问demo
同过netty实现HTTP服务器(或者客户端) 。务器提供诸如HTML文件和其他内容之类的资源,或代表客户端执行其他功能,向客户端返回响应消息。 响应包含有关请求的完成状态信息,并且还可以在其消息正文中包含所请求的...
Netty是一个高性能、异步事件驱动的NIO框架,它提供了对TCP、UDP和文件传输的支持,作为一个异步NIO框架,Netty的所有IO操作都是异步非阻塞的,通过Future-Listener机制,用户可以方便的主动获取或者通过通知机制...
Netty 入门与实战:仿写微信 IM 即时通讯系统,掘金小册子,netty教程。章节齐全无缺失,排版非常不错。 1.仿微信IM系统简介 1 2.Netty是什么? 2 3.服务端启动流程 8 4.客户端启动流程 11 5.实战:客户端与服务端双向...
java netty接收串口数据 开启windows串口工具 发送串口数据调试助手
跟闪电侠学Netty:Netty即时聊天实战与底层原理-book-netty
netty+thrift高并发高性能
Netty NIO high performance高性能;Modbus Function sync/aync 同步/异步非阻塞;Modbus IoT Data Connector Supports工业物联网平台IoT支持。
netty tomcat战争部署 tomcat净值测试。 用于测试异步记录器,k8s