Networking-Blog

My WordPress Blog

How To Increase Squid’s Cache Directory Swap Size

At times, granted a high-end server capacity and resources with large disk and memory capacity,
increase squid’s disk cache size is highly advisable. With higher disk cache size, you provide a higher
amount of disk space to be used by squid on caching web files
.

Increase Squid Cache Directory Swap Size

With default Squid rpm installation, the default value of squid cache directory swap size is set to 100MB.
Having a large disk storage would be efficient to store a larger directory swap size for squid to use.

Simply edit /etc/squid/squid.conf and find the cache directory squid directive

cache_dir ufs /var/spool/squid 100 16 256

/var/spool/squid is the directory folder location where squid will use to swap cached web files.

100 the first number is the amount of disk space in MB to be used by squid for caching directory.
16
is the number of first-level sub directories which will be created under the ‘Directory’.
256 is the number of second-level sub directories which will be created under each first-level directory.

To verify your disk and partition sizes, simply

# df -ah

giving you a similar lines

/dev/sda3              49G  4.5G   42G  10% /var
/dev/sda2             387G   18G  350G   5% /home
/dev/sda1              99M   12M   83M  13% /boot

From default squid installation, cache dir is physically dumped to /var directory by default.
Now, considering a server with high space, say 40GB free disk partition size, you could reconfigure
squid cache_dir to a value of

cache_dir ufs /var/spool/squid 2000 32 512

That is 2GB of cache directory for squid to use with 512 second-level directory under the first level of 32.

Save, exit and create the cache directory.

Stop Squid first

# service squid stop

Recreate Squid Cache Directory

# squid -z

Start Squid Service

# service squid start

This setup would nicely suit a large and regular internet user infrastructure setup.

All done.

Linux Squid and Dansguardian its slow

Months ago I’ve installed squid and dansguardian without a problems and worked perfect,
but week ago when the users navigate with their browsers its slow
.

I’ve changed some parameters in squid and dansguardian to solve the problem :

sudo vi /etc/squid/squid.conf

cache_dir ufs /var/spool/squid 2000 16 256
cache_mem 2000 MB
maximum_object_size 4096 KB

sudo vi /etc/ dansguardian/dansguardian.conf   ( Default Settings )

maxchildren = 120
minchildren = 8
minsparechildren = 4
preforkchildren = 6
maxsparechildren = 32
maxagechildren = 500

Right now the browsing is fast as I have done some changes
in the config file
:

maxchildren = 999
minchildren = 250
minsparechildren = 24
preforkchildren = 32
maxsparechildren = 64
maxagechildren = 10000

The following are the results I get after running

> # ps aux | grep dans
> 419 3049 0.0 11.3 127952 114912 ? Ss 16:44 0:00
> dansguardian-av -c /etc/dansguardian-av/dansguardian.conf
> 419 3050 0.0 11.3 127956 115024 ? S 16:44 0:00
> dansguardian-av -c /etc/dansguardian-av/dansguardian.conf
> 419 3051 0.0 11.3 132836 114964 ? S 16:44 0:00