Varnish无法分配内存导致自动重启子进程的问题

2010年1月13日 由 月影鹏鹏 留言 »

我的Varnish服务器在访问量达到一定程度的时候会出现自动重启子进程的问题,从日志中出现重启子进程时有以下错误提示

Panic message: Missing errorhandling code in sma_alloc(), storage_malloc.c line 79:   Condition((sma->s.p
tr) != 0) not true.  errno = 12 (Cannot allocate memory)  thread = (cache-worker)sp = 0×71a42004 {   fd = 4218, id = 4218, xid = 2057707839,   client = 116.3
0.99.238:12844,   step = STP_LOOKUP,   handling = hash,   ws = 0×71a4204c {      id = “sess”,     {s,f,r,e} = {0×71a42534,,+672,(nil),+16384},   },     worke
r = 0×1f5f30d8 {     },     vcl = {       srcname = {         “input”,         “Default”,       },     }, },

还是参考官方文档的Performance Tuning

  • -h classic,500009 (default: 16383)

To keep hash lookups fast, you should not have more than 10 objects per hash bucket. If you have 3 million objects, number of objects should be at least 300000. The number should be a prime number. You can generate one on http://www.prime-numbers.org/.

于是根据Varnish创建的object数目慢慢调大-h的参数值,最后终于彻底解决了子进程自动重启的问题。

顺带提一下Varnish不重启进程让修改后的配置文件立刻生效的方法

1. telnet登陆到Varnish的管理端口

2. vcl.load <configname> <configpath>

configname可以自己设定,想叫啥都行。configpath就是配置文件的完整路径,比如/usr/local/varnish/etc/varnish/default.vcl

3. vcl.use <configname>

第二步和第三步如果成功会返回代码200,全部操作完成后退出即可。

关于管理台的运用其实很简单,telnet登陆上以后执行help就一目了然了。

参考文档

http://varnish.projects.linpro.no/wiki/Performance

广告位

留言