Hello!
On Mon, Nov 11, 2013 at 10:50 PM, microwish wrote:
>
> 1) "lua socket tcp connect timed out" is in nginx error log when
> set_keepalive function of lua-resty-memcached module is called;
>
If you use set_keepalive correctly, then there should be few connect()
requests. So the "lua socket tcp connect timed out" error is an
indication that you may not call set_keepalive in the right way. Will
you provide a minimal and complete example that can reproduce the
issue?
> 2) connect() function returns OK, while receive() function returns with
> error "failed to receive 1st line: timeout".
> That agrees with the first point.
This is a different error. It means that receive() timed out rather
than connect(). There are basically two possibilities:
1. your memcached server does not return the response within the
timeout limit you set (you can confirm this by using tools like
tcpdump or wireshark or systemtap-based tools).
2. nginx's event loop is blocked by something (you can check this by
using the epoll-loop-blocking-distr tool if you're on Linux:
https://github.com/agentzh/stapxx#epoll-loop-blocking-distr ).
> By ngx_lua source codes, I guess that connection's read event was
> triggered and finally ngx_http_lua_abort_pending_timers() was called;
>
Your guess here does not make any sense.
ngx_http_lua_abort_pending_timers() is completely unrelated.
> 3) The most weird is that, when I issued STATS command of memcached,
> curr_connections was only around 150 and listen_disabled_num was always 0.
I'd rather trust the outputs of kernel-level tools like tcp-accept-queue here:
https://github.com/agentzh/nginx-systemtap-toolkit#tcp-accept-queue
Best regards,
-agentzh