Thursday, October 27, 2011
1:18 PM

Tuning Up Squid

        
        
Specifying RAM Size 
To improve performance, squid can actually store objects directly to Main Memory (RAM) to serve them to clients. And even though the ‘space available’ is far lower compared to Secondary Storage Devices (Hard Disk), the ‘fetch time’ is significantly higher. As a result, a significant change of performance can be seen.


Step 1: Finding out the RAM usage


root@firefly:~# free -m

OR

root@firefly:~# top


Step 2: Allocating RAM
Always make sure to back up the configuration file before editing


root@firefly:~# vim /etc/squid/squid.conf
    cache_mem 128 MB
    maximum_object_size_in_memory 1 MB

The first option specifies that 128 MB from RAM would be used by squid for storing 'hot' objects. The second option states that the maximum size of a stored 'hot' object would be 1 MB, implying that maximum of 128 objects may be stored in the RAM.

NOTE: Please make sure that the allocated memory size is less than the specified disk cache size discussed in the next section.


Specifying the Disk Cache Size:

As we all know, squid places frequently accessed web elements into the hard disk. Although hard disks are much slower compared to RAM, they can provide significantly more space. The disk cache setting can be manipulated as shown below


root@firefly:~# vim /etc/squid/squid.conf


    # cache_dir ufs /var/spool/squid 100 16 256
    ### default settings.
    ### cache_dir filesystem location size_in_MB L1 L2
    ### L1: Number of parent directories
    ### L2: Number of sub-directories


    cache_dir ufs /var/spool/squid 256 16 256
    minimum_object_size 0 KB
    ### stores anything greater than 0 KB
    maximum_object_size 10 MB
    ### Maximum size of a stored object is 10MB


     cache_swap_low 90
     cache_swap_high 95

##squid will try to maintain cache size of 90% of
##allocated disk space. Whenever the size 
##exceeds 90%, some elements may be deleted. When 
##cache size exceeds 95%, deletion is much more 
##'aggressive' until lower limit (90%) is 
## achieved



http://www.packtpub.com/article/squid-proxy-server-fine-tuning-achieve-better-performance



0 comments:

Post a Comment