How fast is Socket & OutputStream

Discussion in 'Java' started by jlukar@gmail.com, Dec 26, 2006.

  1. Guest

    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.
     
    , Dec 26, 2006
    #1
    1. Advertising

  2. wrote:
    >
    > 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
     
    Thomas Hawtin, Dec 26, 2006
    #2
    1. Advertising

  3. Guest

    thanks so much for the informative answer. I appreciate it much.


    On Dec 25, 8:29 pm, Thomas Hawtin <> wrote:
    > wrote:
    >
    > > 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#getSendBuf...()
    >
    > 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
     
    , Dec 27, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. puretec

    Socket: Input/OutputStream

    puretec, Dec 22, 2004, in forum: Java
    Replies:
    0
    Views:
    326
    puretec
    Dec 22, 2004
  2. Thomas

    Socket Input-/Outputstream

    Thomas, Dec 22, 2004, in forum: Java
    Replies:
    3
    Views:
    380
    Steve Horsley
    Dec 23, 2004
  3. Replies:
    6
    Views:
    1,314
  4. Replies:
    2
    Views:
    3,709
  5. Laszlo Nagy
    Replies:
    1
    Views:
    5,084
    Mark Wooding
    Jan 27, 2009
Loading...

Share This Page