You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2016/12/27 11:59:34 UTC
[Bug 60523] New: Reduce number of network packets that server sends
to client via WebSocket connection
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
Bug ID: 60523
Summary: Reduce number of network packets that server sends to
client via WebSocket connection
Product: Tomcat 9
Version: 9.0.0.M15
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: WebSocket
Assignee: dev@tomcat.apache.org
Reporter: iv_kovalyov@mail.ru
Target Milestone: -----
Created attachment 34559
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34559&action=edit
Patch for WsRemoteEndpointImplBase.java
I am using Tomcat 9 and Spring.
My web application has a websocket service.
My application sends binary messages to client using sendMessage of:
org.springframework.web.socket.WebSocketSession.
I collected tcp packets by wireshark. I see that every binary websocket message
uses at least 2 TCP packets.
The first packet is the header, it is small.
There is patch for WsRemoteEndpointImplBase.java from version 9.0.0.M15 in
attachement, it
creates one packet from header and tail if it's size not more than 65536 bytes.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
--- Comment #7 from Mark Thomas <ma...@apache.org> ---
(In reply to Ilgar Kovalyov from comment #6)
> Hello, Mark.
> I just installed Autobahn WebSocket testsuite.
> Can you tell me more about your tests?
> I want to reproduce test results.
> What web application did you deployed at tomcat for test purposes?
The programmatic WebSocket echo example in the Tomcat examples
> What test did you run?
All of the Autobhan WebSocket server tests.
There are some very old results that give you an idea of the tests being run
here:
http://home.apache.org/~markt/dev/autobahn/
I ran a more recent version of those tests (but not the latest).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
--- Comment #8 from Joseph Dean <jo...@gmail.com> ---
I'm experiencing the same behavior. The client library I use to send data to my
server over websockets properly bundles the payload length and payload in a
single tcp datagram. Data coming from my tomcat server is always sending two
datagrams for a single message: one with 2 bytes of payload which is the
websocket header + payload length, and the 2nd which is the payload.
From what I can see the doWrite(SendHandler, long, ByteBuffer...) sends each
provided buffer in a separate frame. We can see inside this method it invokes:
for (ByteBuffer buffer : buffers) {
socketWrapper.write(true, buffer);
// Snip
socketWrapper.setWriteTimeout(timeout);
socketWrapper.flush(true);
}
The original patch allocates a new buffer to place both the header and payload
in a single buffer before handing it to this method, which resolves the network
behavior but results in extra memory copies. Perhaps the more correct solution
is to modify WsRemoteEndpointImplServer::doWrite to only do a single socket
flush after writing all provided buffers?
The protocol I'm working on sends numerous very small packets; about 90% of my
traffic is TCP header overhead. Doubling the number of packets thus nearly
doubles my overall bandwidth usage. This is extremely important to my
application.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #9 from Mark Thomas <ma...@apache.org> ---
Re-open to review the most recent comment.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
--- Comment #2 from Ilgar Kovalyov <iv...@mail.ru> ---
(In reply to Mark Thomas from comment #1)
> What does this patch do to performance? It adds a couple of copies.
Yes, it adds a couple of copies in memory but reduces number of network
packets.
Network packet transmission takes more time than operations with memory and we
have perfomance benefit sending less network packets.
If you wish this perfomance benefit can be checked by test.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
--- Comment #3 from Ilgar Kovalyov <iv...@mail.ru> ---
Yes, it adds a couple of copies in memory but reduces number of network
packets.
Network packet transmission takes more time than operations with memory and we
have perfomance benefit sending less network packets.
If you wish this perfomance benefit can be checked by test.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
--- Comment #6 from Ilgar Kovalyov <iv...@mail.ru> ---
Hello, Mark.
I just installed Autobahn WebSocket testsuite.
Can you tell me more about your tests?
I want to reproduce test results.
What web application did you deployed at tomcat for test purposes?
What test did you run?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
Ilgar Kovalyov <iv...@mail.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
--- Comment #4 from Ilgar Kovalyov <iv...@mail.ru> ---
Answered in previous comment
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #5 from Mark Thomas <ma...@apache.org> ---
The proposed patch will not be applied because it results in significant
performance degradation rather than an improvement.
Testing with the Autobahn WebSocket testsuite showed performance decreased more
than 2 orders of magnitude when the proposed patch was applied.
Whether the additional copies, the additional allocations or other factors are
responsible for the performance degradation might be an interesting topic to
research.
Performance bottlenecks are notoriously difficult to identify via code
inspection in all but the most trivial of cases.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #1 from Mark Thomas <ma...@apache.org> ---
What does this patch do to performance? It adds a couple of copies.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 60523] Reduce number of network packets that server sends to
client via WebSocket connection
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60523
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |FIXED
--- Comment #10 from Mark Thomas <ma...@apache.org> ---
Fixed in:
- trunk for 9.0.0.M27 onwards
- 8.5.x for 8.5.21 onwards
Fixing this for 8.0.x and earlier would require significant refactoring -
effectively the refactoring that took place for 8.5.x.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org