More than 2 tcp connections to a server

I am developing a multi-threaded client that connects to a server and downloads the file specified by a URL. After 2 connections are made, each in a different thread, there is no improvement in download speed. I think this is because a limit of 2 connections is being imposed, I think at the OS level.

Can anyone provide a solution to work around this limitation? In .Net one can specify a ConnectionGroupName for a WebRequest, which "tricks" the system into seeing connections from different clients, even though they originate from the same client. Is there an equivalent to this property in Java?

Thanks for reading.

[640 byte] By [ecruz3a] at [2007-10-2 4:46:52]
# 1

> I am developing a multi-threaded client that connects

> to a server and downloads the file specified by a

> URL. After 2 connections are made, each in a

> different thread, there is no improvement in download

> speed. I think this is because a limit of 2

> connections is being imposed, I think at the OS

> level.

It is more likely you are saturating the available bandwidth.

tschodta at 2007-7-16 0:51:40 > top of Java-index,Java Essentials,Java Programming...
# 2

I know I'm not saturating the available bandwidth. I can monitor the network usage in the Windows Task Manager. My Java code tops out at 50%, but using the .NET code mentioned in the original post, I can max out at 100%. The issue is with the number of concurrent connections the client is making.

ecruz3a at 2007-7-16 0:51:40 > top of Java-index,Java Essentials,Java Programming...
# 3

> I am developing a multi-threaded client that connects

> to a server and downloads the file specified by a

> URL. After 2 connections are made, each in a

> different thread, there is no improvement in download

> speed. I think this is because a limit of 2

> connections is being imposed, I think at the OS

> level.

> I know I'm not saturating the available bandwidth. I

> can monitor the network usage in the Windows Task

> Manager.

You could test your assumption that Windows limits you to 2 connections by running your app on Linux.

tschodta at 2007-7-16 0:51:40 > top of Java-index,Java Essentials,Java Programming...
# 4
Testing the code on different platforms won't make a difference; the connection limit is part of the HTTP 1.1 standard.
ecruz3a at 2007-7-16 0:51:40 > top of Java-index,Java Essentials,Java Programming...
# 5
You might still want to test if your Java code will also max out at 50% when run on Linux...
tschodta at 2007-7-16 0:51:40 > top of Java-index,Java Essentials,Java Programming...
# 6

> I think this is because a limit of 2

> connections is being imposed, I think at the OS

> level.

Well iIf that was true you would expect to be unable to form the third connection, so obviously that has nothing to do with it. Unless you're trying to convince yourself that the OS will let you form N >> 2 connections but only use two at a time, which doesn't make any kind of sense. A single browser will use more than that on a single Web page.

I would try larger buffers when reading, and I would also try upping the socket receive buffers to around 60k. If you are on Windows this will make a large difference as the default is 8k, which might have been a lot in about 1989, pathetically underpowered now.

EJP

ejpa at 2007-7-16 0:51:40 > top of Java-index,Java Essentials,Java Programming...