Keepalive not working with upstream tcp server

I am trying to use nginx to proxy my requests to a custom tcp backend
server that I have. I am following the same model as the default
memcached module with in the nginx code base (1.5.10) , the relevant
config file attached. Tried with most of the keepalive options but I
still see new connections getting created to upstream server. (rather I
do see the connection getting closed by nginx in strace)

Do I need to specifically compile nginx with http upstream keepalive
module, thought it was default enabled but the code doesn’t seem to go
through it looking in gdb. Is there any other specific module or setting
I need to use for the upstream tcp persistent connection usecase.

Thanks in advance,
Jayadev

— nginx.conf------

http {
default_type application/octet-stream;
keepalive_timeout 100;
proxy_http_version 1.1;

upstream my_backend {
server 127.0.0.1:1111;
keepalive 100;
}

server {
listen 4080;
keepalive_timeout 100;
keepalive_requests 100000;
proxy_http_version 1.1;
proxy_set_header Connection keepalive;

location / {
root html;
index index.html index.htm;
my_pass my_backend;
}
}

Hello!

On Wed, Apr 02, 2014 at 01:01:07AM -0700, Jayadev C wrote:

I am trying to use nginx to proxy my requests to a custom tcp
backend server that I have. I am following the same model as the
default memcached module with in the nginx code base (1.5.10) ,
the relevant config file attached. Tried with most of the
keepalive options but I still see new connections getting
created to upstream server. (rather I do see the connection
getting closed by nginx in strace)

[…]

my_pass my_backend;

Looks like you did something wrong in you module. Note that
memcached module explicitly sets u->keepalive when it’s ok to keep
a connection alive.


Maxim D.
http://nginx.org/

I am setting u->keepalive = 1 in my module too, but let me double check
that though.

Meanwhile , is the keepalive done by http_upstream_keepalive_module ? Is
it included by default or do I need to compile explicitly include that
module. I don’t see the code going through that module in my request
flow.

Jai

On Wednesday, April 2, 2014 7:53 AM, Maxim D. [email protected]
wrote:

Hello!

On Wed, Apr 02, 2014 at 01:01:07AM -0700, Jayadev C wrote:

I am trying to use nginx to proxy my requests to a custom tcp
backend server that I have. I am following the same model as the
default memcached module with in the nginx code base (1.5.10) ,
the relevant
config file attached. Tried with most of the
keepalive options but I still see new connections getting
created to upstream server. (rather I do see the connection
getting closed by nginx in strace)

[…]

my_pass my_backend;

Looks like you did something wrong in you module. Note that
memcached module explicitly sets u->keepalive when it’s ok to keep
a connection alive.


Maxim D.
http://nginx.org/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs