Linux 选择 vs 投票 vs epoll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4039832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
select vs poll vs epoll
提问by ravi
I am designing a new server which needs to support thousands of UDP connections (somewhere around 100,000 sessions). Any input or suggestions on which one to use?
我正在设计一个需要支持数千个 UDP 连接(大约 100,000 个会话)的新服务器。关于使用哪一个的任何意见或建议?
回答by Yann Ramin
Linux: epoll
FreeBSD: kqueue
Windows: ??
Linux: epoll
FreeBSD: kqueue
Windows: ??
There are wrapper libraries, such as libevent and libev, which can abstract this for you.
有一些包装库,例如 libevent 和 libev,它们可以为您抽象这一点。
回答by Kalantir
The answer is epoll if you're using Linux, kqueue if you're using FreeBSD or Mac OS X, and i/o completion ports if you're on Windows.
如果您使用的是 Linux,答案是 epoll,如果您使用的是 FreeBSD 或 Mac OS X,则是 kqueue,如果您使用的是 Windows,则是 i/o 完成端口。
Some additional things you'll (almost certainly) want to research are:
您(几乎可以肯定)想要研究的一些其他内容是:
- Load balancing techniques
- Multi-threaded networking
- Database architecture
- Perfect hash tables
- 负载均衡技术
- 多线程网络
- 数据库架构
- 完美的哈希表
Additionally, it is importantto note that UDP does not have "connections" as opposed to TCP. It would also be in your best interest to start small and scale larger since debugging network-based solutions can be challenging.
此外,重要的是要注意 UDP 与 TCP 相比没有“连接”。由于调试基于网络的解决方案可能具有挑战性,因此从小规模开始并扩大规模也符合您的最大利益。
回答by unixman83
The author of CURL wrote an amazing article on poll vs select vs event libraries.
CURL 的作者写了一篇关于poll vs select vs event libraries的精彩文章。