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 2017/07/19 22:32:13 UTC

[Bug 60523] Reduce number of network packets that server sends to client via WebSocket connection

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