-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Upload performance is less impressive than download #1117
Comments
There are a lot of factors that could cause this. Does your server do any significant work in If that doesn't fix the issue, you should create a minimal example that demonstrates the issue and post it here so we can investigate it. There shouldn't be any throttling done in this library. |
Here is the example. I made minimal changes to ChatServer and ChatClient. If the server and client are in different countries, you will see the upload speed is less than 1Mbps. The sending call runs very quickly, but the messages are kept in memory on Client side and processed slowly. I used WireShark to compare this example with some online speed test. It seems ChatClient gets ACK packets from ChatServer much more frequently than online speed test. |
If my measurements are correct, the example sends 60 Mbps of websocket data, which is... a lot. Keep in mind that each message on console represents 120000 bytes sent. The only way to see if the bottleneck is in this library is to check the TCP upload speed between both machines using something like For me, the TCP upload speed between my laptop and server is 14 Mbps while the websocket server can keep up with 6 Mbps. |
Yes, console prints out one line per 100 send() calls, which send 120000 bytes. In my testing, the client console printed out the lines very quickly, which gave me the impression that the upload was very fast. But in fact, most messages were kept in memory by the client and the memory usage kept going up. The server received about 100 messages per second and the server console printed out the lines at a much slower speed - about one line per second. You can check out the screenshot of my testing. Timestamp is printed out in console now after I made minor code change: example |
The |
So the blocking queue is not consumed in a timely manner, is it? How can I improve the throughput? |
Have you checked the actual TCP throughput? Are you sure you aren't simply limited by internet speed between the two machines? |
If I remove line 817 (ostream.write(buffer.array(), 0, buffer.limit());) in WebSocketClient.java, the blocking queue is consumed fast enough. So it seems the bottleneck is in the Socket. The upload speed of my internet connection is 500Mbps, and the download speed of the other machine is also hundreds of Mbps. I run speed test in web browser and the upload speed is 300Mbps. Wireshark shows just one tcp connection to the server during upload testing. |
I deployed a netty server, then used the same ChatClient, the upload speed was 30Mbps. Everything is the same except the websocket server. |
Okay, that sounds pretty bad. I'll try to profile the library and see what I can find. |
@PhilipRoman did you find anything? I also encounter this issue. |
It turns out for the client -> server message, the data needs to be masked (XOR), so the upload performance is not as good as download performance. |
Has the problem been solved now |
Any news about this? |
I have reproduced the issue. Still investigating the root cause. |
@PhilipRoman you are looking for something like
|
@PhilipRoman could you check if https://github.com/marci4/Java-WebSocket-Dev/tree/Issue1117 helps? |
Hello, has there been any update on this problem? |
I deployed one chat server and opened one chat client in different countries. I used this single client to profile download and upload performance. The download speed could reach about 15Mbps, which is OK. But the upload speed never reached 1Mbps. The server continued processing messages for some time after client finished sending all the messages. No message was lost on the server side. It seems there is some throttling for upload.
If there is throttling, where can I find out the code for throttling? If there is not, how can I improve the upload speed?
Thank you.
The text was updated successfully, but these errors were encountered: