9.14. Squid

Squid is a high-performance proxy caching server for web clients. What it actually does, is to try to prevent different users from fetching the same file several times, instead it keeps a copy of that file in it's cache, and the users get that copy instead. That is a lot faster than downloading the file every time, it's especially clear when you work with apt-get.

The squid server runs on the machine with the hostname webcache, which by default is the Main-server. Try to ping

ping -c4 webcache

and you will see which machine responds:
tjener:~# ping -c3 webcache
PING tjener.intern (10.0.2.2) 56(84) bytes of data.
64 bytes from tjener.intern (10.0.2.2): icmp_seq=1 ttl=64 time=0.117 ms
64 bytes from tjener.intern (10.0.2.2): icmp_seq=2 ttl=64 time=0.153 ms
64 bytes from tjener.intern (10.0.2.2): icmp_seq=3 ttl=64 time=0.126 ms

--- tjener.intern ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.117/0.132/0.153/0.015 ms
The most obvious thing to adjust when it comes to how the Squid server works out-of-the box, is the size of it's swapfiles. The default size is 100MB, while it's dedicated partition /var/spool/squid is in most cased far bigger than that. Like in this case
tjener:~# df -h /var/spool/squid/
Filesystem         	        Size  Used Avail Use% Mounted on
/dev/mapper/vg_system-lv_squid	469M   95M  349M  22% /var/spool/squid/
In this case it would make sense setting the swapfiles size to something near 469M, you achieve this by editing the line about number 699 in the file /etc/squid/squid.conf, remove the comment-sign # in front of the line, and adjust it to look like this, creating a 400M size for the swapfiles

cache_dir ufs /var/spool/squid 400 32 256
Once that is changed, you need to stop squid, and resize it's swapfiles, then start squid again.

/etc/init.d/squid stop
squid -z
/etc/init.d/squid start


tjener:~# /etc/init.d/squid stop
Stopping proxy server: (waiting....done) squid.
tjener:~# squid -z
2005/11/21 16:10:14| Creating Swap Directories
tjener:~# /etc/init.d/squid start
Starting proxy server: squid.