• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Open ports in a huge web application.

 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After a long time I am visiting JR , looks great !

Here goes the question !
Say suppose there is a very huge site (terms of traffic that it gets) , like Facebook.com , which draws a lot of users.This question is about scalability. Below I have mentioned some of the technical details , which might be worth going through to understand the question that I am going to state later.

When a web page opens up in our browser , it establishes a persistent TCP/IP connection.It’s persistent because it keeps the connection open and uses the same connection for multiple HTTP request response pairs.It a connection remains open for certain amount of time , then the client/browser closes it by sending a TCP packet with it’s fin bit set. So there exists a communication channel with a port in the user’s workstation and a port in the server hosting the website. Now the port number is specified using 16 bits unsigned type , which means that there can be at most 65536 ports in a computer. I am ignoring the fact that ports below 1024 are reserverd.

So the question is , is it that at any given point of time no more that 65K users are online concurrently ?

I am sure that it’s possible but how ?

My take , but wanted to confirm it or my understanding might not be completely correct , so please point to some good resources.

Say the site that I am talking about is www.fakeit.com , so when my browser requests for the IP of www.fakeit.com then the DNS sends the request to the dns of the domain fakiit.com and it returns the IP of a host which is less loaded. So the DNS of fakeit.com acts as the load balancer and there can be a lot of host and multiples of 65K ports.


Thanks,
Rahul Bhattacharjee
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Server sockets work differently than client sockets - they can (and generally are) multi-threaded and can serve multiple clients simultaneously. So the server app only uses a single socket (generally port 80 for web apps) for multiple clients.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes , there is a single server socket listening to all the requests , but once the server socket accepts a request , it creates another socket (with a different port number) in the server.Now the communication happens between the client socket and the new server socket and the original server socket goes back to listening for more requests.

So , my question still holds good , unless I am missing something silly here.

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got you. It depends on what one means by "concurrent users". Even keep-alive connections are closed after a period of inactivity (my Firefox has it set to 115 seconds).

If you actually have a web app that is accessed by that many users on an ongoing basis (so that the timeout doesn't kick in) you'll most likely have to resort to multiple servers much sooner than you reach that number of users.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf. One last thing for confirmation.

Yes , but how do we add multiple servers. Is that something the DNS would take care of . Suppose my site's host name is www.fakeit.com and I have multiple servers with my application running on those. And there would be one DNS for my domain (dns for fakeit.com) .

So when the browser requests the IP of www.fakeit.com , the dns query reaches my dns (the dns to handle name-ip resolution for only fakeit.com) and it returns the ip of the host which it thinks has less traffic (which has open ports). Is it how this works ?

Thanks,
Rahul Bhattacharjee
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It could work that way, but probably doesn't. Load balancing isn't really something you want to handle on the DNS level (at least not completely). See Round robin DNS for some discussion of that.

If we're talking web apps, then you could have Apache handle it, or Apache and Tomcat together.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Ulf

Regards,
Rahul Bhattacharjee
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic