在.NET / Windows的服务器最大传出套接字连接 [英] Max Outgoing Socket Connections in .NET/Windows Server

查看:93
本文介绍了在.NET / Windows的服务器最大传出套接字连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里,我需要保持到另一台服务器为成千上万的移动用户在我的服务器(基本上是移动设备连接到我的中间层服务器的时候都能够,维护客户端的TCP连接一个稍微不寻常的情况更稳定的连接,为移动设备上的第三方服务器)。

I have a slightly unusual situation where I'm needing to maintain CLIENT tcp connections to another server for thousands of mobile users on my servers (basically the mobile devices connect to my middle tier server when they are able to, which maintains a more stable connection to the 3rd party server for the mobile devices).

不管怎么说,我使用异步套接字(在SslStream包裹)已经开发了我的服务器应用程序,已经得到其上运行的全部时间,现在1000的客户端会话。我对这个结果很满意,只要我看到在一个单核处理器约0-10%的平均CPU使用率,以及有关RAM 60MB的使用随着时间的推移。

Anyways, I've developed my server application using Async Sockets (wrapped up in a SslStream), and have got 1000 client sessions running full time on it right now. I'm quite happy with the results so far as I'm seeing about 0-10% average cpu usage on a single core processor, and about 60mb of ram being used over time.

我的问题是,如何调整这件事,所以我可以达到10万或20万以上的客户端会话被我的服务器上运行?再次,这是一个有点非传统的,因为我的服务器是不是真的像一个服务器,因为我担心传出连接,不传入。

My question is, how do I scale this up so I can reach 100,000 or 200,000 or more client sessions being run on my server? Again, this is a bit untraditional, as my server isn't really acting like a server, since I'm worried about outgoing connections, not incoming.

我知道,有一个注册表设置MaxUserPort的需要改为超越这似乎是5000不过默认的,似乎有65535另一个硬限制,我不要放在该限制居住昭然若揭。
这是每个网络接口的限制吗?它是一个全球性的Windows限制?它是每个进程的限制?

I know that there's a registry setting MaxUserPort that needs to be changed to get beyond the default which seems to be 5000. However, there seems to be another hard limit of 65535, and I'm not too clear on where that limit resides. Is this a limit per network interface? Is it a global Windows limit? Is it a limit per process?

如果它是每个网络接口的限制,我可以多个网络接口和绑定客户端会话插槽添加到每个接口(例如:接口2 65K接口1,65K等等)?

If it is a limit per network interface, can I add multiple network interfaces and bind client session sockets to each interface (eg: 65k on interface 1, 65k on interface 2, etc.)?

我也不太清楚是什么,如果任何套接字选项或属性我应该设置帮助的事情了。现在,我没有使用任何套接字选项。

I'm also not too sure what, if any socket options or properties I should be setting to help things out. Right now I'm not using any socket options.

我会很感激任何关于这一问题的想法,因为明确的建议一直非常难以在这个问题上得的。谢谢!

I'd really appreciate any thoughts on this subject, as clear advice has been pretty hard to come by on this subject. Thanks!

推荐答案

一个Windows机器可以轻松扩展到非常高的数字打开的连接。 64K的临时端口限速为IP地址,而不是每台机器。如果您需要更多临时端口,增加限制为@SuperTux建议,也分配多个IPS的机器。要充分利用,你必须手动调用客户端套接字上的bind(),并从池与自由港通过源IP(这也意味着你将负责跟踪每个地址可用的临时端口计数)。高端机械─类型的设备很多做到这一点(SNAT池的负载均衡,例如)以支持成千上万的并发连接。

A Windows machine can easily scale to very high numbers of open connections. The 64k ephemeral port limit is per IP address, not per machine. If you need more ephemeral ports, increase the limits as @SuperTux suggests, but also assign more IPs to the machine. To take advantage, you'll have to manually call Bind() on your client socket and pass a source IP from your pool with free ports (this also implies you'll be responsible for keeping track of available ephemeral port counts per address). Lots of high-end appliance- type devices do this (SNAT pools on load balancers, for instance) to support hundreds of thousands of concurrent connections.

簿记是一个麻烦,但比它扔得到充分利用硬件每64K客户端连接好。

Bookkeeping is a hassle, but better than throwing underutilized hardware at it for every 64k client connections.

这篇关于在.NET / Windows的服务器最大传出套接字连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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