转载本站文章请注明,转载自: 月影鹏鹏 [http://Jacky.Aiwaly.com]
本文链接: http://jk.aiwaly.com/wp/varnish%e6%97%a0%e6%b3%95%e5%88%86%e9%85%8d%e5%86%85%e5%ad%98%e5%af%bc%e8%87%b4%e8%87%aa%e5%8a%a8%e9%87%8d%e5%90%af%e5%ad%90%e8%bf%9b%e7%a8%8b%e7%9a%84%e9%97%ae%e9%a2%98.html
我的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就一目了然了。
参考文档