C: epoll and multithreading

Daniel picture Daniel · Jan 14, 2011 · Viewed 12.7k times · Source

I need to create specialized HTTP server, for this I plan to use epoll sycall, but I want to utilize multiple processors/cores and I can't come up with architecture solution. ATM my idea is followng: create multiple threads with own epoll descriptors, main thread accepts connections and distributes them among threads epoll. But are there any better solutions? Which books/articles/guides can I read on high load architectures? I've seen only C10K article, but most links to examples are dead :( and still no in-depth books on this subject :(.

Thank you for answers.

UPD: Please be more specific, I need materials and examples (nginx is not an example because its too complex and has multiple abstraction layers to support multiple systems).

Answer

Javier picture Javier · Jan 14, 2011

check libevent and libev sources. they're highly readable, and already a good infrastructure to use.

Also, libev's documentation has plenty of examples of several tried and true strategies. Even if you prefer to write directly to epoll(), the examples can lead to several insights.