Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select vs poll vs epoll [closed]

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?

like image 364
ravi Avatar asked Oct 28 '10 04:10

ravi


People also ask

What is the difference between poll and epoll?

epoll is a Linux-specific enhancement of poll(). It hides the details of representation in an internal data structure that is manipulated using a special function epoll_create(). It's one of the newer variants developed for high-performance servers with many active connections...

Why is epoll better than select?

The main difference between epoll and select is that in select() the list of file descriptors to wait on only exists for the duration of a single select() call, and the calling task only stays on the sockets' wait queues for the duration of a single call.

What is the difference between select and poll?

The select() call has you create three bitmasks to mark which sockets and file descriptors you want to watch for reading, writing, and errors, and then the operating system marks which ones in fact have had some kind of activity; poll() has you create a list of descriptor IDs, and the operating system marks each of ...

What is select poll epoll?

Unlike select and poll both of which only provide one API, epoll is not a single API but a group of 3 APIs. epoll_create and epoll_add are called to set up the epoll instance while epoll_wait can be called in a loop to constantly wait on the fds added by epoll_add . The complexity of the inner loop is O(ready fds) .


2 Answers

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.

like image 173
Kalantir Avatar answered Oct 06 '22 12:10

Kalantir


The author of CURL wrote an amazing article on poll vs select vs event libraries.

like image 27
unixman83 Avatar answered Oct 06 '22 13:10

unixman83