Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

How fast is Socket & OutputStream

Thread view: 
jlukar@gmail.com - 26 Dec 2006 01:07 GMT
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.
Thomas Hawtin - 26 Dec 2006 01:29 GMT
> 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
jlukar@gmail.com - 27 Dec 2006 05:25 GMT
thanks so much for the informative answer. I appreciate it much.

> jlu...@gmail.com wrote:
>
[quoted text clipped - 19 lines]
>
> Tom Hawtin


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.