Saturday, October 30, 2010

Multicore support for lophttpd

lophttpd (in version 0.86), which is my private research
project for high performance web servers, now comes
with support for multiple cores (Linux only for now).
Unless specified otherwise, one thread per CPU core sleeps
in a accept() loop. Increasing load of the cores will then
result in more and more connections passed to the accept()
sleeping on yet unused cores.
This works since the kernel wakeup's all threads sleeping
in the accept() but only one will actually get the
connection (all others get EAGAIN).
In OS engineering this is known as the thundering herd problem
if you have thousands of processes woken up at once.
However this does not apply here since the number of cores
is small compared to what would "thunder a herd".
So basically we take the good parts of that "problem" but do not
run into the problem itself.


If it turns out to work well, I will also add multicore
support to sshttp. And it is by far more fun to code it
than the OS classes at university discovering scheduling theoretically.

3 comments:

Anonymous said...

I don't think that thundering herd would be a problem from the performance's point of view even with more processors. AFAIK accept can return EAGAIN only in the case there are no acceptable connections. That means there is little activity at the moment. It just adds a little latency. But in the case of high load it should work as expected (without spurious EAGAIN wakeups).

nick black said...

Might I recommend your taking a look at my (open-source) libtorque library? My masters thesis at Georgia Tech considered these issues in great detail -- check out my paper (linked from the page).

Icke said...

sure. thx, I will have a look