Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic