Websockets 和可扩展性
Websockets and scalability
我是 websockets 的初学者。
在我的应用程序中需要服务器需要在发生变化时通知客户端并计划使用 websockets。
单个服务器实例和单个客户端 ==> 将创建多少个 websockets 以及多少个到 websockets 的连接?
单个服务器实例和 10 个客户端 ==> 将创建多少个 websockets 以及多少个到 websockets 的连接?
单个服务器实例和 1000 个客户端 ==> 将创建多少个 websockets 以及多少个到 websockets 的连接?
当您的应用程序拥有 1000 多个用户群时,您如何使用 webscokets 进行扩展?
非常感谢您的反馈。
1) Single server instance and single client ==> How many websockets will be created and how many connections to websockets?
如果您的客户端创建一个webSocket 连接,那么客户端上将有一个webSocket 连接,服务器上将有一个webSocket 连接。客户端创建到服务器的 webSocket 连接,因此客户端决定有多少连接。如果它创建3,则有3。如果它创建1,则有1。通常,客户端只创建1。
2) Single server instance and 10 clients ==> How many websockets will be created and how many connections to websockets?
如上所述,这取决于客户端的操作。如果每个客户端创建 1 个 webSocket 连接,并且有 10 个客户端连接到服务器,那么服务器将看到总共 10 个 webSocket 连接。
3) Single server instance and 1000 clients ==> How many websockets will be created and how many connections to websockets?
与第 2 点相同。
How do you scale with webscokets when your application has a 1000’s of user base?
一台配置得当的服务器可以同时处理数十万个大部分空闲的 webSocket 连接,因为空闲的 webSocket 几乎不使用任何服务器 CPU。对于更大规模的部署,可以将服务器集群(运行 多个服务器进程)并使用粘性负载平衡来分散负载。
如果您正在追求大规模 webSocket 或 socket.io 部署,Google 上还有很多类似的文章值得一读:
The Road to 2 Million Websocket Connections in Phoenix
600k concurrent websocket connections on AWS using Node.js
10 million concurrent webSockets
最终,每个正确配置的服务器可实现的规模可能更多地取决于每个连接有多少 activity 以及交付它需要多少计算。
我是 websockets 的初学者。 在我的应用程序中需要服务器需要在发生变化时通知客户端并计划使用 websockets。
单个服务器实例和单个客户端 ==> 将创建多少个 websockets 以及多少个到 websockets 的连接?
单个服务器实例和 10 个客户端 ==> 将创建多少个 websockets 以及多少个到 websockets 的连接?
单个服务器实例和 1000 个客户端 ==> 将创建多少个 websockets 以及多少个到 websockets 的连接?
当您的应用程序拥有 1000 多个用户群时,您如何使用 webscokets 进行扩展?
非常感谢您的反馈。
1) Single server instance and single client ==> How many websockets will be created and how many connections to websockets?
如果您的客户端创建一个webSocket 连接,那么客户端上将有一个webSocket 连接,服务器上将有一个webSocket 连接。客户端创建到服务器的 webSocket 连接,因此客户端决定有多少连接。如果它创建3,则有3。如果它创建1,则有1。通常,客户端只创建1。
2) Single server instance and 10 clients ==> How many websockets will be created and how many connections to websockets?
如上所述,这取决于客户端的操作。如果每个客户端创建 1 个 webSocket 连接,并且有 10 个客户端连接到服务器,那么服务器将看到总共 10 个 webSocket 连接。
3) Single server instance and 1000 clients ==> How many websockets will be created and how many connections to websockets?
与第 2 点相同。
How do you scale with webscokets when your application has a 1000’s of user base?
一台配置得当的服务器可以同时处理数十万个大部分空闲的 webSocket 连接,因为空闲的 webSocket 几乎不使用任何服务器 CPU。对于更大规模的部署,可以将服务器集群(运行 多个服务器进程)并使用粘性负载平衡来分散负载。
如果您正在追求大规模 webSocket 或 socket.io 部署,Google 上还有很多类似的文章值得一读:
The Road to 2 Million Websocket Connections in Phoenix
600k concurrent websocket connections on AWS using Node.js
10 million concurrent webSockets
最终,每个正确配置的服务器可实现的规模可能更多地取决于每个连接有多少 activity 以及交付它需要多少计算。