Hello!
On Mon, May 12, 2014 at 11:07 AM, arthurx wrote:
> I am actually trying to connect to Elasticsearch, which has endpoint like
> this
>
> curl -XPOST "http://localhost:9200/sports/athlete/_search"
> -d '{ "query":{ "match_all":{} } }'
>
> The upstream blocks I mentioned is just the upstream declaraton in nginx
> conf
> upstream backenddb {
> 123.0.1.2:9200;
> keepalive 36;
> }
>
> And in order to access this endpoint in lua, I try to do
> ngx.location.capture on a location block that use this upstream.
Okay, then you don't need to use lua-resty-http at the same time :)
> Actually I am trying to debug some occasional lags I am experiencing. There
> are some lua-resty-http library that has the keep alive options, that's why
> I am trying to understand if keepalive in both context are relevant or not.
>
Both your nginx upstream module and lua-resty-http library are "TCP
clients". So they offer you the choice to use keepalive connections or
not. It is that simple :)
> Also I wonder if the backend need to support the keepalive function, maybe
> some databses or backend servers do not support persistent connection
> natively?
>
Yes, the backend server may not support (or be configured to support)
TCP connection reuse (that is, keepalive connections). For example,
some http servers are particularly configured to disable HTTP
keep-alive to save server-side resources.
Best regards,
-agentzh