免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123
最近访问板块 发新帖
楼主: taoyouba
打印 上一主题 下一主题

[proxy] SQUID,4天累计1亿次请求,无故障,但疑点重重,望高手诊症! [复制链接]

论坛徽章:
0
21 [报告]
发表于 2010-05-29 12:33 |只看该作者
楼上的大哥,再来看看最新的状态:
Squid Object Cache: Version 3.0.STABLE25
Start Time:     Thu, 13 May 2010 15:36:37 GMT
Current Time:   Sat, 29 May 2010 04:19:10 GMT
Connection information for squid:
        Number of clients accessing cache:      93534
        Number of HTTP requests received:       282296262
        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:   12623.6
        Average ICP messages per minute since start:    0.0
        Select loop called: -2107058277 times, -0.637 ms avg
Cache information for squid:
        Hits as % of all requests:      5min: 82.2%, 60min: 84.5%
        Hits as % of bytes sent:        5min: 97.4%, 60min: 97.5%
        Memory hits as % of hit requests:       5min: 66.5%, 60min: 67.8%
        Disk hits as % of hit requests: 5min: 10.0%, 60min: 9.7%

        Storage Swap size:      19516900 KB
        Storage Swap capacity:  46.5% used, 53.5% free
        Storage Mem size:       2084908 KB
        Storage Mem capacity:   100.0% used,  0.0% free
        Mean Object Size:       19.22 KB
        Requests given to unlinkd:      0
Median Service Times (seconds)  5 min    60 min:
        HTTP Requests (All):   0.00000  0.00000
        Cache Misses:          0.01387  0.01387
        Cache Hits:            0.00000  0.00000
        Near Hits:             0.09219  0.07825
        Not-Modified Replies:  0.00000  0.00000
        DNS Lookups:           0.00000  0.00278
        ICP Queries:           0.00000  0.00000
Resource usage for squid:
        UP Time:        1341753.816 seconds
        CPU Time:       136093.238 seconds
        CPU Usage:      10.14%
        CPU Usage, 5 minute avg:        9.10%
        CPU Usage, 60 minute avg:       9.42%
        Process Data Segment Size via sbrk(): 4293287888 KB
        Maximum Resident Size: 0 KB
        Page faults with physical i/o: 2
Memory usage for squid via mallinfo():
        Total space in arena:  -1487652 KB
        Ordinary blocks:       -1557322 KB  59900 blks
        Small blocks:               0 KB      0 blks
        Holding blocks:        307696 KB   2047 blks
        Free Small blocks:          0 KB
        Free Ordinary blocks:   69669 KB
        Total in use:          -1249626 KB 106%
        Total free:             69669 KB -5%
        Total size:            -1179956 KB
Memory accounted for:
        Total accounted:       -1459802 KB 124%
        memPool accounted:     -1459802 KB 124%
        memPool unaccounted:   279845 KB -23%
        memPoolAlloc calls: 44309514948
        memPoolFree calls:  44295384403
File descriptor usage for squid:
        Maximum number of file descriptors:   65536
        Largest file desc currently in use:   51553
        Number of file desc currently in use: 46832
        Files queued for open:                   0
        Available number of file descriptors: 18704
        Reserved number of file descriptors:   100
        Store Disk files open:                40994
Internal Data Structures:
        1144953 StoreEntries
        279605 StoreEntries with MemObjects
        279540 Hot Object Cache Items
        1015453 on-disk objects


一、内存命中率现在是稍高了,但磁盘的命中反而是非常低。硬盘(VM虚拟机)是80G,给squid缓冲设了40G,物理内存4G,给squid设了2G
最后的信息可以看到100万个文件被存放在硬盘,按道理应该磁盘命中不至于这么低啊。是不是受内存的限制呢?因为看到Hot Object Cache Items的数值相对比较小,是否有关?

二、再看Largest file desc currently in use数,和Store Disk Files open,几乎已经到达了65536的极限。而且最纳闷的是这个数值,在SQUID刚启动的时候,他是比较小的,大概就两三千。随着运行时间的延长,数值不断在增加,非繁忙时期,他又小幅的减少,但总体来说他是在不断增大。到达上限后,SQUID就挂死。所以现在我不得不隔几天就重启一次SQUID。
记得楼上曾经有一位大侠说调整TCP连接的一些设置可以缓解这个问题,不过按他提供的资料设置后,仍然没见明显的效果。

现在运行13天,累计差不多3亿次的请求了,文件描述符也差不多到上限了,应该是时候要重启一下squid了。

论坛徽章:
0
22 [报告]
发表于 2010-05-29 13:21 |只看该作者
回复 21# taoyouba

/etc/sysctl.conf
net.ipv4.ip_forward = 0
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 3
net.ipv4.ip_local_port_range = 1024 65534
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_response = 1
net.netfilter.nf_conntrack_max = 1048576
kernel.pid_max = 65535
net.core.netdev_max_backlog = 2048
net.ipv4.tcp_wmem = 4096 32768 8388608
13/16
net.ipv4.tcp_rmem = 4096 87380 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 8388608
net.core.wmem_default = 8388608
net.core.wmem_max = 8388608
楼主试试这个 ·!我的现在每天跑20M 但是描述很稳定~!

论坛徽章:
0
23 [报告]
发表于 2010-05-30 11:01 |只看该作者
Storage Mem size:       2084908 KB
Storage Mem capacity:   100.0% used,  0.0% free

别的看不出来。。但是内存用完了。

尝试调整下关于内存方面的参数。。开始你内存命中太低,但是现在虽然高,但是你内存不足。。

论坛徽章:
0
24 [报告]
发表于 2010-05-30 11:11 |只看该作者
还可以改善图片让浏览器缓存减少SQUID消耗!

论坛徽章:
0
25 [报告]
发表于 2010-06-04 09:43 |只看该作者
贴一下我的/etc/sysctl.conf
[root@cache163 ~]# cat /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl( and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename
# Useful for debugging multi-threaded applications
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1

# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456

# Edit by Gucong
# 保持fin-wait-2状态的时间
net.ipv4.tcp_fin_timeout=30

#当KEEPALIVE起作用时,发送keepalive消息的频率,默认2小时,改为20分钟
net.ipv4.tcp_keepalive_time=1200

#开启SYN Cookies,当SYN等待列队溢出,启用cookies来处理,默认关闭,改为开启
net.ipv4.tcp_syncookies=1

#开启重用,允许将TIME-WAIT状态sockets重新用于新的TCP连接,默认关闭,改为开启
net.ipv4.tcp_tw_reuse=1

#启用TCP连接中TIME-WAIT sockets的快速回收,默认关闭,改为开启
net.ipv4.tcp_tw_recycle=1

#用户向外连接的端口范围,默认32768~61000,改为1024~65000
net.ipv4.ip_local_port_range=1024 65000

#表示SYN列队的长度,默认1024,改为8192,可容纳更多处于等待状态的连接
net.ipv4.tcp_max_syn_backlog=8192

#表示系统同时保持TIME-WAIT套接字的最大数量,如果超过将立即清除,默认180000,改为5000
net.ipv4.tcp_max_tw_buckets=5000
以上这些参数,也是从别的资料里面找到的,但是具体解析有些还是不太了解
楼上的兄弟,能否简单给出你的配置中每项的说明吗?

论坛徽章:
0
26 [报告]
发表于 2010-06-04 09:46 |只看该作者
Storage Mem size:       2084908 KB
Storage Mem capacity:   100.0% used,  0.0% free

别的看不出来。 ...
qczl1224 发表于 2010-05-30 11:01



    机器的物理内存为4G,用于SQUID缓冲的设置了2G,TOP监控看到squid占用内存3G左右,系统剩余物理内存约1G。
因为站点的图片数量较多,总大小约有150G,就是说无论我设置多大的缓冲内存,肯定会爆满

对于内存还有什么办法呢?

论坛徽章:
0
27 [报告]
发表于 2010-06-05 14:05 |只看该作者
标记学习

论坛徽章:
0
28 [报告]
发表于 2010-08-30 13:49 |只看该作者
本帖最后由 qczl1224 于 2010-08-30 13:55 编辑

request_timeout 20 seconds
connect_timeout 100 seconds
client_lifetime 3600 seconds

6楼说的..调整类似参数,可以降低部署描述使用,和尽快回收描述符..

还有部署描述符65536不是系统极限..

新装的系统,你可以看看这个文件/proc/sys/fs/file-max,
我记得看过一个CentOS 5.5的这个数值是80W,也就是你在
/etc/security/limits.conf 中修改描述 80W以下都可以,当然这个可能要比较好的服务器支持.服务器差的话,能不能打开10W都有问题把,呵呵
你可以先测试再使用!

论坛徽章:
0
29 [报告]
发表于 2010-09-04 11:52 |只看该作者
configure 的时候是否加了 --enable-epoll 参数?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP