Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netty-websocket和websocket性能对比 #59

Open
jaceding opened this issue Jul 10, 2019 · 12 comments
Open

netty-websocket和websocket性能对比 #59

jaceding opened this issue Jul 10, 2019 · 12 comments

Comments

@jaceding
Copy link

使用Jmeter压测,结果显示netty-websocket并没有性能提升呀

@YeautyYE
Copy link
Owner

使用Jmeter压测,结果显示netty-websocket并没有性能提升呀

  1. 压测时客户端性能是否足够强(如果是压创建连接的性能意义并不是很大)
  2. 建议测一下推送性能;最好使用零拷贝进行群推,效果很明显(前提是,连接数够多,数据量够大,还要注意带宽)

@jaceding
Copy link
Author

先说一下我的测试方法吧,我是使用Jmeter,分别以200 250 300 350 400线程(代表一个用户)保持长连接,然后每个用户发送一条消息(查看结果,线程中确实很多推送),查看聚合报告,使用netty-websocket的吞吐量峰值大约是290,而websocket是360,而且websocket错误率也更低。
我的测试方法是不是有问题,或者有没有其他更好的测试方案,感谢您的回答。

@YeautyYE
Copy link
Owner

先说一下我的测试方法吧,我是使用Jmeter,分别以200 250 300 350 400线程(代表一个用户)保持长连接,然后每个用户发送一条消息(查看结果,线程中确实很多推送),查看聚合报告,使用netty-websocket的吞吐量峰值大约是290,而websocket是360,而且websocket错误率也更低。
我的测试方法是不是有问题,或者有没有其他更好的测试方案,感谢您的回答。

请问报错是报的什么错。
除了峰值,有没有接收耗时
另外,建议测从服务端发送到客户端的性能。

@jaceding
Copy link
Author

错误有以下两种:

  1. :WebSocket conection closed unexpectedly by the server: [1002] RSV1 not allowed to be set
  2. :- Unexpected error: null
    java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
    java.util.LinkedList$ListItr.next(Unknown Source)
    JMeter.plugins.functional.samplers.websocket.ServiceSocket.getResponseMessage(ServiceSocket.java:149)
    JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:159)
    org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
    org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
    org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
    org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
    java.lang.Thread.run(Unknown Source)

在目前的测试结果中的平均响应时间也对netty-websocket不利。

  1. 200线程数(即用户数)
    websocket平均响应时间分别为:7 14 6 (单位是ms,下面就不重复了)
    netty-websocket平均响应时间分别为:10 21 15
  2. 300线程数(即用户数)
    websocket平均响应时间分别为:276 130 23
    netty-websocket平均响应时间分别为:55 275 108
  3. 400线程数(即用户数)
    websocket平均响应时间分别为:42 160 180
    netty-websocket平均响应时间分别为:372 577 166

先说一下我的测试方法吧,我是使用Jmeter,分别以200 250 300 350 400线程(代表一个用户)保持长连接,然后每个用户发送一条消息(查看结果,线程中确实很多推送),查看聚合报告,使用netty-websocket的吞吐量峰值大约是290,而websocket是360,而且websocket错误率也更低。
我的测试方法是不是有问题,或者有没有其他更好的测试方案,感谢您的回答。

请问报错是报的什么错。
除了峰值,有没有接收耗时
另外,建议测从服务端发送到客户端的性能。

@YeautyYE
Copy link
Owner

错误有以下两种:

  1. :WebSocket conection closed unexpectedly by the server: [1002] RSV1 not allowed to be set
  2. :- Unexpected error: null
    java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
    java.util.LinkedList$ListItr.next(Unknown Source)
    JMeter.plugins.functional.samplers.websocket.ServiceSocket.getResponseMessage(ServiceSocket.java:149)
    JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:159)
    org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
    org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
    org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
    org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
    java.lang.Thread.run(Unknown Source)

在目前的测试结果中的平均响应时间也对netty-websocket不利。

  1. 200线程数(即用户数)
    websocket平均响应时间分别为:7 14 6 (单位是ms,下面就不重复了)
    netty-websocket平均响应时间分别为:10 21 15
  2. 300线程数(即用户数)
    websocket平均响应时间分别为:276 130 23
    netty-websocket平均响应时间分别为:55 275 108
  3. 400线程数(即用户数)
    websocket平均响应时间分别为:42 160 180
    netty-websocket平均响应时间分别为:372 577 166

先说一下我的测试方法吧,我是使用Jmeter,分别以200 250 300 350 400线程(代表一个用户)保持长连接,然后每个用户发送一条消息(查看结果,线程中确实很多推送),查看聚合报告,使用netty-websocket的吞吐量峰值大约是290,而websocket是360,而且websocket错误率也更低。
我的测试方法是不是有问题,或者有没有其他更好的测试方案,感谢您的回答。

请问报错是报的什么错。
除了峰值,有没有接收耗时
另外,建议测从服务端发送到客户端的性能。

在测试前,建议先让Java程序预热。
在预热过后,我的400条线程的测试结果。2个框架Average均为0,Throughput均为332.8/sec(我用的18年Mac 16G)

2000条线程用本框架跑出了Average 0 , Throughput1000/sec
image

2000条线程使用spring的websocket框架跑出Average 1 , Throughput997.5/sec。并且后台一堆的EOFException
image
image

以上的测试均在预热20次以上之后得到结果。

但是,这并不能代表什么。真正体现性能差距并不是在普通的请求响应,而在于服务端主动群推消息时。

@jaceding
Copy link
Author

感谢你的提醒,在经过多次预热之后,测试结果终于对netty-websocket有利。
但最重要的一点是

真正体现性能差距并不是在普通的请求响应,而在于服务端主动群推消息时

@chenweibo
Copy link

16核 32G内存连 1万个人有问题的吗

@YeautyYE
Copy link
Owner

16核 32G内存连 1万个人有问题的吗

如果是空连接,100万都没问题

@wuxia233
Copy link

大佬,请问用jmeter测试报的EOFException有影响吗

@YeautyYE
Copy link
Owner

大佬,请问用jmeter测试报的EOFException有影响吗

没影响

@fengsam6
Copy link


你好,有具体netty预热好,具体性能数据,还有内存占用比值

@ShemuelDeng
Copy link

大佬, java程序预热是怎么做的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants