This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Squid Memory and Caching Tweaks

Squid tends to be memory piggish as it likes to cache to ram.  I want squid to not only put all that cache to the hard disk i want large files.  Here is how you do it..[:)]

Login to your firewall using an ssh client using the "loginuser" ID.

Once logged in "su" to root...
ASL> su -
Password: 

Open the .conf file in "joe".
ASL> joe /var/chroot-squid/etc/squid.conf-default

cache_mem
This is a biggie.  It partially controls the maximum amount of ram used for the object cache.  This is not a hard limit though. Since I want my stuff cached to the hard disk and i want to minimize ram usage by squid i set this to zero.
Default cache_mem 8 MB

Default maximum_object_size 4096 KB
Objects larger than this size will NOT be saved on disk.  Make this as large as the largest file you want cached on the disk.  I would not make it larger than 25% of your total squid partition size.

maximum_object_size_in_memory (bytes)
Objects greater than this size will not be attempted to be kept in the memory cache.  Since we are loooking to minimize memory usage set this to zero.  If you have a tons of free ram then make this at most a meg in size.
Default maximum_object_size_in_memory 8 KB
--------------------------------------------------------------------------
in v6 it is a bit different
The same procedure applies BUT:
look for the following:
[] Objects greater than this size will not be attempted to be kept in the memory cache.  Since we are loooking to minimize memory usage set this to zero.  If you have a tons of free ram then make this at most a meg in size.

next find []  Objects larger than this size will NOT be saved on disk.  Make this as large as the largest file you want cached on the disk.  I would not make it larger than 25% of your total squid partition size.

finally find []
This is a biggie.  It partially controls the maximum amount of ram used for the object cache.  This is not a hard limit though. Since I want my stuff cached to the hard disk and i want to minimize ram usage by squid i set this to zero.

Here are my v6 settings:
maximum_object_size_in_memory 0 KB
maximum_object_size 250 MB
cache_mem 0 KB

Once you make the mods save the file and then stop the http proxy.  Wiat a few minutes and then restart it.  That will load the new squid configuration.


This thread was automatically locked due to age.
  • William, O wise and Grand Pooh-bah,
    what are the advantages and disadvantages of doing this besides reducing swap usage?

    Ian M [:)]
  • Hi,

    well you have less swapping, because Squid is using the harddisk for storage instead of memory, hmm. And you now have many many files on your /var/storage. Higher CPU load and more stress to the harddisk. 
    If you have some small line to the internet, it will for sure boost the speed of often visited sites.

    Chris
  • [ QUOTE ]
    Hi,

    well you have less swapping, because Squid is using the harddisk for storage instead of memory, hmm. And you now have many many files on your /var/storage. Higher CPU load and more stress to the harddisk. 
    If you have some small line to the internet, it will for sure boost the speed of often visited sites.

    Chris 

    [/ QUOTE ]
    The added usage to the harddisk is minimal.  I have been using this type on configuration for a year or two and have yet to kill a hard disk even with 10 users all at the same time using it.  The biggest advantage is you do not force the system into swapping which affects system performance much more negativly than shifting the cache to the hard disk.  I have not seen a detrimental effect to system performace by shifting the cache to the hard disk and out of ram. To the contrary, I have at least for me have increased my system's performance by leaving more ram available for things like IDS and accounting.   Again this is only optional, I am not saying anyone HAS to run this configuration.  This configuration works for me quite well and i provide it for the benefit of the Astaro community.

    Owner:  Emmanuel Technology Consulting

    http://etc-md.com

    Former Sophos SG(Astaro) advocate/researcher/Silver Partner

    PfSense w/Suricata, ntopng, 

    Other addons to follow

  • Dear Sirs,

    I agree with Chris that this configuration may exhauste the harddisk and CPU, but in the other hand it is very useful for poor internet connection also.

    The values for cache_mem is in MB while for the maximum size object and maximum size object in memory are in KB.

    Today I start the setting of Williams
    cache_mem 0 MB
    maximum_object_size 250000 KB
    maximum_object_size_in_memory 0 KB

    hearing from you soon.

    Ali Ismail
  • Wondering how many hours the cache will stay in the harddisk ?
  • [ QUOTE ]
    Wondering how many hours the cache will stay in the harddisk ? 

    [/ QUOTE ]
    You have to go look at squid-cache.org and see how the various aging types do it.  I have had things stay on for a week and stay as little as a couple hours.

    Owner:  Emmanuel Technology Consulting

    http://etc-md.com

    Former Sophos SG(Astaro) advocate/researcher/Silver Partner

    PfSense w/Suricata, ntopng, 

    Other addons to follow

  • [ QUOTE ]
    Dear Sirs,

    I agree with Chris that this configuration may exhauste the harddisk and CPU, but in the other hand it is very useful for poor internet connection also.

    The values for cache_mem is in MB while for the maximum size object and maximum size object in memory are in KB.

    Today I start the setting of Williams
    cache_mem 0 MB
    maximum_object_size 250000 KB
    maximum_object_size_in_memory 0 KB

    hearing from you soon.

    Ali Ismail 

    [/ QUOTE ]
    The hard disk is not going to get exhausted and give out sooner IME.  The hard disk is there for storage..why not use it?  Using the hard disk is NOT going to increase cpu usasge either AFAIK.

    Owner:  Emmanuel Technology Consulting

    http://etc-md.com

    Former Sophos SG(Astaro) advocate/researcher/Silver Partner

    PfSense w/Suricata, ntopng, 

    Other addons to follow

  • Hi,

    well the files still need to be processed by squid, keeping his tables up2date, removing to old files and so on, no 99% cpu load, but nothing to look over. Not the large files are the problem, but the million small ones. 
    Guess a better solution would be some old box, where you can put in some ide raid controller with raid 0 over 2 or more disks. 
    And you can mess around with him, without loosing astaro warranty  [;)].

    Chris
  • [ QUOTE ]
    Hi,

    well the files still need to be processed by squid, keeping his tables up2date, removing to old files and so on, no 99% cpu load, but nothing to look over. Not the large files are the problem, but the million small ones. 
    Guess a better solution would be some old box, where you can put in some ide raid controller with raid 0 over 2 or more disks. 
    And you can mess around with him, without loosing astaro warranty  [;)].

    Chris 

    [/ QUOTE ]
    I am seeing no performance issues.  My cpu load stays well below .5 during the day and only spikes to 1-2 during log rotations and accounting calculations.

    Owner:  Emmanuel Technology Consulting

    http://etc-md.com

    Former Sophos SG(Astaro) advocate/researcher/Silver Partner

    PfSense w/Suricata, ntopng, 

    Other addons to follow

  • Dear Friends,

    I just installed the ASL 6, and when I try to tune the cache, I found the 3 parameters empty ?

    Should I reinstall or upgrade ??

    Thanks