进程可创建的最大连接数

原帖: http://blog.chinaunix.net/u/8912/showart_2441203.html

 

linux 连接数的限制
    
    socket连接数的理论值应该和一个进程所能打开的最大文件描述符数相等

查看 

ulimit -a

修改linux socket最大连接数
    
    有两种方法:
    1、ulimit -n 5000    
        把允许最大打开的描述符修改为5000,只对当前终端打开的应用程序有效。
    
    2、修改/etc/security/limits.conf
在该文件中添加以下两行:
    *      soft    nofile     5000
    *      hard    nofile     20000

    解释:
    *      表示该配置对所有用户均有效
    soft     表示软连接数
    hard     表示硬连接数
    nofile    配置是针对描述符的 


注意内核的限制 sysctl -a看看那个maxfiles之类的参数。



windows连接数的限制

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

HKLM/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters

 
TcpNumConnections  
Key: Tcpip/Parameters
取值类型:REG_DWORD - Number
取值范围:0 - 0xfffffe
缺省值:0xfffffe
描述:本参数限制可以同时打开的TCP连接的数量

MaxUserPort
key: Tcpip/Parameters
取值类型:REG_DWORD - Number
取值范围:5000-65534 (十进制)
缺省值:0x1388 (5000 十进制)
描述:控制一个应用程序可以打开的最多端口数量。通常,短命的端口在1024-5000之间分配。
当试图发起5000以上端口的连接,系统将出现WSAENOBUFS(10055)错误:因为队列满或者系统
缺乏足够的缓冲空间


TcpNumConnections

Description
Specifies the maximum number of connections that TCP can have open simultaneously.
If the value of this entry is 0, then you cannot establish any connections.

Data type Range Default value
REG_DWORD
0x40000–0xFFFFFE
0xFFFFFE


MaxUserPort

Description
Specifies the highest port number that TCP can assign when an application requests an available user port from the system. 
Typically, ephemeral ports (those used briefly) are allocated to port numbers 1024 through 5000.

Data type Range Default value
REG_DWORD
5,000–65,534 (port number)
5000

Note
Windows Server 2003 does not add this entry to the registry. You can add it by using the registry editor Regedit.exe.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值