Grizzly和Netty以及Mina简单性能对比

来源:互联网 发布:电子音乐软件下载 编辑:程序博客网 时间:2024/04/30 04:08
最近在服务框架中尝试增加了Grizzly传输集成,简单测试后发现,TPS(每秒处理请求数)略低于Netty,略高于Mina,相差并不是很大,但TPS比Netty稳定很多(每秒方差小),不会出现大幅波动,可以考虑备选。 

Mina为ApacheDirectory服务器的底层NIO框架:http://mina.apache.org 
Netty为JBoss的NIO框架:http://www.jboss.org/netty 
Grizzly是Sun的GlassFish服务器的底层NIO框架:http://grizzly.java.net 

注:以下数据为开发环境简单测试,存在较大统计误差,并且Mina采用的是旧版本(因新版本API不兼容),可能存在测试的不公平性。 

测试版本: 
Grizzly2.1.1,Netty3.2.2,Mina1.1.7 

测试结论: 
服务器Linux下TPS,Netty最高,但波动非常大,Grizzly次之,但波动小,Mina最低。 
本机Windows下TPS,Grizzly最高,Mina次之,Netty最低。 

测试结果: 
单一长连接,100并发,来回数据均为1K: 
服务器Linux下TPS,Grizzly:15061,Netty:15211,Mina: 14828。 
本机Windows下TPS,Grizzly:6945,Netty:4433,Mina:5750。 

测试详细: 

1. Linux: 

(1) Grizzly: 
Java代码  收藏代码
  1. [01:48:17] count: 72059, error: 0,tps:16046  
  2. [01:48:19] count: 103081, error: 0,tps:15412  
  3. [01:48:21] count: 133459, error: 0,tps:15169  
  4. [01:48:23] count: 164335, error: 0,tps:15436  
  5. [01:48:25] count: 195370, error: 0,tps:15516  
  6. [01:48:27] count: 226222, error: 0,tps:15425  
  7. [01:48:29] count: 256864, error: 0,tps:15320  
  8. [01:48:31] count: 287435, error: 0,tps:15284  
  9. [01:48:33] count: 317908, error: 0,tps:15235  
  10. [01:48:35] count: 348632, error: 0,tps:15361  
  11. [01:48:37] count: 379702, error: 0,tps:15534  
  12. [01:48:39] count: 410473, error: 0,tps:15384  
  13. [01:48:41] count: 441696, error: 0,tps:15610  
  14. [01:48:43] count: 472648, error: 0,tps:15474  
  15. [01:48:45] count: 503532, error: 0,tps:15440  
  16. [01:48:47] count: 534368, error: 0,tps:15417  
  17. [01:48:49] count: 565526, error: 0,tps:15578  
  18. [01:48:51] count: 596600, error: 0,tps:15536  
  19. [01:48:53] count: 627111, error: 0,tps:15254  
  20. [01:48:55] count: 657956, error: 0,tps:15422  
  21. [01:48:57] count: 689197, error: 0,tps:15619  
  22. [01:48:59] count: 719944, error: 0,tps:15372  
  23. [01:49:01] count: 750797, error: 0,tps:15426  
  24. [01:49:03] count: 781439, error: 0,tps:15321  
  25. [01:49:05] count: 812245, error: 0,tps:15401  
  26. [01:49:07] count: 842992, error: 0,tps:15372  
  27. [01:49:09] count: 873677, error: 0,tps:15341  
  28. [01:49:11] count: 904656, error: 0,tps:15488  
  29. [01:49:13] count: 935273, error: 0,tps:15307  
  30. [01:49:15] count: 965723, error: 0,tps:15224  
  31. [01:49:17] count: 996358, error: 0,tps:15316  
  32. +================================================================+  
  33. |             Dubbo Remoting Performance Test Report             |  
  34. +================================================================+  
  35. |                        Test Environment                        |  
  36. +----------------------------------------------------------------+  
  37. +----------------------------------------------------------------+  
  38. | Client OS: Linux 2.6.18-128.el5xen amd64                       |  
  39. | Client CPU: 16 cores                                           |  
  40. | Client JVM: Java HotSpot(TM) 64-Bit Server VM 1.6.0_18-b07     |  
  41. | Client Memory: 535,953,408 bytes (Max: 535,953,408 bytes)      |  
  42. | Client Network: eth0                                           |  
  43. | Client MTU: 1500 bytes                                         |  
  44. +----------------------------------------------------------------+  
  45. |                           Test Scene                           |  
  46. +----------------------------------------------------------------+  
  47. | Client Transporter: grizzly                                    |  
  48. | Serialization: hessian2                                        |  
  49. | Response Timeout: 5000 ms                                      |  
  50. | Data Length: 1024 bytes                                        |  
  51. | Client Shared Connections: 1                                   |  
  52. | Client Concurrent Threads: 100                                 |  
  53. | Run Times Per Thread: 10000                                    |  
  54. +----------------------------------------------------------------+  
  55. |                          Test Result                           |  
  56. +----------------------------------------------------------------+  
  57. | Succeeded Requests: 1,000,000                                  |  
  58. | Failed Requests: 0                                             |  
  59. | Client Elapsed Time: 3404 ms                                   |  
  60. | Average Response Time: 6 ms                                    |  
  61. | Requests Per Second: 15061/s                                   |  
  62. | Throughput Per Second: 30,846,411 bytes/s                      |  
  63. +================================================================+  


(2) Netty: 
Java代码  收藏代码
  1. [01:53:56] count: 113330, error: 0,tps:17381  
  2. [01:53:58] count: 136859, error: 0,tps:11764  
  3. [01:54:00] count: 160062, error: 0,tps:11601  
  4. [01:54:02] count: 186185, error: 0,tps:13060  
  5. [01:54:04] count: 209548, error: 0,tps:11681  
  6. [01:54:06] count: 236865, error: 0,tps:13658  
  7. [01:54:08] count: 263920, error: 0,tps:13526  
  8. [01:54:10] count: 288269, error: 0,tps:12174  
  9. [01:54:12] count: 312995, error: 0,tps:12362  
  10. [01:54:14] count: 336914, error: 0,tps:11958  
  11. [01:54:16] count: 362085, error: 0,tps:12584  
  12. [01:54:18] count: 385552, error: 0,tps:11732  
  13. [01:54:20] count: 409792, error: 0,tps:12119  
  14. [01:54:22] count: 442461, error: 0,tps:16334  
  15. [01:54:24] count: 469138, error: 0,tps:13338  
  16. [01:54:26] count: 493428, error: 0,tps:12144  
  17. [01:54:28] count: 521258, error: 0,tps:13915  
  18. [01:54:30] count: 560968, error: 0,tps:19854  
  19. [01:54:32] count: 609262, error: 0,tps:24146  
  20. [01:54:34] count: 657769, error: 0,tps:24250  
  21. [01:54:36] count: 704225, error: 0,tps:23226  
  22. [01:54:38] count: 736721, error: 0,tps:16248  
  23. [01:54:40] count: 771944, error: 0,tps:17611  
  24. [01:54:42] count: 808276, error: 0,tps:18164  
  25. [01:54:44] count: 840891, error: 0,tps:16307  
  26. [01:54:46] count: 873613, error: 0,tps:16360  
  27. [01:54:48] count: 911968, error: 0,tps:19174  
  28. [01:54:50] count: 960476, error: 0,tps:24248  
  29. +================================================================+  
  30. |             Dubbo Remoting Performance Test Report             |  
  31. +================================================================+  
  32. |                        Test Environment                        |  
  33. +----------------------------------------------------------------+  
  34. +----------------------------------------------------------------+  
  35. | Client OS: Linux 2.6.18-128.el5xen amd64                       |  
  36. | Client CPU: 16 cores                                           |  
  37. | Client JVM: Java HotSpot(TM) 64-Bit Server VM 1.6.0_18-b07     |  
  38. | Client Memory: 536,215,552 bytes (Max: 536,215,552 bytes)      |  
  39. | Client Network: eth0                                           |  
  40. | Client MTU: 1500 bytes                                         |  
  41. +----------------------------------------------------------------+  
  42. |                           Test Scene                           |  
  43. +----------------------------------------------------------------+  
  44. | Client Transporter: netty                                      |  
  45. | Serialization: hessian2                                        |  
  46. | Response Timeout: 5000 ms                                      |  
  47. | Data Length: 1024 bytes                                        |  
  48. | Client Shared Connections: 1                                   |  
  49. | Client Concurrent Threads: 100                                 |  
  50. | Run Times Per Thread: 10000                                    |  
  51. +----------------------------------------------------------------+  
  52. |                          Test Result                           |  
  53. +----------------------------------------------------------------+  
  54. | Succeeded Requests: 1,000,000                                  |  
  55. | Failed Requests: 0                                             |  
  56. | Client Elapsed Time: 3151 ms                                   |  
  57. | Average Response Time: 6 ms                                    |  
  58. | Requests Per Second: 15211/s                                   |  
  59. | Throughput Per Second: 31,152,738 bytes/s                      |  
  60. +================================================================+  


(3) Mina: 
Java代码  收藏代码
  1. [01:56:39] count: 103543, error: 0,tps:14427  
  2. [01:56:41] count: 132855, error: 0,tps:14655  
  3. [01:56:43] count: 166918, error: 0,tps:17021  
  4. [01:56:45] count: 195301, error: 0,tps:14190  
  5. [01:56:47] count: 224616, error: 0,tps:14657  
  6. [01:56:49] count: 262498, error: 0,tps:18941  
  7. [01:56:51] count: 294846, error: 0,tps:16174  
  8. [01:56:53] count: 334369, error: 0,tps:19761  
  9. [01:56:55] count: 353994, error: 0,tps:9812  
  10. [01:56:57] count: 379195, error: 0,tps:12596  
  11. [01:56:59] count: 423003, error: 0,tps:21886  
  12. [01:57:01] count: 466447, error: 0,tps:21721  
  13. [01:57:03] count: 496609, error: 0,tps:15081  
  14. [01:57:05] count: 514800, error: 0,tps:9095  
  15. [01:57:07] count: 539324, error: 0,tps:12262  
  16. [01:57:09] count: 571361, error: 0,tps:16018  
  17. [01:57:11] count: 594834, error: 0,tps:11736  
  18. [01:57:13] count: 616056, error: 0,tps:10611  
  19. [01:57:15] count: 643891, error: 0,tps:13917  
  20. [01:57:17] count: 662115, error: 0,tps:9111  
  21. [01:57:19] count: 688659, error: 0,tps:13271  
  22. [01:57:21] count: 724968, error: 0,tps:18154  
  23. [01:57:23] count: 767680, error: 0,tps:21356  
  24. [01:57:25] count: 802471, error: 0,tps:17395  
  25. [01:57:27] count: 842291, error: 0,tps:19910  
  26. [01:57:29] count: 877187, error: 0,tps:17448  
  27. [01:57:31] count: 917275, error: 0,tps:20044  
  28. [01:57:33] count: 945382, error: 0,tps:14053  
  29. [01:57:35] count: 972663, error: 0,tps:13637  
  30. +================================================================+  
  31. |             Dubbo Remoting Performance Test Report             |  
  32. +================================================================+  
  33. |                        Test Environment                        |  
  34. +----------------------------------------------------------------+  
  35. +----------------------------------------------------------------+  
  36. | Client OS: Linux 2.6.18-128.el5xen amd64                       |  
  37. | Client CPU: 16 cores                                           |  
  38. | Client JVM: Java HotSpot(TM) 64-Bit Server VM 1.6.0_18-b07     |  
  39. | Client Memory: 536,150,016 bytes (Max: 536,150,016 bytes)      |  
  40. | Client Network: eth0                                           |  
  41. | Client MTU: 1500 bytes                                         |  
  42. +----------------------------------------------------------------+  
  43. |                           Test Scene                           |  
  44. +----------------------------------------------------------------+  
  45. | Client Transporter: mina                                       |  
  46. | Serialization: hessian2                                        |  
  47. | Response Timeout: 5000 ms                                      |  
  48. | Data Length: 1024 bytes                                        |  
  49. | Client Shared Connections: 1                                   |  
  50. | Client Concurrent Threads: 100                                 |  
  51. | Run Times Per Thread: 10000                                    |  
  52. +----------------------------------------------------------------+  
  53. |                          Test Result                           |  
  54. +----------------------------------------------------------------+  
  55. | Succeeded Requests: 1,000,000                                  |  
  56. | Failed Requests: 0                                             |  
  57. | Client Elapsed Time: 3207 ms                                   |  
  58. | Average Response Time: 6 ms                                    |  
  59. | Requests Per Second: 14828/s                                   |  
  60. | Throughput Per Second: 30,368,031 bytes/s                      |  
  61. +================================================================+  


2. Windows: 

(1) Grizzly: 
Java代码  收藏代码
  1. +================================================================+  
  2. |             Dubbo Remoting Performance Test Report             |  
  3. +================================================================+  
  4. |                        Test Environment                        |  
  5. +----------------------------------------------------------------+  
  6. | Server OS: Windows XP 5.1 x86                                  |  
  7. | Server CPU: 2 cores                                            |  
  8. | Server JVM: Java HotSpot(TM) Client VM 1.6.0_18-b07            |  
  9. | Server Memory: 16,252,928 bytes (Max: 259,522,560 bytes)       |  
  10. | Server Network: Intel(R) WiFi Link 5100 AGN - Teefer2 Miniport |  
  11. | Server MTU: 1500 bytes                                         |  
  12. +----------------------------------------------------------------+  
  13. | Client OS: Windows XP 5.1 x86                                  |  
  14. | Client CPU: 2 cores                                            |  
  15. | Client JVM: Java HotSpot(TM) Client VM 1.6.0_18-b07            |  
  16. | Client Memory: 16,515,072 bytes (Max: 259,522,560 bytes)       |  
  17. | Client Network: Intel(R) WiFi Link 5100 AGN - Teefer2 Miniport |  
  18. | Client MTU: 1500 bytes                                         |  
  19. +----------------------------------------------------------------+  
  20. |                           Test Scene                           |  
  21. +----------------------------------------------------------------+  
  22. | Server Transporter: grizzly                                    |  
  23. | Server Service Threads: 100                                    |  
  24. | Client Transporter: grizzly                                    |  
  25. | Serialization: hessian2                                        |  
  26. | Response Timeout: 5000 ms                                      |  
  27. | Data Length: 1024 bytes                                        |  
  28. | Client Shared Connections: 1                                   |  
  29. | Client Concurrent Threads: 100                                 |  
  30. | Run Times Per Thread: 10000                                    |  
  31. +----------------------------------------------------------------+  
  32. |                          Test Result                           |  
  33. +----------------------------------------------------------------+  
  34. | Succeeded Requests: 1,000,000                                  |  
  35. | Failed Requests: 0                                             |  
  36. | Client Elapsed Time: 14393 ms                                  |  
  37. | Average Response Time: 14 ms                                   |  
  38. | Requests Per Second: 6945/s                                    |  
  39. | Throughput Per Second: 14,224,879 bytes/s                      |  
  40. +================================================================+  


(2) Netty: 
Java代码  收藏代码
  1. +================================================================+  
  2. |             Dubbo Remoting Performance Test Report             |  
  3. +================================================================+  
  4. |                        Test Environment                        |  
  5. +----------------------------------------------------------------+  
  6. | Server OS: Windows XP 5.1 x86                                  |  
  7. | Server CPU: 2 cores                                            |  
  8. | Server JVM: Java HotSpot(TM) Client VM 1.6.0_18-b07            |  
  9. | Server Memory: 16,252,928 bytes (Max: 259,522,560 bytes)       |  
  10. | Server Network: Intel(R) WiFi Link 5100 AGN - Teefer2 Miniport |  
  11. | Server MTU: 1500 bytes                                         |  
  12. +----------------------------------------------------------------+  
  13. | Client OS: Windows XP 5.1 x86                                  |  
  14. | Client CPU: 2 cores                                            |  
  15. | Client JVM: Java HotSpot(TM) Client VM 1.6.0_18-b07            |  
  16. | Client Memory: 16,646,144 bytes (Max: 259,522,560 bytes)       |  
  17. | Client Network: Intel(R) WiFi Link 5100 AGN - Teefer2 Miniport |  
  18. | Client MTU: 1500 bytes                                         |  
  19. +----------------------------------------------------------------+  
  20. |                           Test Scene                           |  
  21. +----------------------------------------------------------------+  
  22. | Server Transporter: netty                                      |  
  23. | Server Service Threads: 100                                    |  
  24. | Client Transporter: netty                                      |  
  25. | Serialization: hessian2                                        |  
  26. | Response Timeout: 5000 ms                                      |  
  27. | Data Length: 1024 bytes                                        |  
  28. | Client Shared Connections: 1                                   |  
  29. | Client Concurrent Threads: 100                                 |  
  30. | Run Times Per Thread: 10000                                    |  
  31. +----------------------------------------------------------------+  
  32. |                          Test Result                           |  
  33. +----------------------------------------------------------------+  
  34. | Succeeded Requests: 999,988                                    |  
  35. | Failed Requests: 12                                            |  
  36. | Client Elapsed Time: 34434 ms                                  |  
  37. | Average Response Time: 22 ms                                   |  
  38. | Requests Per Second: 4422/s                                    |  
  39. | Throughput Per Second: 9,057,411 bytes/s                       |  
  40. +================================================================+  


(3) Mina: 
Java代码  收藏代码
  1. +================================================================+  
  2. |             Dubbo Remoting Performance Test Report             |  
  3. +================================================================+  
  4. |                        Test Environment                        |  
  5. +----------------------------------------------------------------+  
  6. | Server OS: Windows XP 5.1 x86                                  |  
  7. | Server CPU: 2 cores                                            |  
  8. | Server JVM: Java HotSpot(TM) Client VM 1.6.0_18-b07            |  
  9. | Server Memory: 16,252,928 bytes (Max: 259,522,560 bytes)       |  
  10. | Server Network: Intel(R) WiFi Link 5100 AGN - Teefer2 Miniport |  
  11. | Server MTU: 1500 bytes                                         |  
  12. +----------------------------------------------------------------+  
  13. | Client OS: Windows XP 5.1 x86                                  |  
  14. | Client CPU: 2 cores                                            |  
  15. | Client JVM: Java HotSpot(TM) Client VM 1.6.0_18-b07            |  
  16. | Client Memory: 16,646,144 bytes (Max: 259,522,560 bytes)       |  
  17. | Client Network: Intel(R) WiFi Link 5100 AGN - Teefer2 Miniport |  
  18. | Client MTU: 1500 bytes                                         |  
  19. +----------------------------------------------------------------+  
  20. |                           Test Scene                           |  
  21. +----------------------------------------------------------------+  
  22. | Server Transporter: mina                                       |  
  23. | Server Service Threads: 100                                    |  
  24. | Client Transporter: mina                                       |  
  25. | Serialization: hessian2                                        |  
  26. | Response Timeout: 5000 ms                                      |  
  27. | Data Length: 1024 bytes                                        |  
  28. | Client Shared Connections: 1                                   |  
  29. | Client Concurrent Threads: 100                                 |  
  30. | Run Times Per Thread: 10000                                    |  
  31. +----------------------------------------------------------------+  
  32. |                          Test Result                           |  
  33. +----------------------------------------------------------------+  
  34. | Succeeded Requests: 1,000,000                                  |  
  35. | Failed Requests: 0                                             |  
  36. | Client Elapsed Time: 6473 ms                                   |  
  37. | Average Response Time: 17 ms                                   |  
  38. | Requests Per Second: 5750/s                                    |  
  39. | Throughput Per Second: 11,777,750 bytes/s                      |  
  40. +================================================================+  
0 0