個人心情和 Linux / FreeBSD 等技術

2007/05/05

squid 效能等注意事項!

關於 filesystem
  • Linux
    • Reiserfs
      • reiserfs3 works just fine, it's recommended that

      • you mount with noatime and notail options, and

      • for theperformance freaks put the journal on a

      • different spindle

    • ext3
      • another fine blend, the defaults filesystem
      • creation parameters are just good for squid
      • - watch out for the number of inodes - squid
      • cached objects are usually about 12-16 kb in
      • size, make sure you have enough.

    • ext2
      • well, ext2 is a venerable good filesystem. But
      • do youreally want to wait for hours while your
      • FS is being checked?

  • Solaris
    • UFS
      • UFS is the old Solaris File System, which good and stable.
      • Use "noatime" as mount option.

    • ZFS
      • Use ZFS, if you want really high performance for your
      • Squid Cache. ZFS is included in Solaris beginning with
      • Solaris 10.Release 6/06. Use "noatime" as mount option.
關於RAID
squid 對於 RAID 的擊中率特別的差勁 = =,尤其是 RAID
4 / 5簡單了說就是不建議使用 RAID

關於SMP
Squid is a single process application and can not make use of SMP

If you want to make Squid benefit from a SMP system you
will needto runmultiple instances of Squid and find a way to
distribute yourusers on thedifferent Squid instances just as
if you had multiple Squid boxes.

Having two CPUs is indeed nice for running other CPU
intensive tasks onthe same server as the proxy, such as if
you have a lot of logs and need torun various statistics
collections during peak hours.

The authentication and group helpers barely use any CPU
and does notbenefit from dual-CPU configuration

*大意是...squid這隻程式無法在多 cpu 的系統獲得更多好處
,但是多個cpu的確能夠讓 unix 系統在額外執行程式時更流暢...*

關於OS安裝

Running Squid on separate drives to that which your OS is
running is often a very good idea

*將OS和squid快取分開安裝在不同的disk上是不錯的*

Generally seek time is what you want to optimize for Squid,
or moreprecisely the total amount of seeks/s your system
can sustain.This is why it is better to have your cache_dir
spread over multiple smallerdisks than one huge drive
(especially with SCSI).

*把 cache_dir 分派在多個而容量較小的disk效能會勝過單一
容量大的硬碟*
ex: 單一2GB*5個會比單一10GB的要好

If your system is very I/O bound, you will want to have
both yourOS and log directories running on separate drives.

*系統I/O頻繁時最好把系統和 log 與 disk cache分開,另外
最好是一個partition 就只放一個 cache_dir *

如何找出在 cache 中最大的物件
# sort -r -n +4 -5 access.log | awk '{print $5, $7}' | head -25

如何把cache清除乾淨?

# squid -k shutdown
# echo . . > /cache1/swap.state (每個cache都要)

Squid.conf中cache_mem代表的是?

cache_mem不代表 squid 所使用記憶體的最大值,它只能表示
需要用多少記憶體留住 " hot " (點擊率高)的檔案。

Squid需要多少記憶體?
1GB的cache_dir大約佔用10MB的 ram ,但是在64位元的 server
上會更多

*簡言之,記憶體插曹插滿就對了 = =*

沒有多餘記憶體的話,要如何降低記憶體使用

1.使用不同的malloc library ,例如GNU malloc 或是 dlmalloc

2.降低 squid.conf 設定檔中 cache_mem 的量 (Reducing this
parameterwill not significantly affect performance, but you may
recieve somewarnings in cache.log if your cache is busy)

3. Turn the memory_pools off in the config file. This causes
Squid togive up unused memory by calling free() instead of
holding on to thechunk for potential, future use. Generally
speaking, this is a bad ideaas it will induce heap fragmentation.
Use memory_pools_limit instead.

4. 降低設定檔中的 cache_swap . This will reduce the number
of objectsSquid keeps. Your overall hit ratio may go down a little,
but your cache will perform significantly better.

*某些malloc不支援超過2GB的記憶體,包括dlmalloc,當記憶體
大於2GB時則只能使用到2GB*

參考資料
squid的wiki

沒有留言: