免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 10748 | 回复: 10
打印 上一主题 下一主题

[proxy] [寻求帮助] Squid 3 做web缓存.优化配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-12 19:44 |只看该作者 |倒序浏览
各位高手帮我看看我这是随便配的.性能也不知道好不好.

我硬件 E5420 x2 8G内存 SATA 硬盘
想要做web缓存.存图片 js css .网站是php程序.不知道怎么配置.各位帮帮忙了..

[root@host ~]# /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

论坛徽章:
0
2 [报告]
发表于 2009-01-12 19:45 |只看该作者
我现在的配置. 有多个域名.

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 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2009-01-12 20:04 |只看该作者
[root@host ~]# 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

论坛徽章:
0
4 [报告]
发表于 2009-01-12 20:05 |只看该作者
我用TOP 看squid 用了103M内存....好像很小呢

论坛徽章:
0
5 [报告]
发表于 2009-01-14 10:23 |只看该作者
minimum_object_size 102400 KB



maximum_object_size 1024 KB
你这明显有问题呀
最小的还比最大的值都大

论坛徽章:
0
6 [报告]
发表于 2009-01-14 12:22 |只看该作者
多谢提醒.我现在又重新配置了下. 参考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

论坛徽章:
0
7 [报告]
发表于 2009-01-14 12:25 |只看该作者
/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

论坛徽章:
0
8 [报告]
发表于 2009-01-14 23:05 |只看该作者
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%

前后变化还是很明显的

论坛徽章:
8
综合交流区版块每周发帖之星
日期:2015-12-02 15:03:53数据库技术版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-09-14 06:20:00金牛座
日期:2014-10-10 11:23:34CU十二周年纪念徽章
日期:2013-10-24 15:41:34酉鸡
日期:2013-10-19 10:17:1315-16赛季CBA联赛之北京
日期:2017-03-06 15:12:44
9 [报告]
发表于 2009-01-15 10:15 |只看该作者
内存大的话还是多起几个squi进程吧

论坛徽章:
17
2015年辞旧岁徽章
日期:2015-03-03 16:54:152017金鸡报晓
日期:2017-02-08 10:39:422017金鸡报晓
日期:2017-01-10 15:19:56JAVA
日期:2016-11-01 13:25:46C
日期:2016-10-25 16:01:4715-16赛季CBA联赛之八一
日期:2016-06-21 23:38:0815-16赛季CBA联赛之山东
日期:2016-05-12 12:49:54IT运维版块每日发帖之星
日期:2016-04-20 06:20:00IT运维版块每日发帖之星
日期:2016-03-22 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13IT运维版块每日发帖之星
日期:2015-08-25 06:20:002015亚冠之德黑兰石油
日期:2015-08-22 22:55:54
10 [报告]
发表于 2010-03-01 15:16 |只看该作者
回复 9# ruochen


    怎样多起几个squid进程呢?安装多个squid再启动?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP