69

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
ravi
  • 745
  • 1
  • 7
  • 4
  • 1
    which os are you on? different os have different specific. – J-16 SDiZ Oct 28 '10 at 04:45
  • Linux Redhat enterprise version 5 – ravi Oct 28 '10 at 18:41
  • 1
    @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](http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html) – ypercubeᵀᴹ Dec 30 '11 at 01:59
  • 4
    Zed Shaw wrote a great analysis of epoll vs poll: http://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. – dpn Feb 01 '13 at 23:35
  • 1
    I find a good webpage to indicate the difference between them : http://www.ulduzsoft.com/2014/01/select-poll-epoll-practical-difference-for-system-architects/#Polling_with_poll Hope can help – Question-er XDD Dec 09 '15 at 09:23
  • 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. – rustyx Mar 16 '21 at 10:21

2 Answers2

50

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.

Mathew Kurian
  • 5,949
  • 5
  • 46
  • 73
Kalantir
  • 581
  • 3
  • 2
  • 6
    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. – ravi Nov 08 '10 at 04:02
20

Linux: epoll FreeBSD: kqueue Windows: ??

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

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82