How fast is Socket & OutputStream

J

jlukar

Hi,

I have a load tester that connects to the server and sends through
1000's of messages and using the returned message from the server
calculates the round-trip numbers (milliseconds).

One implementation of the server has bottleneck. Another
implementation does not have as big of a bottleneck.

However the slower server simply is slower to accept the messages while
it is doing other things and hence the round trip numbers do not show
this fact.

It is like trying to stuff some rice grains down a narrow pipe.

Can anyone tell me what is the low level behaviour of writing to the
socket OutputStream ? if my loader is sending more messages than the
server can accept, will the message linger around the network layer
(possibly on the file handler behind the socket) untill the serve can
accept it ?

If this is not the case and my loader blocks untill server accepts,
then that can be misleading using the round trip approach.
 
T

Thomas Hawtin

Can anyone tell me what is the low level behaviour of writing to the
socket OutputStream ? if my loader is sending more messages than the
server can accept, will the message linger around the network layer
(possibly on the file handler behind the socket) untill the serve can
accept it ?

The sending side will buffer a certain amount of data. You can tell how
much with Socket.getSendBufferSize, and set a hint with
setSendBufferSize. On the other side, you have a similar thing with
(get|set)ReceiveBufferSize.

http://java.sun.com/javase/6/docs/api/java/net/Socket.html#getSendBufferSize()

Also of note, is that IP is not a reliable protocol. So TCP needs to
keep hold of the data on the sending side until it is acknowledged. The
receiving side will set a maximum window which determines how much can
be sent without acknowledgment. With a small window and long latency, it
may be the case that the window fills up before a lightly loaded server
can get an acknowledgment back. If the receiver's buffer fills, it will
not accept any more data, causing the sender's buffer to fill and the
sending thread to block.

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top