[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Several simultaneous URLConnections to a single server

Posted on 2004-09-21
11
Medium Priority
?
459 Views
Last Modified: 2012-05-05
I have a java application using Sun's JDK 1.4 which opens
several URLConnections to our server.  Some of these take
the server a long time to generate a response, and sometimes
the client has several that occur at the same time.

It appears that java does not allow them to all happen in parallel.
Perhaps java may be trying to reuse the same socket connection
for processing each http request in serial.  With some of my slow
responses, however, this default limitation on parallel URLConnections
is really making things unacceptably slow.

Is there any way I can change the configuration so that there is
1. No small limit to the number of simultaneous connections
2. Even if some of the responses are slow, the other responses don't
    have to wait.

Thanks a lot
0
Comment
Question by:bjornsone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12115196
You're presumably handling them in separate threads? If not, that's what you should do
0
 

Expert Comment

by:ggalvao
ID: 12115359
Make your URLConnection class implement Thread interface then use methods .start() to dispatch the connection code.
0
 

Author Comment

by:bjornsone
ID: 12115978
Yes, I am using separate threads, but java somewhere at a lower
level has restrictions on how it handles multiple URLConnections to
the same server.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 12116019
>>
but java somewhere at a lower
level has restrictions on how it handles multiple URLConnections to
the same server.
>>

What's your OS and how many open connections have you got?

0
 

Author Comment

by:bjornsone
ID: 12116526
It runs on windows 2000 and windows xp
I can't set an absolute maximum that our application
may be using at once, but it should typically not
exceed 5.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12116566
>>I can't set an absolute maximum that our application may be using at once

You certainly can set a maximum number of threads and should. 5 would be absolutely fine. You should probably set a timeout and an exception will be thrown, allowing the thread to exit
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1200 total points
ID: 12116582
0
 
LVL 7

Assisted Solution

by:JugglerW
JugglerW earned 800 total points
ID: 12116836
If you use a standard internet browser to access your server (assuming it's a http server) is this also slow?

My quick thoughts:

- You can set the Java property http.maxConnections to a larger value, but default should be already 5 as default

- You can set the Java property http.keepAlive to true (but default should be already true).

- Sometimes the http server restricts the number of parallel connections from one client / IP.

- be sure HTTP/1.1 with keep alive is used by your server. To test open a normal socket to your server and send a request like:

HEAD / HTTP/1.1\r\n
HOST: <your host>\r\n
\r\n
\r\n

Now read and print out the input stream until you get an empty line. The header fields recieved may give you some insight on your server.
You may also use this approach to test how many parallel connections your server can handle if you start it n times in parallel threads.

For an exact description of HTTP protocol see: http://www.w3.org/Protocols/rfc2616/rfc2616.html


0
 
LVL 7

Expert Comment

by:JugglerW
ID: 12116860
Clarification:

In

HOST: <your host>\r\n

<your host> means the name of your server like www.microsoft.com
0
 

Author Comment

by:bjornsone
ID: 12136278
Thanks alot
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12136389
8-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question