It's not a secret anymore!*
The moose likes Sockets and Internet Protocols and the fly likes How many requests can handle a port at 'a' time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "How many requests can handle a port at Watch "How many requests can handle a port at New topic
Author

How many requests can handle a port at 'a' time

pravin gate
Greenhorn

Joined: Feb 20, 2012
Posts: 10
I am creating a web application having a login page , where number of users can tries to login at same time. so here I need to handle number of requests at a time.

I know this is already implemented for number of popular sites like Gtalk.

So I have some questions in my mind.

"How many requests can a port handle at a time ?"

For e.g . As we know when we implement client server communication using Socket programming(TCP), we pass 'a port number(unreserved port number)to server for creating a socket .

So I mean to say if 100000 requests came at a single time then what will be approach of port to these all requests.

Is he maintains some queue for all these requests , or he just accepts number of requests as per his limit? if yes what is handling request limit size of port ?

Summary: I want to know how server serves multiple requests simultaneously?I don't know any thing about it. I know we are connection to a server via its ip address and port number that's it. So I thought there is only one port and many request come to that port only via different clients so how server manages all the requests?

This is all I want to know. If you explain this concept in detail it would be very helpful. Thanks any way.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Hi, Pravin, and welcome to the Ranch!

If you look at the constructors for the ServerSocket class, you'll see that a couple of them take a backlog parameter. This specifies the queue depth for incoming connection requests. If you continue to look at that documentation, you'll see that the default value is 50.
pravin gate
Greenhorn

Joined: Feb 20, 2012
Posts: 10
Thanks, for showing interest .

If the queue depth for incoming connection requests default value is 50, does It means that I can handle my port say '5000' can handle only 50 requests at a time.


Jeff Verdegan wrote:Hi, Pravin, and welcome to the Ranch!

If you look at the constructors for the ServerSocket class, you'll see that a couple of them take a backlog parameter. This specifies the queue depth for incoming connection requests. If you continue to look at that documentation, you'll see that the default value is 50.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

pravin gate wrote:Thanks, for showing interest .

If the queue depth for incoming connection requests default value is 50, does It means that I can handle my port say '5000' can handle only 50 requests at a time.


No. For one thing, the port doesn't handle requests. The port is just an identifier that indicates where the request should go.

For another, what it means the ServerSocket can handle 50 simultaneous requests for a new connection at once. (Or maybe 51--50 backlog + 1 currently being processed.) But don't worry. Unless either a) you're google.com or b) your code that handles the connection request is poorly written, you won't have that many connection requests backing up.

Also, note that this is the number of requests to establish a connection. Logging in, just like chatting, is something that's done after the connection is established. If you have 50 people trying to log in, or 50 people chatting, then they've already got their 50 connections, and that means 50 different sockets.

At this point, handling simultaneous network traffic can be divided into two parts:

1) Data on the wire being delivered to your Java app. This is not a Java question. This is about your hardware, how your OS is configured, and your routers and switches and ISP and a whole slew of stuff that's generally out of your hands and definitely out of scope for any discussion here.

2) Data that your Sockets are receiving that you need to process, presumably in multiple threads. This is the part that you have some control over, and this is where you should focus your attention.

However, when all is said and done, I think you should lay this question aside for the moment. It's good to be curious about it, but if you're just starting out in Java network programming, then "maximum simultaneous requests" is not going to be a practical concern for you, and certainly not at the socket level. So focus on proper design, and on understanding multithreading and the basics of Java network programming, and revisit this question when you want to study networking in general as its own topic.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How many requests can handle a port at 'a' time