User Tools

Site Tools


pfsense:squid:local_cache

This is an old revision of the document!


PFSense - Squid - Local Cache

Squid Cache General Settings

Cache Replacement PolicyHeap LFUDA
Low-Water Mark in %90
High-Water Mark in %95

Squid Hard Disk Cache Settings

Hard Disk Cache Size50000
Hard Disk Cache Systemaufs
Level 1 Directories128
Hard Disk Cache Location/var/squid/cache
Minimum Object Size0
Maximum Object Size2048

Squid Memory Cache Settings

Memory Cache Size 4096
Maximum Object Size in RAM 1024
Memory Replacement Policy Heap GDSF

Memory Replacement Policy

Cache Dynamic ContentChecked - Select to enable caching of dynamic content

cache_mem

This is one of the top two options as far as performance impact goes.

The default value here is 8 MB, which is a safe option for just about any system size.

But since your box is not lacking in memory it can safely be raised to 32 MB, and even 48 if you have stripped all other services off of your server.

If your box is lacking in memory, go back to the hardware section and reread the part about memory…you need a bunch of memory for a fast web cache.

You should be aware that cache_mem does not limit the process size of squid. This sets how much memory squid is allowed to set aside for “hot objects” which are the most recently used objects.

Having said all that, keep in mind that the buffer cache in Linux is also quite good, so the gains you'll see by raising this are very small, but still measurable.


cache_dir

This is where you set the directories you will be using.

You should have already mkreiserfs'd your cache directory partitions, so you'll have an easy time deciding the values here.

First, you will want to use about 80% or less of each cache directory for the web cache.

If you use any more than that you will begin to see a slight degradation in performance.

Remember that cache size is not as important as cache speed, since for maximum effectiveness your cache needs only store about a weeks worth of traffic.

You'll also need to define the number of directories and sub-directories. The formula for deciding that is this:

x=Size of cache dir in KB (i.e. 6GB=~6,000,000KB) 
y=Average object size (just use 13KB)
z=Number of directories per first level directory (((x / y) / 256) / 256) * 2 = # of directories

As an example, if 6GB of the drives is used, so:

6,000,000 / 13 = 461538.5 / 256 = 1802.9 / 256 = 7 * 2 = 14

So my cache_dir line would look like this: cache_dir 6000 14 256
pfsense/squid/local_cache.1584215363.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki