This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTPConnection pooling  RSS feed

 
Saha Kumar
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Is it a good practice to pool HTTPConnections? I want to speed up access to a server which is accessed via HTTPConnection.

Thank you.

-Saha
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is really no point on pooling HTTP connections. HTTP is a connection-less protocol: you connect, send a request, receive a response, and it disconnects. With HTTP 1.1. you can use keep-alive, which lets a connection live even after the response has been received, but only for a short time. And it would need to be for the same server to begin with, so: if you have a need to connect to the same server multiple times, and not for the same session/clickstream, then you should reconsider your architecture/design.
 
Saha Kumar
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ulf. I connect to the same server. I only require stateless functionality (not necessary to keep same session). What are the other options? The protocol is https.

-Saha
 
R Ramesh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In continuation to the post,
Let's say if a client made a request to server, by that time if the server is responding to another request then would this request be queued by the server and respond after it completes it current service? Since the client is waiting for the response from server would there any exception thrown at the client end? If yes, what is the time limit the client could expect an exception?
 
Joe Ess
Bartender
Posts: 9428
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by R Ramesh:
In continuation to the post,
Let's say if a client made a request to server, by that time if the server is responding to another request then would this request be queued by the server and respond after it completes it current service?

Yes, though a well-written server will service multiple clients simultaneously.


Since the client is waiting for the response from server would there any exception thrown at the client end?

While the client is waiting? No.
If the connection times out, yes.


If yes, what is the time limit the client could expect an exception?

java.net.URLConnection and java.net.Socket have methods to get/set a timeout.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!