处理超过1024个文件描述符,在C在Linux上 [英] Handling more than 1024 file descriptors, in C on Linux
问题描述
我带螺纹的网络服务器上使用的epoll(边沿触发)和线程工作,我使用的httperf进行基准测试我的服务器。
I am working on a threaded network server using epoll (edge triggered) and threads and I'm using httperf to benchmark my server.
到目前为止,它在请求被发送的速度执行得很好或几乎一模一样。直到1024屏障,这里的一切减慢至约30请求/秒。
So far, it's performing really well or almost exactly at the rate the requests are being sent. Until the 1024 barrier, where everything slows down to around 30 requests/second.
运行在Ubuntu 9.04的64位。
Running on Ubuntu 9.04 64-bit.
我已经尝试过:
- 增加文件描述符的数量的ulimit成功。它只是不提高1024以上并发连接的性能。
- Increasing the ulimit number of file descriptors, successfully. It just doesn't improve the performance above 1024 concurrent connections.
安德里@ filefridge:〜/ Dropbox的/学校/组452 / code /服务器$的ulimit -n结果
20000
andri@filefridge:~/Dropbox/School/Group 452/Code/server$ ulimit -n
20000 - Increasing the ulimit number of file descriptors, successfully. It just doesn't improve the performance above 1024 concurrent connections.
我要我的基准测试程序可以有多少个并发连接处理,直到它开始放慢(不含操作系统的干扰)。
I need to benchmark how many concurrent connections my program can handle until it starts to slow down (without the operating system interfering).
如何让我的程序与超过1024个文件描述符运行?
这限制可能是有原因的,但对于基准目的,我需要它了。
This limit is probably there for a reason, but for benchmarking purposes, I need it gone.
感谢您的答案,但我想我已经找到了罪魁祸首。在我的程序一切重新定义__FD_SETSIZE后开始移动速度快了很多。当然也的ulimit需要提高,但没有__FD_SETSIZE我的计划永远没有这个机会。
Thanks for all your answers but I think I've found the culprit. After redefining __FD_SETSIZE in my program everything started to move a lot faster. Of course ulimit also needs to be raised, but without __FD_SETSIZE my program never takes advantage of it.
推荐答案
感谢您的答案,但我想我已经找到了罪魁祸首。在我的程序一切重新定义__FD_SETSIZE后开始移动速度快了很多。当然也的ulimit需要提高,但没有__FD_SETSIZE我的计划永远没有这个机会。
Thanks for all your answers but I think I've found the culprit. After redefining __FD_SETSIZE in my program everything started to move a lot faster. Of course ulimit also needs to be raised, but without __FD_SETSIZE my program never takes advantage of it.
这篇关于处理超过1024个文件描述符,在C在Linux上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!