今天打开了 lighttpd 得 mod_status,发现居然 fd-Event-Handler 默认用的是 Poll,大吃了一惊。还以为他怎么也会根据平台使用 kqueue 呢。网上搜了一下,找到了配置的方法,不需要重新编译只需要在 conf 里面配置一下。
server.event-handler = “freebsd-kqueue”
当然还可以选择其他,详细的参考 lighttpd wiki 吧。
今天打开了 lighttpd 得 mod_status,发现居然 fd-Event-Handler 默认用的是 Poll,大吃了一惊。还以为他怎么也会根据平台使用 kqueue 呢。网上搜了一下,找到了配置的方法,不需要重新编译只需要在 conf 里面配置一下。
server.event-handler = “freebsd-kqueue”
当然还可以选择其他,详细的参考 lighttpd wiki 吧。
今天又重新读了 The C10K Problam,决定好好写份摘要记录下学到的内容。
文章主要探讨了如何配置操作系统或者编写相应的程序可以支持10K数量级以上的客户端。目前有不少IO框架可供选择使用,譬如重量级的ACE,轻量级的libevent等。
开发网络应用一般有一些好的I/O策略可以参考:
采用哪种通知机制非常关键,主要有两种readiness notification类型,基于level-triggered的方式有传统的select()和poll()系统调用,level-triggered针对file descriptors的condition改变进行通知,一旦condition出现变化,那么用select()系统调用会检测到。而edge-triggered这个概念在BSDCON 2000大会上关于kqueue()的论文里面由Jonathon Lemon提出的,和level-triggered不同的是,这种通知不取决于condition的改变,而是取决于事件源的活动。
下面是引自 Kqueue 这篇论文里面的说明:
Events will normally considered to be “level-triggered”, as opposed to “edge-triggered”. Another way of putting this is to say that an event is be reported as long as a specified condition holds, rather than when activity is actually detected from the event source. The given condition could be as simple as “there is unread data in the buffer”, or it could be more complex. This approach handles the scenario described above, and allows the application to perform a partial read on a buffer, yet still be notified of an event the next time it calls the API. This corresponds to the existing semantics provided by poll() and select().
Recent Comments