Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How does one server handle multiple connections at a time?

The technology has been growing, so does the data, and hence its methods to store and manage. Most people wouldn’t bother how one Server handles multiple connections at a time, or how it really tackles a large amount of network traffic. They may be curious but won’t get most of the technical terms. Nevertheless, in the Tech world, it is important to know. This will, first of all, help you enhance your knowledge levels. Secondly, it will keep you up-to-date with “what’s latest” while you prepare a software or even test it. There are countless applications that run on the servers. One cannot imagine the degree of pressure of those (server admins) who handle it all. A proper strategy is a must, else it may bring disaster, perhaps the loss of crucial data and/or of finances.

How does one server handle multiple connections?

It is a common question and quite mind-boggling, which is – How does one Server Handle Multiple connections? Let’s suppose that multiple clients have been simultaneously connected to port 80. This signifies that the “connection” actually represents a packet that consists of a header field containing the destination port, which is 80 in this case. There are many other ports that have different serial numbers to get identified. It is possible that multiple clients get connected to the same port depending on which client has been assigned which port. The sockets signify the exact end-point.

It is quite an obvious fact that the IP address of each client will certainly differ, and so does the server’s IP address. Ports are just for general source and destination purpose and will hence allow multiple connections, that in turn will be diverted to the exact servers where they are supposed to reach.

One also needs to remember the rules. A socket is recognized by the syntax – {SRC-IP, SRC-PORT, DEST-IP, DEST-PORT, PROTOCOL}. Mind that mentioning the protocol is important. Therefore, if two clients try to connect with the same port then according to the rule it would be – socket1{SRC-A, 100, DEST-X, 80, TCP} and socket2{SRC-B, 100, DEST-X, 80, TCP}. To summarize this particular case, host A contacts with the Server X through the port 80, and host B too contacts with the same server through the same port. The IP addresses of these clients are, of course, different.

Now the server is going to decide which socket should be prioritized. If a single server is listening to the same port it is possible that there are more than one sockets being connected which can be from the same or different clients. As long as this server knows which request is coming from where (via the socket) it can respond to the respective client(s) using the same socket. It does not need to open another port in its own node, but the original one using which the client initially tried to connect, can be used. In fact, it should respond back using the same initial socket in order to not waste the resources.

It is possible that a server’s two different processes listen to the same port, provided that both of them use different protocols; else it is impossible. Servers are also classified as single and multiple threaded.

If one server uses single child-process in order to serve all the sockets it is known as a single-threaded server. If a server uses a number of sub-processes in order to serve multiple requests by allocating each socket to one sub-process then it is known as a multi-threaded server. This is how the server handles multiple connections at a time.

One should not assume that if the two processes are mentioned then there must be some kind of parent-child relationship between them both. OS, in general, allows a child process to inherit everything from parents. Therefore, if a process (say) A is listening to a number of sockets then other (child) processes like A1, A2,… can also listen, but not another process B which is entirely unrelated. The two or more different processes cannot listen to the same socket and that is managed by the operating system. If the OS does not follow this then it will be called as violating the existing rules.

The post How does one server handle multiple connections at a time? appeared first on Apachebooster Blog: Showcasing the tech blogs written by our writers.



This post first appeared on Tired Of Your Web Server Performance? Try Apachebooster, An Apache Based Plugin For Cpanel, please read the originial post: here

Share the post

How does one server handle multiple connections at a time?

×

Subscribe to Tired Of Your Web Server Performance? Try Apachebooster, An Apache Based Plugin For Cpanel

Get updates delivered right to your inbox!

Thank you for your subscription

×