找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 6795|回复: 9

请问设置FD_SETSIZE大小能改变ACE的Reactor服的连接数吗?

[复制链接]
发表于 2007-12-19 21:54:45 | 显示全部楼层 |阅读模式
我把2.4内核的linux升级成了2.6的内核了,并在编译的时候修改了在<linux/posix_type>中__FD_SETSIZE设为了65536
,并在编译ACE的时候在config.h 中也加了#define FD_SETSIZE 65536,但当连接数达到1016时,他好像什么事件也不触发了.就客户端好像是连接上了,但服务端没有反应,请大家指点啊.!  谢谢!
 楼主| 发表于 2007-12-19 21:54:52 | 显示全部楼层
FFFF是 65535,而不是65536。
说明你的修改并没有生效,是不是和系统相关呢?
推荐你用TP_Reactor或者Dev_Poll_Reactor.
 楼主| 发表于 2007-12-19 21:54:58 | 显示全部楼层
TP_Reactor能达到这么多吗.我一开始的时候就是用的TP_Reactor,不过他的连接数也只有1000左右啊.

我感觉在ACE中最大连接数跟FD_SETSIZE关系并非主要的,我认为跟getrlimit函数的返回值关系比较大.
 楼主| 发表于 2007-12-19 21:55:06 | 显示全部楼层
设置FD_SETSIZE可以修改连接数,但在重新编译linux内核,只重编译ACE是不行的!

一般Linux下连接数为1024,ACE自己用了两个,我们只能连接1022个连接。

如果连接数超出1000,可采用epoll。最大可连接到65535。
 楼主| 发表于 2007-12-19 21:55:14 | 显示全部楼层
内核是重新编译了,在<linux/posix_type.h>头文件中改了,也重新编译了ACE,我单独用C语言测试时,发现FD_SETSIZE确实是65536的.但到了ACE中就变了,在ACE.h中的max_hanles()函数的返回值确是1024 ,我现在最想用的就是用TP_Reactor来达到5000 的用户量.
 楼主| 发表于 2007-12-19 21:55:21 | 显示全部楼层
TP_Reactor就是为了突破1024的限制而设计的。
 楼主| 发表于 2007-12-19 21:55:27 | 显示全部楼层
那就只能好好分析函数 max_hanles(),来查看到底谁影响这个值
 楼主| 发表于 2007-12-19 21:55:36 | 显示全部楼层
也作了和buckwen同样的测试,结果一样,按照http://www.riverace.com/ace-linux.htm的说法:

Using More Than 1024 Network Handles
The maximum number of handles that can be used with select() varies across platforms, but with Linux kernels, it's 1024 by default. For many applications, this is too low, reducing the scalability of applications using select()-based reactor implementations (ACE_Select_Reactor and ACE_TP_Reactor). When you need to increase the number of handles, follow these steps (this works for at least 2.4 kernels as reported by one customer... your mileage may vary):

Change the value of __FD_SETSIZE to the maximum you want. This value should be changed in:
/usr/include/bits/typesizes.h
/usr/include/bits/nptl/typesizes.h
/usr/include/linux/posixtypes.h
Rebuild the kernel.
Rebuild ACE.
Make sure that /proc/sys/fs/file-max (total number of files that can be opened by all users) is large enough. To check, you can: cat /proc/sys/fs/file-max
If you need to increase it, modify /etc/sysctl.conf and add: fs.file-max = <some big number> and then execute sysctl -p. Most likely you will not have to make any changes here.
Edit /etc/security/limits.conf and add: <user name> hard nofile <the handle limit you want> (no larger than the __FD_SETSIZE value from above).
Login as user specified in previous step and execute ulimit -n 2048. At this point kernel will allow any process in current session to open 2048 handles. To check what are your limits you can always use ulimit -a. Since this setting will be valid only for this session, you can add ulimit -n 2048 to your .profile or .bash_profile if the permanent setting is required.
  好像没用。

  另外,采用Dev_Poll好像也是1000多个。

  winston有没有试过?
 楼主| 发表于 2007-12-19 21:55:51 | 显示全部楼层
denis谢谢你对我所做工作的恳定.我试过Dev_Poll,可以实现,
 楼主| 发表于 2007-12-19 21:55:56 | 显示全部楼层
我觉得max_handle()的返回是影响ACE的基于select方式最大连接数的一个方面,我觉得还有另一个因素,应该与register_handles有关,(这只是现在考虑,还不确定,不知是否有和我一样的想法),因为我试过既使max_handles()的返回值达到65536 ,他的连接数也不能超过1024,在这种情况要是大于1024个连接上来的话,服务器就会没有任何反应了.
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-5-20 10:20 , Processed in 0.506923 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表