为什么清漆禁止请求不删除/使缓存数据无效?

时间:2013-07-16 20:00:53

标签: varnish

我正在尝试用varnish来调试不一致的行为 我有一个应用程序,当更新一段内容时,会向varnish发出禁止请求,以便将其从缓存中删除并使该缓存无效。问题是,虽然我可以在清漆日志中看到禁令,但这种方法只能运行几次,但大多数时间都不行。换句话说,当我保存一段内容时,会对表格的清漆发出禁令 1374003254.031996 75 req.http.host ~ www.example.com && req.url ~ ^(.*)(?<!\d{1})539250(?!\d{1})其中539250是网址中存在的唯一内容ID。

我登录了清漆主机并检查了清漆过程。执行ps -ef | grep varn给出 root 8889 1 0 15:19 ? 00:00:00 /usr/sbin/varnishd -P /var/run/varnish.pid -a :80 -T :8100 -f /etc/varnish/qa.vcl -u varnish -g varnish -h critbit -p http_max_hdr 256 -p thread_pool_min 200 -p thread_pool_max 4000 -p thread_pools 2 -p thread_pool_stack 262144 -p thread_pool_add_delay 2 -p session_linger 100 -p sess_timeout 60 -p listen_depth 4096 -p lru_interval 20 -p ban_lurker_sleep 0.2 -s malloc,1G

varnish 8897 8889 0 15:19 ? 00:00:00 /usr/sbin/varnishd -P /var/run/varnish.pid -a :80 -T :8100 -f /etc/varnish/qa.vcl -u varnish -g varnish -h critbit -p http_max_hdr 256 -p thread_pool_min 200 -p thread_pool_max 4000 -p thread_pools 2 -p thread_pool_stack 262144 -p thread_pool_add_delay 2 -p session_linger 100 -p sess_timeout 60 -p listen_depth 4096 -p lru_interval 20 -p ban_lurker_sleep 0.2 -s malloc,1G

有2个进程是否正常?

然后我在清漆cli中做了一个ban.list:

1374003254.031996 75 req.http.host ~ example.com && req.url ~ ^(.*)(?<!\d{1})539250(?!\d{1})
1374003202.365076 224G req.http.host ~ example.com && req.url ~ ^(.*)(?<!\d{1})539250(?!\d{1})
1374003116.772315 83G req.http.host ~ example.com && req.url ~ ^(.*)(?<!\d{1})539250(?!\d{1})
1374002967.450431 267G req.http.host ~ example.com && req.url ~ ^(.*)(?<!\d{1})539250(?!\d{1})
1374002756.701640 187G req.http.host ~ example.com && req.url ~ ^(.*)(?<!\d{1})539250(?!\d{1})

所有我想知道是否有错误导致禁止不删除缓存数据。

1 个答案:

答案 0 :(得分:0)

您的清漆生产线看起来不错。

Varnish有一个管理流程,可以启动(并监视)完成所有请求处理的子项。这是您正在看到的两个过程。

如果你做了很多禁令,你应该考虑阅读Varnish书中的“智能禁令”一章。它可以帮助您缩短禁令清单。

https://www.varnish-software.com/static/book/Cache_invalidation.html#smart-bans