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.
select vs poll vs epoll
Asked Answered
which os are you on? different os have different specific. –
Buzz
Linux Redhat enterprise version 5 –
Modernism
@ravi: You should also check for event-based (asychronous) frameworks like Twisted, where you can write your server and test it with various polling methods: TwistedMatrix.com : Choosing a Reactor –
Timekeeper
Zed Shaw wrote a great analysis of epoll vs poll: sheddingbikes.com/posts/1280829388.html tl;dr: Poll is good if you have a large ratio of active fds. Epoll is better if you have a large number of inactive fds. A good example of inactive fds are things like WebSockets and Cometd, where clients will open a connection and wait for a long time before anything is transmitted either way. –
Handbook
I find a good webpage to indicate the difference between them : ulduzsoft.com/2014/01/… Hope can help –
Robert
Good question, but you might want to replace "Any input or suggestions" with "what are the key differences between them and when should they be used?", then we'll reopen. –
Puce
Just to note, with UDP you could support any number of "sessions" with a single socket for incoming. Once you have saturated the wire, nothing more to gain. Depends on the volume of traffic. –
Privative
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:
- Load balancing techniques
- Multi-threaded networking
- Database architecture
- Perfect hash tables
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.
Thanks for the response. I understand there is no such thing called UDP connections as it is a connectionless oriented communicated. The application I had in mind is session based, so instead of session I mentioned it as connection. My bad. Also I have tried more than 200,000 sessions based on select with multithreaded application. Just wanted to optimize. Also iam not new to building scalable architecture solution. Load balancing might not be good fit for the kind of server iam looking at. It’s definitely a multithread networking. Will most probably use some kind of producer/consumer pattern. –
Modernism
Linux: epoll
FreeBSD: kqueue
Windows: ??
There are wrapper libraries, such as libevent and libev, which can abstract this for you.
Windows: IO Completion Port –
Stearic
And by the way. IOCP: Windows NT 3.5, 1994; kqueue: BSD 4.1, 2000; epoll: linux kernel 2.5.44, 2002. –
Kobe
libev is poorly written IMO, it crashes when I free memory for active events after I've stopped them! The design is not good. Also, It's all in one (3000 line) .c file that contains most of the code. –
Centriole
@Centriole A single 3000 line .c file sounds amazing! –
Omnifarious
© 2022 - 2024 — McMap. All rights reserved.