有时我的应用程序向客户端返回HTTP 503错误。 我唯一的线索是,当它发生时,Cacti报告一个清漆短信分配请求的高峰。
经过一番研究,我可能已经为光油分配了太多的内存,与我的虚拟机相比。 所以我加了2GB。 清漆已经重新装入,但没有重新启动。
现在很less发生错误,但仍然。
这里带有SMS高峰的仙人掌图: http : //s29.postimg.org/94bu3vvd3/varnish_SMS.png
在RHEL6.3上清漆-3.0.4
清漆启动参数:
/ usr / sbin / varnishd -P /var/run/varnish.pid -a:80 -f /etc/varnish/rc_platform.vcl -T xxx.xxx.xx.xxx:6082 -t 120 -w 1,1000, 120 -u清漆-g清漆-S / etc /清漆/秘密-s malloc,6G
有趣的部分varnishstat
SMA.s0.c_req 14736881 2.26 Allocator requests SMA.s0.c_fail 4190399 0.64 Allocator failures SMA.s0.c_bytes 353887517876 54362.00 Bytes allocated SMA.s0.c_freed 347445180586 53372.37 Bytes freed SMA.s0.g_alloc 311300 . Allocations outstanding SMA.s0.g_bytes 6442337290 . Bytes outstanding SMA.s0.g_space 113654 . Bytes available SMA.Transient.c_req 15771681 2.42 Allocator requests SMA.Transient.c_fail 0 0.00 Allocator failures SMA.Transient.c_bytes 910056978442 139797.31 Bytes allocated SMA.Transient.c_freed 910056853513 139797.29 Bytes freed SMA.Transient.g_alloc 52 . Allocations outstanding SMA.Transient.g_bytes 124929 . Bytes outstanding SMA.Transient.g_space 0 . Bytes available
我有一个10GB的虚拟机,6个分配给Varnish。
谢谢。
你有一个非常高的SMA.s0.c_fail计数。 所以,Varnish试图分配内存并失败。 你可以通过增加nuke_limit使Varnish更具攻击性,nuke_limit是试图释放内存时Varnish可以杀死的对象的数量。
您需要重新启动以更改内存设置才能生效。 但是,我build议有更多的内存可用于您的服务器。 给予清漆更多的记忆通常便宜和聪明。
为避免请求失败,varnish将分配瞬态内存来存储对象。 瞬态内存存储是无限的,这意味着如果过度使用服务器,可能会导致服务器停机。 如果你愿意,你可能会限制它。