select vs poll vs epoll
我正在设计一个新服务器,需要支持数千个 UDP 连接(大约 100,000 个会话)。有人可以解释一下select
与poll
与epoll
吗?它将帮助我知道该使用哪一个。
I am designing a new server which needs to support thousands of UDP connections (somewhere around 100,000 sessions). Can someone explain select
vs poll
vs epoll
? It will help me know which one to use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 Linux,答案是 epoll;如果您使用 FreeBSD 或 Mac OS X,答案是 kqueue;如果您使用 Windows,答案是 i/o 完成端口。
您(几乎肯定)想要研究的一些其他内容包括:
此外,重要要注意 UDP 没有像反对TCP。由于调试基于网络的解决方案可能具有挑战性,从小规模开始并扩大规模也符合您的最佳利益。
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.
Some additional things you'll (almost certainly) want to research are:
Additionally, it is important to 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.
Linux:
epoll
FreeBSD:
kqueue
窗户:??
有一些包装器库,例如 libevent 和 libev,可以为您抽象这一点。
Linux:
epoll
FreeBSD:
kqueue
Windows: ??
There are wrapper libraries, such as libevent and libev, which can abstract this for you.