select vs poll vs epoll

54,728

Solution 1

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.

Solution 2

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

Solution 3

Linux: epoll FreeBSD: kqueue Windows: ??

There are wrapper libraries, such as libevent and libev, which can abstract this for you.

Share:
54,728
Admin
Author by

Admin

Updated on August 29, 2020

Comments

  • Admin
    Admin over 3 years

    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?

  • Krystian Bigaj
    Krystian Bigaj over 13 years
    Windows: IO Completion Port
  • Admin
    Admin over 13 years
    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.
  • Soonts
    Soonts about 13 years
    And by the way. IOCP: Windows NT 3.5, 1994; kqueue: BSD 4.1, 2000; epoll: linux kernel 2.5.44, 2002.
  • unixman83
    unixman83 over 12 years
    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.
  • Navin
    Navin over 8 years
    @unixman83 A single 3000 line .c file sounds amazing!
  • enigmaticPhysicist
    enigmaticPhysicist over 7 years
    That guide didn't help at all. It basically assumed everybody knew the main differences between the three.
  • MikeMB
    MikeMB almost 7 years
    Please provide at least a summary and not just a bare link
  • Guy Avraham
    Guy Avraham about 6 years
    @enigmaticPhysicist - I agree with you. I have found this article more detailed, hope it helps: ulduzsoft.com/2014/01/…