[尋求幫助] Squid 3 做web緩存.優化配置
各位高手幫我看看我這是隨便配的.性能也不知道好不好.
我硬體 E5420 x2 8G內存 SATA 硬碟
想要做web緩存.存圖片 js css .網站是php程序.不知道怎麼配置.各位幫幫忙了..
# /usr/local/squid/bin/squidclient -p 80 mgr:info
HTTP/1.0 200 OK
Server: squid/3.0.STABLE9
Mime-Version: 1.0
Date: Mon, 12 Jan 2009 11:40:08 GMT
Content-Type: text/plain
Expires: Mon, 12 Jan 2009 11:40:08 GMT
Last-Modified: Mon, 12 Jan 2009 11:40:08 GMT
X-Cache: MISS from host.xxxxxxxxxxxn.com
Via: 1.0 host.xxxxxxxxxx.com (squid/3.0.STABLE9)
Connection: close
Squid Object Cache: Version 3.0.STABLE9
Start Time: Sat, 10 Jan 2009 03:35:14 GMT
Current Time: Mon, 12 Jan 2009 11:40:08 GMT
Connection information for squid:
Number of clients accessing cache: 622
Number of HTTP requests received: 413193
Number of ICP messages received: 0
Number of ICP messages sent: 0
Number of queued ICP replies: 0
Number of HTCP messages received: 0
Number of HTCP messages sent: 0
Request failure ratio: 0.00
Average HTTP requests per minute since start: 122.8
Average ICP messages per minute since start: 0.0
Select loop called: 380946691 times, 0.530 ms avg
Cache information for squid:
Hits as % of all requests: 5min: 12.6%, 60min: 10.2%
Hits as % of bytes sent: 5min: 8.2%, 60min: 6.1%
Memory hits as % of hit requests: 5min: 0.0%, 60min: 0.0%
Disk hits as % of hit requests: 5min: 53.4%, 60min: 54.3%
Storage Swap size: 68284 KB
Storage Swap capacity: 6.1% used, 93.9% free
Storage Mem size: 67456 KB
Storage Mem capacity: 6.4% used, 93.6% free
Mean Object Size: 7.12 KB
Requests given to unlinkd: 2750
Median Service Times (seconds) 5 min 60 min:
HTTP Requests (All): 0.00000 0.00000
Cache Misses: 0.00000 0.00000
Cache Hits: 0.00000 0.00000
Near Hits: 0.00000 0.00000
Not-Modified Replies: 0.00000 0.00000
DNS Lookups: 0.00000 0.00000
ICP Queries: 0.00000 0.00000
Resource usage for squid:
UP Time: 201893.898 seconds
CPU Time: 251.668 seconds
CPU Usage: 0.12%
CPU Usage, 5 minute avg: 0.17%
CPU Usage, 60 minute avg: 0.10%
Process Data Segment Size via sbrk(): 36648 KB
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
Total space in arena: 36920 KB
Ordinary blocks: 36905 KB 43 blks
Small blocks: 0 KB 0 blks
Holding blocks: 77380 KB 552 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 14 KB
Total in use: 114285 KB 100%
Total free: 14 KB 0%
Total size: 114300 KB
Memory accounted for:
Total accounted: 99739 KB 87%
memPool accounted: 99739 KB 87%
memPool unaccounted: 14560 KB 13%
memPoolAlloc calls: 108186275
memPoolFree calls: 107611093
File descriptor usage for squid:
Maximum number of file descriptors: 1024
Largest file desc currently in use: 115
Number of file desc currently in use: 57
Files queued for open: 0
Available number of file descriptors: 967
Reserved number of file descriptors: 100
Store Disk files open: 0
Internal Data Structures:
26398 StoreEntries
16811 StoreEntries with MemObjects
16809 Hot Object Cache Items
9587 on-disk objects
《解決方案》
我現在的配置. 有多個域名.
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow all
icp_access allow localnet
icp_access deny all
htcp_access allow localnet
htcp_access deny all
http_port 80 vhost vport
cache_peer 我的ip parent 8080 0 no-query originserver login=PASS name=name
cache_peer_domain xxx www.xxxx.com .xxx.com .124.com .1222.com .22222.com
hierarchy_stoplist cgi-bin ?
cache_mem 1024 MB
maximum_object_size_in_memory 250 KB
cache_dir ufs /usr/local/squid/var/cache 1100 16 256
minimum_object_size 102400 KB
maximum_object_size 1024 KB
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log none
cache_log none
cache_store_log none
emulate_httpd_log on
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern (cgi-bin|\?) 0 0% 0
refresh_pattern . 0 20% 4320
cache_mgr mail#mail.com
error_directory /usr/local/squid/share/errors/Simplify_Chinese
coredump_dir /usr/local/squid/var/cache
[ 本帖最後由 JackTon 於 2009-1-12 19:47 編輯 ]
《解決方案》
# ps aux |grep squid
root 10068 0.0 0.0 23204 1392 ? Ss Jan10 0:00 /usr/local/squid/sbin/squid -s
nobody 10070 0.1 1.4 139700 115744 ? S Jan10 4:13 (squid) -s
root 14949 0.0 0.0 61196 748 pts/0 S+ 20:03 0:00 grep squid
《解決方案》
我用TOP 看squid 用了103M內存....好像很小呢
《解決方案》
minimum_object_size 102400 KB
maximum_object_size 1024 KB
你這明顯有問題呀
最小的還比最大的值都大
《解決方案》
多謝提醒.我現在又重新配置了下. 參考linuxtone.org上的文章
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
acl PURGE method PURGE
http_access allow PURGE localhost
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow all
icp_access allow localnet
icp_access deny all
htcp_access allow localnet
htcp_access deny all
http_port 80 vhost vport
cache_peer 219.232.237.142 parent 8080 0 no-query originserver login=PASS name=name
cache_peer_domain name www.name.com .name.com .name1.cn .nam2.net .name3.cn .name4.cn
hierarchy_stoplist cgi-bin ? \.php
acl QUERY urlpath_regex cgi-bin\? \.php \.rar \.zip \.cgi \.avi \.wmv \.rm \.ram \.mpg \.mpeg \.zip \.exe
cache deny QUERY
cache_dir ufs /usr/local/squid/var/cache 10000 16 256
cache_mem 2048 MB
max_open_disk_fds 0
maximum_object_size 512 KB
maximum_object_size_in_memory 256 KB
memory_pools on
memory_pools_limit 64 MB
forwarded_for on
log_icp_queries off
via off
reply_header_access Server deny all
reply_header_access X-Cache deny all
reply_header_access Cache-Control deny all
reply_header_access age deny all
httpd_suppress_version_string off
ie_refresh off
tcp_recv_bufsize 32 KB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
memory_replacement_policy lru
hosts_file /etc/hosts
request_header_max_size 128 KB
access_log none
cache_log none
cache_store_log none
refresh_pattern ^ftp: 60 20% 10080
refresh_pattern ^gopher: 60 0% 1440
refresh_pattern . 0 20% 1440
refresh_pattern -i \.jpg$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.gif$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.swf$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.jpg$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.png$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.bmp$ 1440 50% 2880 ignore-reload
quick_abort_min 20 KB
quick_abort_max 20 KB
quick_abort_pct 95
connect_timeout 2 minute
negative_ttl 0 minutes
read_timeout 90 seconds
pconn_timeout 120 seconds
shutdown_lifetime 5 seconds
strip_query_terms off
icp_port 0
cache_mgr mail@mail.com
error_directory /usr/local/squid/share/errors/Simplify_Chinese
icon_directory /usr/local/squid/share/icons
mime_table /usr/local/squid/etc/mime.conf
coredump_dir /usr/local/squid/var/cache
store_objects_per_bucket 15
client_db off
《解決方案》
/usr/local/squid/bin/squidclient -p 80 mgr:info
HTTP/1.0 200 OK
Mime-Version: 1.0
Date: Wed, 14 Jan 2009 04:22:36 GMT
Content-Type: text/plain
Expires: Wed, 14 Jan 2009 04:22:36 GMT
Last-Modified: Wed, 14 Jan 2009 04:22:36 GMT
Connection: close
Squid Object Cache: Version 3.0.STABLE9
Start Time: Sat, 10 Jan 2009 03:35:14 GMT
Current Time: Wed, 14 Jan 2009 04:22:36 GMT
Connection information for squid:
Number of clients accessing cache: 169
Number of HTTP requests received: 755317
Number of ICP messages received: 0
Number of ICP messages sent: 0
Number of queued ICP replies: 0
Number of HTCP messages received: 0
Number of HTCP messages sent: 0
Request failure ratio: 0.00
Average HTTP requests per minute since start: 130.1
Average ICP messages per minute since start: 0.0
Select loop called: 592947505 times, 0.588 ms avg
Cache information for squid:
Hits as % of all requests: 5min: 43.7%, 60min: 53.4%
Hits as % of bytes sent: 5min: 26.3%, 60min: 24.1%
Memory hits as % of hit requests: 5min: 40.4%, 60min: 39.6%
Disk hits as % of hit requests: 5min: 19.5%, 60min: 7.7%
Storage Swap size: 142344 KB
Storage Swap capacity: 1.4% used, 98.6% free
Storage Mem size: 154792 KB
Storage Mem capacity: 7.4% used, 92.6% free
Mean Object Size: 7.42 KB
Requests given to unlinkd: 6016
Median Service Times (seconds) 5 min 60 min:
HTTP Requests (All): 0.00000 0.00000
Cache Misses: 0.00379 0.01235
Cache Hits: 0.00000 0.00000
Near Hits: 0.00000 0.00000
Not-Modified Replies: 0.00000 0.00000
DNS Lookups: 0.00000 0.00000
ICP Queries: 0.00000 0.00000
Resource usage for squid:
UP Time: 348441.987 seconds
CPU Time: 392.385 seconds
CPU Usage: 0.11%
CPU Usage, 5 minute avg: 0.11%
CPU Usage, 60 minute avg: 0.12%
Process Data Segment Size via sbrk(): 65700 KB
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
Total space in arena: 65972 KB
Ordinary blocks: 65951 KB 13 blks
Small blocks: 0 KB 0 blks
Holding blocks: 172360 KB 1243 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 20 KB
Total in use: 238311 KB 100%
Total free: 20 KB 0%
Total size: 238332 KB
Memory accounted for:
Total accounted: 212142 KB 89%
memPool accounted: 212142 KB 89%
memPool unaccounted: 26189 KB 11%
memPoolAlloc calls: 183375300
memPoolFree calls: 182295085
File descriptor usage for squid:
Maximum number of file descriptors: 1024
Largest file desc currently in use: 36
Number of file desc currently in use: 25
Files queued for open: 0
Available number of file descriptors: 999
Reserved number of file descriptors: 100
Store Disk files open: 0
Internal Data Structures:
39282 StoreEntries
29808 StoreEntries with MemObjects
29807 Hot Object Cache Items
19188 on-disk objects
《解決方案》
Cache information for squid:
Hits as % of all requests: 5min: 12.6%, 60min: 10.2%
Hits as % of bytes sent: 5min: 8.2%, 60min: 6.1%
Memory hits as % of hit requests: 5min: 0.0%, 60min: 0.0%
Disk hits as % of hit requests: 5min: 53.4%, 60min: 54.3%
Cache information for squid:
Hits as % of all requests: 5min: 43.7%, 60min: 53.4%
Hits as % of bytes sent: 5min: 26.3%, 60min: 24.1%
Memory hits as % of hit requests: 5min: 40.4%, 60min: 39.6%
Disk hits as % of hit requests: 5min: 19.5%, 60min: 7.7%
前後變化還是很明顯的
《解決方案》
內存大的話還是多起幾個squi進程吧
《解決方案》
回復 9# ruochen
怎樣多起幾個squid進程呢?安裝多個squid再啟動?