[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] libevent http and lost requests



Hello!

I have a simple my own libevent-based http server written on C, use evhttp.h functions.
I use it like backend with nginx server (about ~2K requests per second).
Sometimes in nginx error log appears error: "(60: Operation timed out) while reading response header from upstream"
Timeout value is 75 seconds in nginx config file, but my http server does not need so long time to handle one request.
Average request time is about 0.01 second (information from nginx access log).

I've used tcpdump to figure out what's going wrong.
There is a network activity on timeouted requests:

nginx -> syn > httpserver
httpserver -> syn-ack > nginx
nginx -> ack > httpserver
nginx -> GET /query/xxx/yyy > httpserver
httpserver -> ack > nginx
...
75 seconds left (timeout)
...
nginx -> fin > httpserver
httpserver -> ack > nginx

Only after this time (75 seconds) libevent calls my http_handler callback.
Message about new http request appears in http server log file.
After less than one second http server ready to send response back to nginx.
But 75 seconds were lost I don't know where, and connection where closed.

So, how I can figure out why libevent holds request for 75 seconds?
Why libevent gives request for handling only when nginx tries to close connection to my http server?

Thanks!