Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C: epoll and multithreading

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).

like image 953
Daniel Avatar asked Jan 14 '11 03:01

Daniel


People also ask

Is epoll multithreaded?

Yes, epoll is thread-safe. Yes, you can do it.

What is epoll in Linux?

epoll is a Linux kernel system call for a scalable I/O event notification mechanism, first introduced in version 2.5. 44 of the Linux kernel. Its function is to monitor multiple file descriptors to see whether I/O is possible on any of them.


1 Answers

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.

like image 175
Javier Avatar answered Sep 29 '22 23:09

Javier