Date: Fri, 19 Aug 2011 13:33:25 +0300 From: about bus <aboutbus@gmail.com> To: freebsd-hackers@freebsd.org Subject: Kqueue + Libevent Message-ID: <CAPgCMdUW4pQcq1m93npCiyN7g4vXeGt_oQuMsUrBcOF8o4KuEw@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello! I've got some interesting problem with my own server which use Libevent and Kqueue. Kqueue holds some sockets for a long time (while reading data) and gives it back to application when another side closes connection. I have server with FreeBSD 7.2 which serves several thousands requests per second. Nginx -> statical requests, images -> backend for dynamical requests: Libevent based http server written on C Sometimes, about 0.1% of request, Nginx displays error: "Operation timed out while reading response from upstream." Switching Libevent from Kqueue to Poll in my http server fixes the problem. Poll works fine without errors in Nginx log file. Debug output for timeouted requests from Libevent: 1) Libevent accepts incoming connection from Nginx. 2) Libevent adds socket to Kqueue for waiting incoming data with HTTP request. 3) No events on socket for 60 seconds, no received data. (60 - timeout value in Nginx config) 4) On the another side Nginx closes connection and displays timeout error. 5) At the same time Kqueue reports about incoming data and returns socket to Libevent. 6) Libevent reads correct HTTP request from socket and passes it to my handler. Why Kqueue does not reports about read event for so long time? Why Kqueue do it only when another side closes connection? It is strange, because Poll does not have such problems.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPgCMdUW4pQcq1m93npCiyN7g4vXeGt_oQuMsUrBcOF8o4KuEw>