IRC 协议 - 持续的客户端连接好吗?
当我尝试使用 C# 和 WCF 时,我一直读到的一件事是让客户端与服务器保持恒定的当前连接是多么不可扩展。尽管 WCF 允许,但如果您想要拥有任何体面的可扩展性,似乎推荐的最佳实践是使用“每次调用”而不是“每次会话”进行实例管理。 (如果我错了,请纠正我)
但是,据我了解,IRC 使用与服务器的持续客户端连接,并且 IRC 服务器(以及服务器网络)在任何给定时间都为数十万客户端提供服务。那么在这种情况下,保持客户端与服务器的持续连接实际上没有什么“坏处”吗?
When I was experimenting with C# and WCF one of the things I kept reading about was how unscalable it is to have clients with a constant current connection to the server. And although WCF allows that it seems that the recommended best practise is to use 'per call' as opposed to 'per session' for instance management if you want to have any kind of decent scalablity. (Please correct me if Im wrong)
However from what I understand IRC uses constant client connections to the server and IRC servers (well networks of servers) are servicing hundreds of thousands of clients at any given time. So in that case is there nothing actually 'bad' about keeping constant client connections to the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只要不遵循每个连接一个线程的架构,服务器就可以支持相当大量的并发 TCP 连接。
除了 TCP 发送和接收窗口之外,IRC 对每个连接状态的要求并不高。
As long as you don't follow the one-thread-per-connection architecture, a server can support quite a large number of concurrent TCP connections.
IRC doesn't require much per connection state, beyond the TCP send and receive windows.
如果您需要实时双工通信(IRC 是一种聊天协议),那么保持 TCP 连接处于活动状态是一个相关选项。然而,TCP 连接会带来网络开销,并且操作系统对并发打开的 TCP 连接数有实际限制。 WCF 通常用在不需要双工通信的 SOAP/HTTP/RPC 上下文中,但它当然也为此提供了合适的绑定和通道。要回答您的问题,如果您对通信有实时、双工要求,保持连接打开并没有什么坏处。
If you need real-time duplex communication (IRC is a chat protocol), then keeping a TCP connection alive is a relevant option. However, TCP connection brings network overhead and operating systems have practical limits on the number of concurrent open TCP connections. WCF is commonly used in SOAP/HTTP/RPC contexts where duplex communication is not required, but certainly it offers suitable bindings and channels for that as well. To answer your question, there is nothing bad in keeping the connection open if you have real-time, duplex requirements for your communication.
是的,这样的架构是可行的,但是...... "ping? pong! “事物的发明是有原因的——让双方都知道对方还在那里。您实际上无法判断客户端是否空闲,因为它没有太多可说的,或者因为它实际上已断开连接并且您正在等待 TCP 超时。
UPD:仅由于服务器网络,IRCnet 上才可能有“数十万个客户端”。对于单机来说,C10K问题仍然是一个问题。
Yes, such architecture is feasible, but... The "ping? pong!" thing was invented for a reason - to let both parties know that the other party is still there. You cannot actually tell if a client is idle, because it does not have much to say or because it is actually disconnected and you are waiting for a TCP timeout.
UPD: "hundreds of thousands of clients" is possible on IRCnet only because of server networks. For a single machine, the C10K problem is still an issue.