Web 服务器如何在单个端口 (80) 上一次处理多个用户的传入请求? [英] How can a web server handle multiple user's incoming requests at a time on a single port (80)?

查看:38
本文介绍了Web 服务器如何在单个端口 (80) 上一次处理多个用户的传入请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Web 服务器如何在单个端口 (80) 上同时处理多个传入请求?

示例:同时有 30 万用户希望看到来自 www.abcdef.com 的图像,该图像分配了 IP 10.10.100.100 和端口 80.那么 www.abcdef.com 如何处理传入用户的负载?

一台服务器(分配有 IP 10.10.100.100)能否处理如此大量的传入用户?如果不是,那么如何将一个 IP 地址分配给多个服务器来处理这种负载?

解决方案

来自 tcpipguide

<块引用>

这种同时使用客户端和服务器套接字的连接标识提供了灵活性,允许我们在 Internet 上认为理所当然的设备之间进行多个连接.例如,繁忙的应用程序服务器进程(如 Web 服务器)必须能够处理来自多个客户端的连接,否则万维网将几乎无法使用.由于使用客户端的套接字以及服务器的套接字来标识连接,因此这没有问题.在 Web 服务器维护上面提到的连接的同时,它可以轻松地拥有另一个连接,例如 IP 地址 219.31.0.44 的端口 2,199.这由连接标识符表示:

(41.199.222.3:80, 219.31.0.44:2199).

<块引用>

事实上,我们可以有多个从同一个客户端到同一个服务器的连接.每个客户端进程都会被分配一个不同的临时端口号,因此即使它们都尝试访问同一个服务器进程(例如 41.199.222.3:80 的 Web 服务器进程),它们都会拥有不同的客户端套接字并代表唯一的连接.这使您可以从计算机同时向同一个网站发出多个请求.

同样,TCP 独立跟踪这些连接中的每一个,因此每个连接都不知道其他连接.TCP 可以处理数百甚至数千个同时连接.唯一的限制是运行 TCP 的计算机的容量,以及到它的物理连接的带宽——同时运行的连接越多,每个连接共享的有限资源就越多.

How does a web server handle multiple incoming requests at the same time on a single port(80)?

Example : At the same time 300k users want to see an image from www.abcdef.com which is assigned IP 10.10.100.100 and port 80. So how can www.abcdef.com handle this incoming users' load?

Can one server (which is assigned with IP 10.10.100.100) handle this vast amount of incoming users? If not, then how can one IP address be assigned to more than one server to handle this load?

解决方案

From tcpipguide

This identification of connections using both client and server sockets is what provides the flexibility in allowing multiple connections between devices that we take for granted on the Internet. For example, busy application server processes (such as Web servers) must be able to handle connections from more than one client, or the World Wide Web would be pretty much unusable. Since the connection is identified using the client's socket as well as the server's, this is no problem. At the same time that the Web server maintains the connection mentioned just above, it can easily have another connection to say, port 2,199 at IP address 219.31.0.44. This is represented by the connection identifier:

(41.199.222.3:80, 219.31.0.44:2199). 

In fact, we can have multiple connections from the same client to the same server. Each client process will be assigned a different ephemeral port number, so even if they all try to access the same server process (such as the Web server process at 41.199.222.3:80), they will all have a different client socket and represent unique connections. This is what lets you make several simultaneous requests to the same Web site from your computer.

Again, TCP keeps track of each of these connections independently, so each connection is unaware of the others. TCP can handle hundreds or even thousands of simultaneous connections. The only limit is the capacity of the computer running TCP, and the bandwidth of the physical connections to it—the more connections running at once, the more each one has to share limited resources.

这篇关于Web 服务器如何在单个端口 (80) 上一次处理多个用户的传入请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆