[squid-users] tcpkeepalive http_port directive

Amos Jeffries squid3 at treenet.co.nz
Wed Feb 17 21:49:11 UTC 2016


On 18/02/2016 9:00 a.m., Sebastien.Boulianne wrote:
> Hi all,
> 
> We host some online catalogs for a customers.
> The online catalogs are slow to answer to the http requests sometimes.
> 
> I would like to extend the timeout that Squid show us.
> 
> I checked in the http_port directive and I saw that
> tcpkeepalive[=idle,interval,timeout]
>                           Enable TCP keepalive probes of idle connections.
>                           In seconds; idle is the initial time before TCP starts
>                           probing the connection, interval how often to probe, and
>                           timeout the time before giving up.
> 
> How shoud I use it ?
> Just like
> http_port xx.xx.xx.xx:80 tcpkeepalive=60 accel defaultsite=... name=...
> 

It is a Linux feature. I'm not sure of other systems support it, but
they might do its quite old.

Setting it without any values uses the default TCP keepalive settings.
You can see what those are with:

 cat /proc/sys/net/ipv4/tcp_keepalive_time
 cat /proc/sys/net/ipv4/tcp_keepalive_intvl
 cat /proc/sys/net/ipv4/tcp_keepalive_probes

You can set those at the system level with sysctl. Or you an set the
values in squid.conf so they apply only client connections received at
that http_port.

In Squid you configure tcp_keepalive_time with 'idle',
tcp_keepalive_intvl with 'interval', and tcp_keepalive_probes is
calculated for you based on what you set for the timeout of a probe.


One gotcha that I am aware of is that there exists NAT systems with
shorter NAT mapping timeouts (approx. 30sec) than TCP normally uses
(approx. 1-5min). If you want to keep alive connections going through
such systems you need an idle value below their NAT timeout.

Amos



More information about the squid-users mailing list