Check out my first novel, midnight's simulacra!

Fast UNIX Servers: Difference between revisions

From dankwiki
No edit summary
No edit summary
Line 16: Line 16:


===Multithreading Event Cores===
===Multithreading Event Cores===
We must mix and match:
* Many event sources, of multiple types:
** Socket descriptors, pipes
** File descriptors referring to actual files (these usually have different blocking semantics)
** Signals, perhaps being used for asynchronous I/O with descriptors (<tt>[[Linux APIs|signalfd(2)]]</tt> on Linux unifies these with socket descriptors; <tt>kqueue</tt> supports <tt>EVFILT_SIGNAL</tt> events)
** Timers (<tt>[[Linux APIs|timerfd(2)]]</tt> on Linux unifies these with socket descriptors; <tt>kqueue</tt> supports EVFILT_TIMER</tt> events)
** [[Pthreads|Condition variables]] becoming available
* One or more event notifiers (<tt>epoll</tt> or <tt>kqueue</tt> fd)
* One or more event vectors, into which notifiers dump events
** <tt>kqueue</tt> supports vectorized registration of event changes, extending the issue
* Threads

Revision as of 01:58, 25 June 2009

Everyone ought start with Dan Kegel's classic site, "The C10K Problem" (still updated from time to time). Jeff Darcy's "High-Performance Server Architecture" is much of the same. Everything here is advanced followup material to these excellent works, and of course the books of W. Richard Stevens.

Queueing Theory

Event Cores

Multithreading Event Cores

We must mix and match:

  • Many event sources, of multiple types:
    • Socket descriptors, pipes
    • File descriptors referring to actual files (these usually have different blocking semantics)
    • Signals, perhaps being used for asynchronous I/O with descriptors (signalfd(2) on Linux unifies these with socket descriptors; kqueue supports EVFILT_SIGNAL events)
    • Timers (timerfd(2) on Linux unifies these with socket descriptors; kqueue supports EVFILT_TIMER events)
    • Condition variables becoming available
  • One or more event notifiers (epoll or kqueue fd)
  • One or more event vectors, into which notifiers dump events
    • kqueue supports vectorized registration of event changes, extending the issue
  • Threads