Re: Connections to backend not closing

2010-02-10 Thread Poul-Henning Kamp
In message <4b71f7a0.2050...@digithi.de>, "Thimo E." writes:
>Dear all,
>
>first of all, varnish is a really nice software! But... :)
>...At the moment I have some problems with varnish and its backend 
>connection(s).
>
>[..]
>
>Some time later (at least 5 minutes !) the last entry "CLOSE_WAIT" 
>disappears but the "FIN_WAIT2" persists, so the webserver still has a 
>semi-open socket:

This is actually per design, varnish keeps backend connections around
if they look like they can be reused, and only revisits them when it
tries to reuse them, so they may linger for quite a while before
varnish discovers they have been closed by the backend.

Apart from the socket hanging around, it is harmless.


-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
p...@freebsd.org | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Connections to backend not closing

2010-02-10 Thread Thimo E.
Hello Poul-Henning,

thanks for your quick response. I am not sure that this behavour is 
really harmless, at least its not for me :)

After 1 day running varnish I have 140 sockets of the backend webserver 
in FIN_WAIT2 state, this is quite a lot.
(btw; I don't know why FIN_WAIT2 sockets stay for such a long time in 
that state and don't time out...)

With a litte bit more semi-open connections I can get my backend to a 
state where stops responsing because of "Too many open connections" (I 
think 256 connections is the limit at the moment). As you can imagine 
that is quote annoying :)

Is there any possibility to say varnish to close "CLOSE_WAIT" 
connections immediately ? Or do you have other ideas ?

Thanks in advance
   Thimo

Am 10.02.2010 11:04, schrieb Poul-Henning Kamp:
> In message<4b71f7a0.2050...@digithi.de>, "Thimo E." writes:
>
>> Dear all,
>>
>> first of all, varnish is a really nice software! But... :)
>> ...At the moment I have some problems with varnish and its backend
>> connection(s).
>>
>> [..]
>>
>> Some time later (at least 5 minutes !) the last entry "CLOSE_WAIT"
>> disappears but the "FIN_WAIT2" persists, so the webserver still has a
>> semi-open socket:
>>  
> This is actually per design, varnish keeps backend connections around
> if they look like they can be reused, and only revisits them when it
> tries to reuse them, so they may linger for quite a while before
> varnish discovers they have been closed by the backend.
>
> Apart from the socket hanging around, it is harmless.
>
>
>

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Connections to backend not closing

2010-02-10 Thread Michael Fischer
On Wed, Feb 10, 2010 at 4:17 PM, Thimo E.  wrote:

> After 1 day running varnish I have 140 sockets of the backend webserver
> in FIN_WAIT2 state, this is quite a lot.


I'm why do you believe this is "a lot"?  Do you have evidence that this is
causing your server to behave suboptimally?  The impact should be no more
than a bit of RAM.

--Michael
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Connections to backend not closing

2010-02-11 Thread Poul-Henning Kamp
In message , Micha
el Fischer writes:
>--000e0cd2978a506e4c047f483f78

>> After 1 day running varnish I have 140 sockets of the backend webserver
>> in FIN_WAIT2 state, this is quite a lot.

Well, yes and no.

The normal finwait2 timeout is on the order of most of a day, 60.000
seconds on FreeBSD for instance, so 140 is probably no more than
one socket every ten minutes or so.

If you look in varnishstat, does the number correlate to the 
"Backend Conn." activity counters in any way ?

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
p...@freebsd.org | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Connections to backend not closing

2010-02-11 Thread Thimo E.
Hello Poul, hello Michael,

 >The impact [of sockets in FIN_WAIT2] should be no more than a bit of RAM.
I disagree slightly :) The application which is waiting in FIN_WAIT2 has 
allocated structures, threads which (may or may not) consume CPU time, 
... and last but not least the value of max opened sockets will be 
reduced by those dead sockets.
And..as I wrote already..due to that many opened sockets my backend 
stops responding because of "Too many open connections".


Situation after 2 days running varnish:

netstat -p:
520 connections in FIN_WAIT2 state

varnishstat:
...
  438 0.00 0.01 Backend conn. reuses
  547 0.00 0.01 Backend conn. was closed
  988 0.00 0.02 Backend conn. recycles
...

>If you look in varnishstat, does the number correlate to the
>"Backend Conn." activity counters in any way ?

Poul, the 547 closed backend connections are quite near to 520 FIN_WAIT2 
connections.

Any suggestions ?

Greets
   Thimo

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Connections to backend not closing

2010-02-12 Thread Laurence Rowe
On 12 February 2010 00:12, Thimo E.  wrote:
> Hello Poul, hello Michael,
>
>  >The impact [of sockets in FIN_WAIT2] should be no more than a bit of RAM.
> I disagree slightly :) The application which is waiting in FIN_WAIT2 has
> allocated structures, threads which (may or may not) consume CPU time,
> ... and last but not least the value of max opened sockets will be
> reduced by those dead sockets.
> And..as I wrote already..due to that many opened sockets my backend
> stops responding because of "Too many open connections".
>
>
> Situation after 2 days running varnish:
>
> netstat -p:
> 520 connections in FIN_WAIT2 state
>
> varnishstat:
> ...
>          438         0.00         0.01 Backend conn. reuses
>          547         0.00         0.01 Backend conn. was closed
>          988         0.00         0.02 Backend conn. recycles
> ...
>
>>If you look in varnishstat, does the number correlate to the
>>"Backend Conn." activity counters in any way ?
>
> Poul, the 547 closed backend connections are quite near to 520 FIN_WAIT2
> connections.
>
> Any suggestions ?

You might want to increase the ulimit -n for your backend server
process. With nginx set up as a proxy, each open connection consumed 4
file descriptors. (The default is normally 1024).

Laurence
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc