`
zhaohaolin
  • 浏览: 1010958 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Netty NIO 框架性能压测-短链接-对比Tomcat【转】

 
阅读更多
压测方案
  1. 准备多个文件大小分别为 1k 10k 100k 300k
  2. 使用ab分别按 [50,2000](按50逐渐叠加)压测服务,每次请求10W次
  3. 硬件信息:CPU:Intel(R) Xeon(R) CPU 1.86GHz ×4 4G
  4. 统计脚本:grep "Requests per second:" 300k_* | awk -F':' '{print substr($1,6),$3}'|sort -n
  5. 1k 10k 压测的时候load维持在3左右,100k 300k的load飙升到5 。
压测结果
  1. 在小文件(小于10k)情况下Netty的性能要优于Tomcat,qps大概能提升50%,而且比Tomcat稳定。
  2. 在并发量增大时候Netty表现得比Tomcat稳定,通过修改内核加快TIME_WAIT的回收时间,从而提高系统的并发量。
  3. 在大文件的情况下Netty没有任何优势,而且线程池相关的没有Tomcat优秀,Tomcat的内存回收更优秀些。
  4. 结论:Netty适合搭建轻量级的应用,特别适合传输内容少,但是并发量非常高的应用。或者是大文件下载服务器。

 

修改TIME_WAIT回收时间
vi /etc/sysctl.conf
net.ipv4.tcp_syncookies = 1 
net.ipv4.tcp_tw_reuse = 1 
net.ipv4.tcp_tw_recycle = 1 
net.ipv4.tcp_fin_timeout = 30
 
/sbin/sysctl -p

net.ipv4.tcp_syncookies = 1 表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭; net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭; net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。 net.ipv4.tcp_fin_timeout 修改系統默认的 TIMEOUT 时间

相关数据(下载)
===== Netty =====
====== 1k ======
50     15661.50 [#/sec] (mean)
100     13429.52 [#/sec] (mean)
150     15385.05 [#/sec] (mean)
200     15598.34 [#/sec] (mean)
250     15135.97 [#/sec] (mean)
300     13494.79 [#/sec] (mean)
350     15102.49 [#/sec] (mean)
400     14614.11 [#/sec] (mean)
450     13463.52 [#/sec] (mean)
500     13447.48 [#/sec] (mean)
550     13126.29 [#/sec] (mean)
600     11108.25 [#/sec] (mean)
650     11073.34 [#/sec] (mean)
700     14518.88 [#/sec] (mean)
750     13409.66 [#/sec] (mean)
800     13060.86 [#/sec] (mean)
850     11938.25 [#/sec] (mean)
900     13133.88 [#/sec] (mean)
950     13670.75 [#/sec] (mean)
1000     13803.70 [#/sec] (mean)
1050     16414.20 [#/sec] (mean)
1100     14770.09 [#/sec] (mean)
1150     11108.65 [#/sec] (mean)
1200     13294.72 [#/sec] (mean)
1250     13448.52 [#/sec] (mean)
1300     15128.31 [#/sec] (mean)
1350     13367.31 [#/sec] (mean)
1400     14277.91 [#/sec] (mean)
1450     13193.80 [#/sec] (mean)
1500     14272.63 [#/sec] (mean)
1550     11004.96 [#/sec] (mean)
1600     13438.72 [#/sec] (mean)
1650     13105.43 [#/sec] (mean)
1700     13653.39 [#/sec] (mean)
1750     13366.72 [#/sec] (mean)
1800     12727.40 [#/sec] (mean)
1850     13075.32 [#/sec] (mean)
1900     11103.91 [#/sec] (mean)
1950     13463.83 [#/sec] (mean)

====== 10k ======
50     7280.51 [#/sec] (mean)
100     9089.69 [#/sec] (mean)
150     9423.90 [#/sec] (mean)
200     8130.07 [#/sec] (mean)
250     8142.88 [#/sec] (mean)
300     8311.20 [#/sec] (mean)
350     8512.20 [#/sec] (mean)
400     7940.84 [#/sec] (mean)
450     7823.32 [#/sec] (mean)
500     8284.60 [#/sec] (mean)
550     8785.93 [#/sec] (mean)
600     7725.20 [#/sec] (mean)
650     7753.23 [#/sec] (mean)
700     8184.61 [#/sec] (mean)
750     8027.75 [#/sec] (mean)
800     7934.49 [#/sec] (mean)
850     7792.94 [#/sec] (mean)
900     7734.34 [#/sec] (mean)
950     7118.27 [#/sec] (mean)
1000     7866.23 [#/sec] (mean)
1050     7724.82 [#/sec] (mean)
1100     7734.17 [#/sec] (mean)
1150     7688.83 [#/sec] (mean)
1200     7359.90 [#/sec] (mean)
1250     7526.02 [#/sec] (mean)
1300     7515.24 [#/sec] (mean)
1350     6639.51 [#/sec] (mean)
1400     7902.36 [#/sec] (mean)
1450     7447.63 [#/sec] (mean)
1500     8216.35 [#/sec] (mean)
1550     8133.42 [#/sec] (mean)
1600     7728.28 [#/sec] (mean)
1650     7724.26 [#/sec] (mean)
1700     7622.26 [#/sec] (mean)
1750     7848.25 [#/sec] (mean)
1800     7715.88 [#/sec] (mean)
1850     7594.04 [#/sec] (mean)
1900     8017.95 [#/sec] (mean)
1950     7992.33 [#/sec] (mean)

====== 100k ======
50     1079.56 [#/sec] (mean)
100     1078.64 [#/sec] (mean)
150     1080.74 [#/sec] (mean)
200     1074.42 [#/sec] (mean)
250     1082.69 [#/sec] (mean)
300     1084.87 [#/sec] (mean)
350     1080.00 [#/sec] (mean)
400     1046.49 [#/sec] (mean)
450     1050.25 [#/sec] (mean)
500     1052.89 [#/sec] (mean)
550     1046.49 [#/sec] (mean)
600     1059.16 [#/sec] (mean)
650     1051.33 [#/sec] (mean)
700     1050.23 [#/sec] (mean)
750     1045.41 [#/sec] (mean)
800     1054.51 [#/sec] (mean)
850     1034.61 [#/sec] (mean)
900     1045.55 [#/sec] (mean)
950     1036.36 [#/sec] (mean)

====== 3000k ======
50     345.95 [#/sec] (mean)
100     355.97 [#/sec] (mean)
150     361.02 [#/sec] (mean)
200     363.39 [#/sec] (mean)
250     358.99 [#/sec] (mean)
300     332.52 [#/sec] (mean)
350     320.66 [#/sec] (mean)
400     315.49 [#/sec] (mean)
450     305.72 [#/sec] (mean)
900     304.57 [#/sec] (mean)

===== Tomcat =====
====== 1k ======
50     8808.85 [#/sec] (mean)
100     9933.93 [#/sec] (mean)
150     11037.66 [#/sec] (mean)
200     10857.99 [#/sec] (mean)
250     10389.63 [#/sec] (mean)
300     11054.51 [#/sec] (mean)
350     10397.66 [#/sec] (mean)
400     10617.54 [#/sec] (mean)
450     9600.62 [#/sec] (mean)
500     10822.00 [#/sec] (mean)
550     10815.92 [#/sec] (mean)
600     11385.86 [#/sec] (mean)
650     11094.66 [#/sec] (mean)
700     10819.33 [#/sec] (mean)
750     10821.28 [#/sec] (mean)
800     9009.25 [#/sec] (mean)
850     10814.18 [#/sec] (mean)
900     9542.68 [#/sec] (mean)
950     11095.51 [#/sec] (mean)
1000     10811.53 [#/sec] (mean)
1050     11084.72 [#/sec] (mean)
1100     11089.07 [#/sec] (mean)
1150     9590.15 [#/sec] (mean)
1200     13826.40 [#/sec] (mean)
1250     8186.03 [#/sec] (mean)
1300     13961.24 [#/sec] (mean)
1350     11077.12 [#/sec] (mean)
1400     16536.29 [#/sec] (mean)
1450     11430.66 [#/sec] (mean)
1500     10817.56 [#/sec] (mean)
1550     16195.09 [#/sec] (mean)
1600     17205.66 [#/sec] (mean)
1650     13300.61 [#/sec] (mean)
1700     11061.43 [#/sec] (mean)
1750     10837.05 [#/sec] (mean)
1800     9786.94 [#/sec] (mean)
1850     10808.81 [#/sec] (mean)
1900     13019.67 [#/sec] (mean)
1950     10090.06 [#/sec] (mean)

====== 10k ======
50     5513.00 [#/sec] (mean)
100     7093.53 [#/sec] (mean)
150     9134.78 [#/sec] (mean)
200     8910.81 [#/sec] (mean)
250     9240.74 [#/sec] (mean)
300     7805.80 [#/sec] (mean)
350     8661.73 [#/sec] (mean)
400     8835.57 [#/sec] (mean)
450     7966.94 [#/sec] (mean)
500     8322.71 [#/sec] (mean)
550     6575.24 [#/sec] (mean)
600     8726.30 [#/sec] (mean)
650     8108.30 [#/sec] (mean)
700     9226.79 [#/sec] (mean)
750     8834.83 [#/sec] (mean)
800     8386.70 [#/sec] (mean)
850     8380.58 [#/sec] (mean)
900     8323.48 [#/sec] (mean)
950     9060.00 [#/sec] (mean)
1000     7213.51 [#/sec] (mean)
1050     9504.06 [#/sec] (mean)
1100     9381.86 [#/sec] (mean)
1150     8839.41 [#/sec] (mean)
1200     9760.02 [#/sec] (mean)
1250     9476.96 [#/sec] (mean)
1300     8366.04 [#/sec] (mean)
1350     9651.87 [#/sec] (mean)
1400     9186.07 [#/sec] (mean)
1450     9600.16 [#/sec] (mean)
1500     8289.33 [#/sec] (mean)
1550     9399.26 [#/sec] (mean)
1600     8205.92 [#/sec] (mean)
1650     8306.61 [#/sec] (mean)
1700     9464.74 [#/sec] (mean)
1750     8682.26 [#/sec] (mean)
1800     9589.63 [#/sec] (mean)
1850     8315.31 [#/sec] (mean)
1900     9174.38 [#/sec] (mean)
1950     8956.78 [#/sec] (mean)

====== 100k ======
50     1033.41 [#/sec] (mean)
100     1054.92 [#/sec] (mean)
150     1061.72 [#/sec] (mean)
200     1075.20 [#/sec] (mean)
300     373.05 [#/sec] (mean)
350     375.34 [#/sec] (mean)
400     376.29 [#/sec] (mean)
450     376.51 [#/sec] (mean)
500     377.04 [#/sec] (mean)
550     377.09 [#/sec] (mean)
650     363.08 [#/sec] (mean)
700     368.69 [#/sec] (mean)

====== 300k ======
50     354.93 [#/sec] (mean)
100     361.82 [#/sec] (mean)
150     366.71 [#/sec] (mean)
200     369.58 [#/sec] (mean)
250     372.58 [#/sec] (mean)
300     374.43 [#/sec] (mean)
350     375.92 [#/sec] (mean)
400     376.23 [#/sec] (mean)
450     376.93 [#/sec] (mean)
500     376.61 [#/sec] (mean)
550     377.67 [#/sec] (mean)
600     372.58 [#/sec] (mean)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics