[squid-users] squid use only memory for cache

From: Chris Barnes <cpbarnes@dont-contact.us>
Date: 03 Oct 2003 01:53:22 +1000

hi people,
I remember a while back someone or some people were talking about making
squid use only memory to store its cache.

This was to make squid faster because memory speed is about 40 times
quicker than hard disk speed.

One of the problems was that the x86 platforms can only handle 4gigs of
memory or something?
And when the system reboots the cache is lost.

well I had a play around on my system (linux 2.4.21 on pentium4 1.8Ghz,
256Meg, 20gig) and I came up with an idea. I made a bunch of RAM Disks
under Linux, grouped them all together using software raid so that the
combined storage space of all ram disks was 64megs, formatted the RAM
Disk, and told squid to use the mounted RAM disk as the cache dir.

Its only a small cache compared to a cache normally found on a hard disk
but this is only a test. So far its working fine.

I came up with an idea to fix the reboot=cache lost problem.

a script could be written so then when squid is shutdown the contents of
the ramdisk are saved to a file using dd like so.

dd if=/dev/md0 of=cache.ext3 bs=8192

or dd if=/dev/ram0 of=cache.ext3 bs=8192 (if you dont have raided ram
disks)

then just before squid is started another script could be run which will
copy the cache.ext3 file back to the Ram Disk like so.

dd if=cache.ext3 of=/dev/md0 bs=8192

or dd if=cache.ext3 of=/dev/ram0

alternativly, if you dont want to use a bunch of ram disks raided
together, you could recompile your linux kernel so that the default ram
disk size is larger. The default is about 4megs i think, i changed mine
to 8megs, but i didn't see anything saying you couldn't have a 512meg
ram disk.

Anyway, thats just some food for thought. Let me know what you think
about that idea.

Regards,
Chris Barnes
Received on Thu Oct 02 2003 - 09:55:51 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:20:16 MST