squid高负载时,不开磁盘缓存,内核CPU占用过高,怎么解决

94 views
Skip to first unread message

lu

unread,
Apr 13, 2010, 12:29:04 AM4/13/10
to linux-...@zh-kernel.org
squid高负载时,不开磁盘缓存,内核CPU占用过高,怎么解决
_______________________________________________
Linux 内核开发中文邮件列表
Linux-...@zh-kernel.org
http://zh-kernel.org/mailman/listinfo/linux-kernel
Linux 内核开发中文社区: http://zh-kernel.org

kaih luo

unread,
Apr 13, 2010, 12:46:08 AM4/13/10
to lu, Linux-...@zh-kernel.org

磁盘上有swap分区吗?如果有swap分区,可能是内存换入换出的问题,那样只有加大内存了

kaih luo

unread,
Apr 13, 2010, 1:11:13 AM4/13/10
to lu, Linux-...@zh-kernel.org
在 2010年4月13日 下午1:03,lu <lujin...@163.com> 写道:
> 不是内存问题,内存很大,有可能是报文从内核传到用户空间这块,不知道怎么优化
打开磁盘缓存,CPU占用率会下来?

Drunkard Zhang

unread,
Apr 13, 2010, 1:23:06 AM4/13/10
to kaih luo, lu, Linux-...@zh-kernel.org
在 2010年4月13日 下午12:46,kaih luo <kaih....@gmail.com>写道:

> 在 2010年4月13日 下午12:29,lu <lujin...@163.com> 写道:
> > squid高负载时,不开磁盘缓存,内核CPU占用过高,怎么解决
>

CPU占用率高可能有多个起因。用htop或atop观察能看到是应用程序占用了CPU时间还是内核本身占用了很多CPU时间,对网卡驱动不太好的系统来说可能处理网卡的IRQ中断会占用大量时间,可能会达到50%以上。所以我原来用的开源的e1000e驱动换成Intel官方的驱动后性能好了很多。

如果系统开始使用SWAP,它的性能就会急剧下降,建议关掉swap(或只留几十MB的交换空间,然后sysctl -w vm.swappiness=1)。

如果怀疑是IO问题,试试 cache_dir null /tmp

squid是单进程,不支持SMP确实是问题,可以尝试下这个:
http://eu.squid-cache.org/ConfigExamples/ExtremeCarpFrontend

--
张绍文
gongf...@gmail.com
zha...@gwbnsh.net.cn
18601633785

Drunkard Zhang

unread,
Apr 13, 2010, 1:28:50 AM4/13/10
to kaih luo, lu, Linux-...@zh-kernel.org
在 2010年4月13日 下午1:11,kaih luo <kaih....@gmail.com>写道:

> 在 2010年4月13日 下午1:03,lu <lujin...@163.com> 写道:
> > 不是内存问题,内存很大,有可能是报文从内核传到用户空间这块,不知道怎么优化
> 打开磁盘缓存,CPU占用率会下来?
>

如果你的流量很大(单台200Mbit左右),建议你只用内存,少用或不用硬盘。我自己的经验:用SATA-2硬盘,每块硬盘用10G空间,在高负载下流量不会超过120M,再高延时就明显增大或流量开始抖动。

内存很大也未必是好事,squid本身有局限性,我现在的机器在24GB内存下跑的很好,但64GB的怎么也跑不起来,后来听说是squid本身的局限性...

>
> >
> > 在2010-04-13 12:46:08,"kaih luo" <kaih....@gmail.com> 写道:
> >>在 2010年4月13日 下午12:29,lu <lujin...@163.com> 写道:
> >>> squid高负载时,不开磁盘缓存,内核CPU占用过高,怎么解决
> >>> _______________________________________________
> >>> Linux 内核开发中文邮件列表
> >>> Linux-...@zh-kernel.org
> >>> http://zh-kernel.org/mailman/listinfo/linux-kernel
> >>> Linux 内核开发中文社区: http://zh-kernel.org
> >>
> >>磁盘上有swap分区吗?如果有swap分区,可能是内存换入换出的问题,那样只有加大内存了
> >
> >
> >
> _______________________________________________
> Linux 内核开发中文邮件列表
> Linux-...@zh-kernel.org
> http://zh-kernel.org/mailman/listinfo/linux-kernel
> Linux 内核开发中文社区: http://zh-kernel.org
>

--
张绍文
gongf...@gmail.com
zha...@gwbnsh.net.cn
18601633785

Reply all
Reply to author
Forward
0 new messages