09.05.2014 Views

Advanced Disk Cache Topics

Advanced Disk Cache Topics

Advanced Disk Cache Topics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Filesystem Tuning Options<br />

First of all, you should never use RAID for Squid cache directories. In my experience,<br />

RAID always degrades filesystem performance for Squid. It is much better to<br />

have a number of separate filesystems, each dedicated to a single disk drive.<br />

I have found four simple ways to improve UFS performance for Squid. Some of these<br />

are specific to certain operating systems, such as BSD and Linux, and may not be<br />

available on your platform:<br />

• Some UFS implementations support a noatime mount option. Filesystems<br />

mounted with noatime don’t update the inode access time value for reads. The<br />

easiest way to use this option is to add it to the /etc/fstab like this:<br />

# Device Mountpoint FStype Options Dump Pass#<br />

/dev/ad1s1c /cache0 ufs rw,noatime 0 0<br />

• Check your mount(8) manpage for the async option. With this option set, certain<br />

I/O operations (such as directory updates) may be performed asynchronously.<br />

The documentation for some systems notes that it is a dangerous flag.<br />

Should your system crash, you may lose the entire filesystem. For many installations,<br />

the performance improvement is worth the risk. You should use this<br />

option only if you don’t mind losing the contents of your entire cache. If the<br />

cached data is very valuable, the async option is probably not for you.<br />

• BSD has a feature called soft updates. Soft updates are BSD’s alternative to journaling<br />

filesystems. * On FreeBSD, you can enable this option on an unmounted<br />

filesystem with the tunefs command:<br />

# umount /cache0<br />

# tunefs -n enable /cache0<br />

# mount /cache0<br />

You only have to run the tunefs once for each filesystem. Soft updates are automatically<br />

enabled on the filesystem again when your system reboots.<br />

On OpenBSD and NetBSD, you can use the softdep mount option:<br />

# Device Mountpoint FStype Options Dump Pass#<br />

/dev/sd0f /usr ffs rw,softdep 1 2<br />

If you’re like me, you’re probably wondering what the difference is between the<br />

async option and soft updates. One important difference is that soft update code has<br />

been designed to maintain filesystem consistency in the event of a system crash,<br />

while the async option has not. This might lead you to conclude that async performs<br />

better than soft updates. However, as I show in Appendix D, the opposite is true.<br />

* For further information, please see “Soft Updates: A Technique for Eliminating Most Synchronous Writes<br />

in the Fast File System” by Marshall Kirk McKusik and Gregory R. Ganger. Proceedings of the 1999 USENIX<br />

Annual Technical Conference, June 6–11, 1999, Monterey, California.<br />

110 | Chapter 8: <strong>Advanced</strong> <strong>Disk</strong> <strong>Cache</strong> <strong>Topics</strong><br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2004 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!