-
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
Add ability to disable default receive buffer size in websocket server #1406
Add ability to disable default receive buffer size in websocket server #1406
Conversation
Signed-off-by: pwangryn <[email protected]>
Thanks for the PR! I think I would like a more general solution, so I've opened #1407 |
@PhilipRoman We try also this before, but only when |
@Vangreen that is really strange, could you please verify with your setup that even doing socket.setReceiveBufferSize(socket.getReceiveBufferSize()); here: https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/java/org/java_websocket/server/WebSocketServer.java#L581 causes the slowdown? (and maybe post the value of On a side note, the websocket default buffer size of 16K seems too low and causes slowdowns in my testing compared to the system default 64K. |
@PhilipRoman setting up the 'real' socket buffer this way somehow blocks the system a memory management. Since there is only one value |
Fixed with #1407 |
@dushabella the behaviour you expect is now turned on by default (no explicit set buffer size). I didn't separate the socket and application buffer sizes since there is no point in having read buffer bigger than socket buffer, but also the socket buffer can easily be saturated on a fast connection, so also not a good idea to have it smaller than socket buffer (just extra syscall overhead). |
@PhilipRoman, you're right there may be benefits of setting the same buffer size, but since the SO_RCVBUF and WebSocket layer buffers are logically separate it could be possible to adjust them independently to fine-tune the behavior of the connection. Depending on the network environment, we may want to adjust the buffer sizes for optimal performance/syscalls/memory use. Consider the connection with relatively small network traffic but a large RTT. Large SO_RCVBUF would be crucial to ensure a proper window size, but it would fill up slowely. Large application buffer wouldn't reduce the number of syscalls since read() shouldn't read out of empty socket anyway, but this large buffer would take up memory and did not use it, and wasted it as a consequence. |
Description
In our project we encountered performance drops in websocket connection over vpn. During debugging we find out that when
socket.setReceiveBufferSize(WebSocketImpl.RCVBUF);
is not set the performance increases (RRT is smaller and more packets per second are ingested)Motivation and Context
Improve performance
How Has This Been Tested?
Types of changes
Checklist: