SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
No. Each port can receive a number of simultaneous TCP connections up to the number configured in the server. The default in my Apache configuration is 150. Connections are typically made to port 80 or, for a single J2EE Web container, port 8080. Note that a browser always defaults to port 80 for HTTP requests, if no other port is specified after the host in the URL.If total number of software ports are limited to say 65536, this means no more than 65536 threads can be created, which means no more than 65536 client requests can be served from this server?
I don't agree that the server sends the request to some other random port - that would cause chaos. When a request is made to port 80, the request stays at port 80, and the server can connect up to its pre-configured maximum number of clients (mine is 150). If you decrease this figure, less clients can connect. If you increase it, you risk the server running out of resources. Any clients that cannot connect due to a busy server will receive an HTTP 500(.13) status code and will be rejected (they'll have to try again later).In case you don't realize how things happen: when a user asks for a file from port 80 (typical HTTP port), the request goes to 80. The server, which is listening on 80 notices that someone's asking for something, so it chooses another random port, e.g. 1083, and creates a separate thread to actually service the request.
It's not the number of ports available, its the number of connections which can be made on a single port. As I say, my maximum simultaneous TCPs is 150 on port 80.In this case, localPort would be 1083, serverPort would be 80. And the amount of ports available to service requests would be dependent on the operating system. I'm not sure how many is correct or what it really depends on.
It's not the number of ports available, its the number of connections which can be made on a single port. As I say, my maximum simultaneous TCPs is 150 on port 80.
When a page is requested and the response returned, the actual TCP connection to the server is very short - say a few milliseconds in duration. Remember that the page is only downloaded once for viewing, so even if the client has the resource open for the user to see for minutes, hours or even days, the request and TCP connection would have closed a long time ago. So there's a window of a good few milliseconds during which each connection is alive, and unless all 10,000 clients simultaneously create TCP connections during those few milliseconds, there will be no problem. In addition, if the number of simultaneous connections does exceed the maximum (e.g. 150), the browser will probably try again a few more times before giving up.In such a case how does a server handle a larger number of simultanrous requests say 10,000.
Since Tomcat is Java-based, yes, the 150 would be the backlog (I prefer to call it "queue") argument for the ServerSocket listening on your Tomcat port. For the Apache Web server example I quoted, Apache isn't Java-based, so it wouldn't use a ServerSocket (instead it would use a non-Java equivalent).The ServerSocket constructor takes a backlog parameter. For the above example backlog =150 , right ?
This tiny ad is wafer thin:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|