java多服务器聊天架构
我目前正处于开始使用多个服务器(机器)开发聊天(实际上是移植较旧的单服务器版本)的阶段。
我想使用 java NIO 库。
我这样做的原因是,当连接大量客户端(大约10k)时,当前的实现工作速度非常慢,而且当前的实现是基于IO套接字库的。我还估计 1 年内将拥有大约 40-50k 的实时客户。
所以..我有几个问题:
- 你认为/估计 NIO 可以处理多少个客户端,因为我听说 NIO 比旧的套接字实现好得多?
- 您有什么想法吗?或者您可以向我指出一些已经实现的使用多服务器聊天的架构。
- 使用多服务器架构时可能面临哪些主要问题?
提前致谢
I'm currently on the stage to begin developing a chat (actually porting an older single server version ) using multiple servers(machines).
I want to use java NIO library.
The reason why I'm doing this is because the current implementation is working very slow when a huge number of clients are being connected(around 10k), also the current implementation is based on the IO socket library. I also estimate that in 1 year to have around 40-50k live clients.
So.. I have a few questions:
- How many client do you think/estimate NIO can handle since I heard is much better than the old socket implementation?
- do you have any ideas or you can point me to some already implemented architecture of using multi server chat.
- what are the major problems that I might face when using a multi server architecture?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为从 NIO 库的角度来看没有任何限制。归根结底,性能取决于您的服务器和网络配置。
You might like to take a look at Apache MINA Project for NIO framework.
Apache MINA 是一个网络应用框架,可以帮助用户轻松开发高性能、高扩展性的网络应用。它通过 Java NIO 提供基于各种传输(例如 TCP/IP 和 UDP/IP)的抽象·事件驱动·异步 API。
Apache MINA 通常被称为:
。 NIO框架·库,
。客户端·服务器框架·库,或
。一个网络·套接字库。
I don't think there is any limitation from the NIO library point of view. At the end of the day performance depends on your Server and Network configuration.
You might like to take a look at Apache MINA Project for NIO framework.
Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract ·event-driven · asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.
Apache MINA is often called:
. NIO framework · library,
. client · server framework · library, or
. a networking · socket library.
如果没有性能测试就很难给出估计;您可以支持的客户端数量将根据内存、处理器速度/负载、带宽/容量、延迟要求、存储要求
而有所不同……您可以使用多种方法在服务器之间共享数据;我会选择它们之间的广播/多播 UDP,因为它是最具可扩展性的方法。
您可能面临的最大问题是应对服务器中断以及正确处理负载平衡。
编辑
如果您不依赖于服务器到服务器的 NIO,那么 pub/sub 模式下的 JMS 可能是一个很好的解决方案。
Estimates are difficult to give without performance testing; the number of clients you can support will vary based on memory, processor speed/load, bandwidth/volume, latency requirements, storage requirements...
There are a couple of approaches you could use to share data between servers; I'd go for broadcast/multicast UDP between them, as it is the most scalable approach.
The biggest issue you're likely to face is coping with server outages, and properly handling load-balancing.
EDIT
If you're not tied to NIO for the server-to-server, JMS in pub/sub mode may be a good solution.