5. DISK IO相关的优化 5.1 cache_dir设置的考虑
· cache_dir采用二级目录方式保存cache object,做配置时不宜过大,建议为规划容量的1倍,否则建立swap目录会花费较多时间。推荐保留10%的空间。这些额外的空间用于存放squid的swap.state文件和临时文件。
· 可以配置多个cache_dir,建议每个cache_dir都放在不同的物理硬盘上,以改善IO效率 5.2 squid相关的目录设置
· log和cahce_dir不要放在一个物理盘上
· cache_dir所在的盘建议使用ReiserFS格式
· mount cache_dir盘时建议使用noatime参数 5.3 DISK Cache的相关设置
· max_open_disk_fds
This directive defines an upper limit on the number of file descriptors that Squid should open for reading and writing cache files on disk. 当达到这个限制后,squid会跳过DISK cache,从而避免IO持续恶化。
缺省为0(无限制)。[建议]For a single disk cache, 900 is a good choice. For a dual disk cache, try 1400.
· max_filedescriptors
允许打开的最大文件描述符,实际允许打开的数量也受编译squid的--with-maxfd的影响。缺省为0。[建议]
· maximum_object_size
maximum_object_size 1024 KB
· cache_swap_low/cache_swap_high ??? 5.4 Linux设置
· filedescriptors
一共有两个方面的限制: 整个系统,当前用户。
http://prefetch.net/blog/index.php/2009/07/31/increasing-the-number-of-available-file-descriptors-on-centos-and-fedora-linux-servers/ 整个系统:
动态调整,每次启动后该设置会丢失:
#ulimit -HSn 4096
在/etc/sysctl.confg中设置:
# vi /etc/sysctl.conf
fs.file-max = 100000
# sysctl -p
[ulimit显示的值和/proc/sys/fs/file-max中显示的值有什么关系]
ulimit command provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command
#vi /etc/security/limits.conf单个用户
* - nofile 8192
6. MEM优化考虑
· cache_mem
Squid占用内存量似乎不受这个参数的控制,此参数不必设得太大,适量就行。服务器:cache_mem 100 MB
· maximum_object_size_in_memory:
设置较小的maximum_object_size_in_memory值有助于有效控制squid过度占用内存
· client_db off
· The ratio of memory-to-disk can be important. We recommend that you have at least 32 MB of RAM for each GB of disk space that you plan to use for caching. 7. CPU优化相关
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 need to run multiple instances of Squid and find a way to distribute your users on the different Squid instances just as if you had multiple Squid boxes.