peakzhang 发表于 2007-12-19 21:54:45

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

我把2.4内核的linux升级成了2.6的内核了,并在编译的时候修改了在<linux/posix_type>中__FD_SETSIZE设为了65536
,并在编译ACE的时候在config.h 中也加了#define FD_SETSIZE 65536,但当连接数达到1016时,他好像什么事件也不触发了.就客户端好像是连接上了,但服务端没有反应,请大家指点啊.!谢谢!

peakzhang 发表于 2007-12-19 21:54:52

FFFF是 65535,而不是65536。
说明你的修改并没有生效,是不是和系统相关呢?
推荐你用TP_Reactor或者Dev_Poll_Reactor.

peakzhang 发表于 2007-12-19 21:54:58

TP_Reactor能达到这么多吗.我一开始的时候就是用的TP_Reactor,不过他的连接数也只有1000左右啊.

我感觉在ACE中最大连接数跟FD_SETSIZE关系并非主要的,我认为跟getrlimit函数的返回值关系比较大.

peakzhang 发表于 2007-12-19 21:55:06

设置FD_SETSIZE可以修改连接数,但在重新编译linux内核,只重编译ACE是不行的!

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

如果连接数超出1000,可采用epoll。最大可连接到65535。

peakzhang 发表于 2007-12-19 21:55:14

内核是重新编译了,在<linux/posix_type.h>头文件中改了,也重新编译了ACE,我单独用C语言测试时,发现FD_SETSIZE确实是65536的.但到了ACE中就变了,在ACE.h中的max_hanles()函数的返回值确是1024 ,我现在最想用的就是用TP_Reactor来达到5000 的用户量.

peakzhang 发表于 2007-12-19 21:55:21

TP_Reactor就是为了突破1024的限制而设计的。

peakzhang 发表于 2007-12-19 21:55:27

那就只能好好分析函数 max_hanles(),来查看到底谁影响这个值

peakzhang 发表于 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有没有试过?

peakzhang 发表于 2007-12-19 21:55:51

denis谢谢你对我所做工作的恳定.我试过Dev_Poll,可以实现,

peakzhang 发表于 2007-12-19 21:55:56

我觉得max_handle()的返回是影响ACE的基于select方式最大连接数的一个方面,我觉得还有另一个因素,应该与register_handles有关,(这只是现在考虑,还不确定,不知是否有和我一样的想法),因为我试过既使max_handles()的返回值达到65536 ,他的连接数也不能超过1024,在这种情况要是大于1024个连接上来的话,服务器就会没有任何反应了.
页: [1]
查看完整版本: 请问设置FD_SETSIZE大小能改变ACE的Reactor服的连接数吗?