本文介绍了C: epoll 和多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建专门的 HTTP 服务器,为此我计划使用 epoll sycall,但我想利用多个处理器/内核,我无法提出架构解决方案.ATM 我的想法是:用自己的 epoll 描述符创建多个线程,主线程接受连接并在线程 epoll 之间分配它们.但是有没有更好的解决方案?我可以阅读哪些关于高负载架构的书籍/文章/指南?我只看过 C10K 文章,但大多数示例链接都已失效:( 仍然没有-关于这个主题的深入书籍:(.

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 :(.

感谢您的回答.

UPD:请说的更具体一些,我需要材料和例子(nginx 不是例子,因为它太复杂并且有多个抽象层来支持多个系统).

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

推荐答案

检查 libeventlibev 来源.它们具有很高的可读性,并且已经是一个很好的基础设施.

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

此外,libev 的文档中提供了大量经过验证的真实策略示例.即使您更喜欢直接编写 epoll(),这些示例也可以带来一些见解.

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.

这篇关于C: epoll 和多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 19:08