如何扩展 socket.io? [英] How can I scale socket.io?

查看:28
本文介绍了如何扩展 socket.io?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个服务器获得 10,000 个并发连接(通过 socket.io).太多了,如果它不能处理更多,我需要启动另一台服务器.

Let's say a server gets 10,000 concurrent connections (via socket.io). That's a lot, and if it can't handle any more, I need to spin up another server.

如何将两台服务器与其 socket.io 同步?

How can I sync the two servers together with their socket.io?

推荐答案

你可以尝试使用例如cluster 模块并将负载分配到多个内核(如果您有一个多核 CPU).如果这还不够,您可以尝试使用 反向代理 跨多个服务器分发请求,并且 redis 作为中央会话数据存储(如果您的方案可能).

You can try to use for example cluster module and distribute the load to multiple cores (in case you have a multi-core CPU). In case this is not enough you can try to use reverse proxy for distributing requests across multiple servers and redis as a central session data store (if it's possible for your scenario).

这篇关于如何扩展 socket.io?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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