Skip to main content

Close
Get the best research tool on the web today,and free!
Connect with people with common interests!

All Annotations of The C10K problem[Preview]

saved by29 people, first byWade Ren on 2006-03-02, last bypeter cai on 2008-07-06

  • 4. Serve one client with each server thread



    ... and let read() and write() block. Has the disadvantage of using a whole stack
    frame for each client, which costs memory. Many OS's also have trouble handling more
    than a few hundred threads. If each thread gets a 2MB stack (not an uncommon
    default value), you run out of *virtual memory* at (2^30 / 2^21) = 512 threads
    on a 32 bit machine with 1GB user-accessible VM (like, say, Linux as normally shipped on x86).
    You can work around this by giving each thread a smaller stack,
    but since most thread libraries don't allow growing thread stacks
    once created, doing this means designing your program to minimize
    stack use. You can also work around this by moving to a 64 bit processor.


    The thread support in Linux, FreeBSD, and Solaris is improving,
    and 64 bit processors are just around the corner even for mainstream users.
    Perhaps in the not-too-distant future, those who prefer using
    one thread per client will be able to use that paradigm even
    for 10000 clients.
    Nevertheless, at the current time, if you actually want to support that many clients,
    you're probably better off using some other paradigm.


    For an unabashedly pro-thread viewpoint, see
    Why Events Are A Bad Idea (for High-concurrency Servers)
    by von Behren, Condit, and Brewer, UCB, presented at HotOS IX.
    Anyone from the anti-thread camp care to point out a paper that rebuts this one? :-)

  • level-triggered
  • Generally only usable with network I/O, not disk I/O.
  • level-triggered
  • whether or not you've done anything with that file descriptor since the last time
    the kernel told you about it.
  • setting nonblocking mode on a disk file handle has no effect.
  • Unfortunately, select() is limited to FD_SETSIZE handles.
  • There is no hardcoded limit to the number of file descriptors poll() can handle,
    but it does get slow about a few thousand, since most of the file descriptors
    are idle at any one time, and scanning through thousands of file descriptors
    takes time.
  • /dev/poll

    This is the recommended poll replacement for Solaris.
  • kqueue()

    This is the recommended poll replacement for FreeBSD (and, soon, NetBSD).
  • means you give the kernel a file descriptor, and later, when that descriptor transitions from
    not ready to ready
  • Readiness change notification (or edge-triggered readiness notification)
    means you give the kernel a file descriptor, and later, when that descriptor transitions from
    not ready to ready, the kernel notifies you somehow.
  • AIO is normally used with edge-triggered completion notification, i.e. a
    signal is queued when the operation is complete.
  • on 2006-07-25 Zhesto
    It's time for web servers to handle ten thousand clients simultaneously, don't you think?
  • on 2006-07-25 Jcbuffington
    notes on how to configure operating systems and write code to support thousands of network clients
  • on 2006-10-25 Jkatzman
    interesting article on handling 10k clients