我创建一个服务器来监视用户的在线presence在网页上。
I am creating a server to monitor the online presence of clients on a webpage.
将有80-100 000(八万)并发客户端进行监控。 在我使用的.Net写这个。客户端将联系使用JavaScript(在HTML页面上)一个(独立)服务器,告诉它们还活着/网络服务器。
Clients will contact a (separate) server using JavaScript (on the HTML-page) to tell the server that they are alive/online.
我正在考虑以下两种方法之一:
I’m considering one of two approaches:
与保活定时发送持久连接。 这会给我更多的高precision时客户端断开连接,我也不需要更新内存结构(onlineinfo)过于频繁,因为我们知道,当客户来了又走。额外的好处网络设备/带宽。
Persistent connections with keep-alive sent regularly. This will give me much higher precision on when clients disconnect and I don’t need to update memory structure (onlineinfo) too often because we know when client comes and goes. Additional benefits to network equipment / bandwidth.
客户端(重新)连接每隔告诉服务器,他们是活的。 这需要大量的连接和将必然减少的精确度。我想象像间隔2-3分钟是我们能做到的最好的。每秒80K / 120 = 660连接... ASP.Net不执行太快了,所以我不能确定这一点。 8核心系统=〜10毫秒每次执行。
Clients (re)connect at intervals to tell server they are alive. This requires a lot of connections and will necessarily decrease the accuracy. I imagine intervals like 2-3 minutes is the best we can do. 80k/120=660 connections per second… ASP.Net don’t execute too fast so I’m unsure about this. 8 core system = ~10 ms per execution.
使用的连接数量也有显着一定的局限性。我不能同时催生了许多线程的实例。 1请求IIS产卵的ASP.Net应用程序将使用1线程,直到请求完成。
With this many connections there are obviously some limitations. I can’t spawn that many threads simultaneously for instance. 1 request to IIS spawning an ASP.Net application will use 1 thread until request is done.
是写一个独立的HTTP服务器的最佳选择? 不.Nets的TcpListener杠杆httpd.sys(IIS)?
Is the best option to write a stand-alone http-server? Doesn’t .Nets TcpListener leverage httpd.sys (IIS)?
关于这个问题的任何(建设性)的想法是AP preciated。
Any (constructive) thoughts on the subject would be appreciated.
编辑:添加一些有用的链接,这个职位按照从萨科Repiquets答案找到链接:
更接近线与高性能套接字在.NET Tips /技术的高性能C#服务器套接字 使用C#.NET Get Closer to the Wire with High-Performance Sockets in .NET Tips / techniques for high-performance C# server sockets High Performance TCP/IP Server using C#.NET100 000永久连接是不是一种可行的选择。
100 000 persistent connections is not a viable option.
在发送间隔的HTTP请求的方式比较可行,写一个专用的HTTP服务器是一个有趣的选择海事组织。
Sending HTTP requests at interval is way more feasible, and writing a dedicated HTTP server is an interesting choice IMO.
看看这个问题的一些方向。