免费注册 查看新帖 |

Chinaunix

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

[proxy] squid缓存大文件,命中率非常低,请高手帮忙 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-09 10:08 |只看该作者 |倒序浏览
本人有个问题想请教各位高手,我用squid2.6,给一台下载服务器做缓存,下载服务器上面都是一些比较大的文件,但squid命中率特别低,想问一下具体是什么原因,还有squid如果缓存比较大的文件是不是还需要什么其它的设置,然后大家给于帮助,多谢了以下是我的配置文件,先贴出来

http_port 80 vhost vport
icp_port 3130
cache_mem 3072 MB
cache_effective_user squid
cache_effective_group squid
cache_log /squid/cache.log
visible_hostname 10.10.168.13
acl all src 0.0.0.0/0.0.0.0
http_access allow all

refresh_pattern .  0    50%     4320 ignore-reload
memory_pools on
forwarded_for on

maximum_object_size_in_memory 8000 KB
cache_dir aufs /cache1 8000 16 256
cache_dir aufs /cache2 8000 16 256
cache_dir aufs /cache3 8000 16 256
                                                         
                                                                                                                  
cache_swap_log /squid/cache_swap_log                                                                              
                                                                                                                  
memory_replacement_policy lru                                                                                    
max_open_disk_fds 0                                                                                               
minimum_object_size 0 KB                                                                                          
maximum_object_size 32768 KB                                                                                      
cache_store_log none      



请大家帮我看下具体有没有什么需要设置和改动的

以下是查看命中率结果:
Squid Object Cache: Version 2.6.STABLE23
Start Time:     Wed, 09 Dec 2009 02:05:57 GMT
Current Time:   Wed, 09 Dec 2009 02:07:30 GMT
Connection information for squid:
        Number of clients accessing cache:      1674
        Number of HTTP requests received:       8752
        Number of ICP messages received:        0
        Number of ICP messages sent:    0
        Number of queued ICP replies:   0
        Request failure ratio:   0.00
        Average HTTP requests per minute since start:   5643.2
        Average ICP messages per minute since start:    0.0
        Select loop called: 372641 times, 0.250 ms avg
Cache information for squid:
        Request Hit Ratios:     5min: 0.0%, 60min: 0.0%
        Byte Hit Ratios:        5min: -31.4%, 60min: -31.4%
        Request Memory Hit Ratios:      5min: 50.0%, 60min: 50.0%
        Request Disk Hit Ratios:        5min: 0.0%, 60min: 0.0%
        Storage Swap size:      1828 KB
        Storage Mem size:       119892 KB
        Mean Object Size:       457.00 KB
        Requests given to unlinkd:      0
Median Service Times (seconds)  5 min    60 min:
        HTTP Requests (All):   7.79421  7.79421
        Cache Misses:          7.79421  7.79421
        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:        93.054 seconds
        CPU Time:       15.451 seconds
        CPU Usage:      16.60%
        CPU Usage, 5 minute avg:        15.24%
        CPU Usage, 60 minute avg:       15.24%
        Process Data Segment Size via sbrk(): 249252 KB
        Maximum Resident Size: 0 KB
        Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
        Total space in arena:  249252 KB
        Ordinary blocks:       239676 KB   3766 blks
        Small blocks:               0 KB      0 blks
        Holding blocks:         27724 KB      3 blks
        Free Small blocks:          0 KB
        Free Ordinary blocks:    9575 KB
        Total in use:          267400 KB 97%
        Total free:              9575 KB 3%
        Total size:            276976 KB
Memory accounted for:
        Total accounted:       228365 KB
        memPoolAlloc calls: 2090432
        memPoolFree calls: 1688061
File descriptor usage for squid:
        Maximum number of file descriptors:   81920
        Largest file desc currently in use:   11400
        Number of file desc currently in use: 11370
        Files queued for open:                   0
        Available number of file descriptors: 70550
        Reserved number of file descriptors:   100
        Store Disk files open:                   7
        IO loop method:                     epoll
Internal Data Structures:
          5448 StoreEntries
          5448 StoreEntries with MemObjects
            76 Hot Object Cache Items
             4 on-disk objects

论坛徽章:
0
2 [报告]
发表于 2009-12-09 12:02 |只看该作者
Mean Object Size:       457.00 KB
你说说大文件下载可是在内存里的平均值只有457 KB
Internal Data Structures:
          5448 StoreEntries
          5448 StoreEntries with MemObjects
            76 Hot Object Cache Items
有5448个文件存储着但是只有76个是热点
我记得还有一个参数是影响到多线程下载命中率的,找到了给你发上来

论坛徽章:
0
3 [报告]
发表于 2009-12-09 13:30 |只看该作者
好的,多谢了,我真的很急,

论坛徽章:
0
4 [报告]
发表于 2009-12-09 13:32 |只看该作者
你的max_object也许小了,作为大文件下载
maximum_object_size 32768 KB

看看range 也许可以帮到你
http://blog.akaka.com.cn/2007/09/squid-range_offset_limit.html

论坛徽章:
0
5 [报告]
发表于 2009-12-10 09:51 |只看该作者
那个文章我看了加了一个参数,range_offset_limit -1,maximum_object_size 60 MB   也已经改大了。                                   
但是效果不大,命中率还是很低啊,有没有什么办法解决,还有我这几台机器的磁盘IO已经非常大了,这个有没有更好 的办法

论坛徽章:
0
6 [报告]
发表于 2009-12-10 10:32 |只看该作者
你给的资料还不够多,最好是硬件信息、系统信息、负载信息都贴出来,还有网络连接情况、你日常分发的文件大小,信息要充分大家才好帮你,还有你做配置改动的时候不要一次改多个,最好是改一个收集一段时间info再改。对下载分发没什么经验,不过据说用同步分发的方式再用lighttpd做下载效率高,一台服务器可以跑到近G的流量

论坛徽章:
0
7 [报告]
发表于 2009-12-10 10:58 |只看该作者
硬件信息:hp dl360g5   内存8G,双核双至强1.6G,scsi硬盘146G。
系统信息:
load average: 1.85, 1.37, 1.16
vmstat 1
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
3  0   6508 635584  90764 610220   12    8    13    21  124  111  2  2 95  0  0
2  0   6508 645836  90764 610264    0    0     0   872 14787 12968 11 16 73  0  0
3  0   6508 636700  90764 610300    0    0     0     0 14114 9479 17 16 67  0  0
3  0   6508 646500  90764 609996    0    0     0     0 14770 14637  8 13 79  0  0


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          13.96    0.00   14.51    0.05    0.00   71.49

Device:         rrqm/s   wrqm/s   r/s   w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util
cciss/c0d0        0.00    31.80  0.00  8.00     0.00     0.16    39.80     0.02    2.45   0.27   0.22
cciss/c0d0p1
               0.00     1.20  0.00  0.40     0.00     0.01    32.00     0.00    0.00   0.00   0.00
cciss/c0d0p2
               0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
cciss/c0d0p3
               0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
cciss/c0d0p5
               0.00    30.60  0.00  7.60     0.00     0.15    40.21     0.02    2.58   0.29   0.22
cciss/c0d0p6
               0.00     0.00  0.00  0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

Squid Object Cache: Version 2.6.STABLE23
Start Time:     Thu, 10 Dec 2009 01:47:30 GMT
Current Time:   Thu, 10 Dec 2009 02:58:22 GMT
Connection information for squid:
        Number of clients accessing cache:      14034
        Number of HTTP requests received:       558647
        Number of ICP messages received:        0
        Number of ICP messages sent:    0
        Number of queued ICP replies:   0
        Request failure ratio:   0.00
        Average HTTP requests per minute since start:   7883.9
        Average ICP messages per minute since start:    0.0
        Select loop called: 13535147 times, 0.314 ms avg
Cache information for squid:
        Request Hit Ratios:     5min: 0.3%, 60min: 0.2%
        Byte Hit Ratios:        5min: -20.8%, 60min: -23.1%
        Request Memory Hit Ratios:      5min: 39.1%, 60min: 47.9%
        Request Disk Hit Ratios:        5min: 53.0%, 60min: 46.3%
        Storage Swap size:      280968 KB
        Storage Mem size:       952888 KB
        Mean Object Size:       1404.84 KB
        Requests given to unlinkd:      1159
Median Service Times (seconds)  5 min    60 min:
        HTTP Requests (All):  31.72324 31.72324
        Cache Misses:         31.72324 31.72324
        Cache Hits:           12.67057  2.64709
        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:        4251.561 seconds
        CPU Time:       1606.439 seconds
        CPU Usage:      37.78%
        CPU Usage, 5 minute avg:        45.39%
        CPU Usage, 60 minute avg:       39.80%
        Process Data Segment Size via sbrk(): 1810900 KB
        Maximum Resident Size: 0 KB
        Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
        Total space in arena:  1810900 KB
        Ordinary blocks:       1800497 KB  13639 blks
        Small blocks:               0 KB      0 blks
        Holding blocks:         27724 KB      3 blks
        Free Small blocks:          0 KB
        Free Ordinary blocks:   10402 KB
        Total in use:          1828221 KB 99%
        Total free:             10402 KB 1%
        Total size:            1838624 KB
Memory accounted for:
        Total accounted:       1733519 KB
        memPoolAlloc calls: 92646133
        memPoolFree calls: 89719795
File descriptor usage for squid:
        Maximum number of file descriptors:   81920
        Largest file desc currently in use:   63793
        Number of file desc currently in use: 62271
        Files queued for open:                   0
        Available number of file descriptors: 19649
        Reserved number of file descriptors:   100
        Store Disk files open:                 503
        IO loop method:                     epoll
Internal Data Structures:
         36115 StoreEntries
         36095 StoreEntries with MemObjects
           546 Hot Object Cache Items
           200 on-disk objects



网络大概跑到200Mb左右,日常下载的文件有几百K到几百M的

[ 本帖最后由 小号来一个 于 2009-12-10 11:00 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2009-12-10 11:27 |只看该作者
从你提供的信息看io并不算高,队列是集中在了cpu上

squidclient -p80 mgr:60min
squidclient -p80 mgr:5min
这些信息也看看,你看log里是不是大量的http 206请求,这些请求有命中不,感觉你应该是设置成rang 设置成-1,把所有都预load过来,文件不经常变更的话用refresh_pattern ignore-reload参数忽略no-cache头

就我们两个菜鸟在这讨论,大大们进来看看吧

论坛徽章:
0
9 [报告]
发表于 2009-12-10 13:59 |只看该作者
把所有都预load过来,文件不经常变更的话用refresh_pattern ignore-reload参数忽略no-cache头

我这样做可以吗refresh_pattern .  0    50%     4320 ignore-reload

论坛徽章:
0
10 [报告]
发表于 2009-12-11 09:59 |只看该作者
最好加个文件类型
refresh_pattern \.exe$ 0    50%     4320 ignore-reload
refresh_pattern \.rar$ 0    50%     4320 ignore-reload
refresh_pattern \.zip$ 0    50%     4320 ignore-reload
多观察下有没有提高命中率,注意分析日志跟回源流量
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP