清漆击中传球意味着什么? [英] Varnish hit-for-pass means?

查看:23
本文介绍了清漆击中传球意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为 Varnish 版本 3 有一些用于不同操作的对象.

As Varnish Version 3 has some objects for different operations.

例如,当必须从后端检索数据时使用 pass.当它在缓存中找到请求内容时使用命中.

For Example, pass is used when it has to retrieve data from backend. and it uses hit when it finds requesting content in cache.

但我无法理解hit-for-pass的用法.清漆什么时候用?我还没有在网上找到任何有用的材料让我清楚.

But I cant understand usage of hit-for-pass. when varnish uses it ? I haven't found any useful material on net which make me clear.

推荐答案

创建一个 hit_for_pass 对象来优化针对后端服务器的获取过程.

A hit_for_pass object is made to optimize the fetch procedure against a backend server.

对于普通缓存未命中,Varnish 会将请求相同缓存对象的所有客户端排队,并向后端发送单个请求.这通常是最快的,让后端处理单个请求,而不是同时处理 n 个请求.

For ordinary cache misses, Varnish will queue all clients requesting the same cache object and send a single request to the backend. This is usually quickest, letting the backend work on a single request instead of swamping it with n requests at the same time.

请记住,某些后端会花费大量时间来准备对象;10 秒并不少见.如果这是首页 HTML 并且您有 3000 个请求/秒,那么仅发送一个后端请求就很有意义.

Remember that some backends use a lot of time preparing an object; 10 seconds is not uncommon. If this is the front page HTML and you have 3000 req/s against it, sending just one backend request makes a lot of sense.

当 Varnish 获取对象后发现无法缓存时,就会出现问题.这样做的原因可能是后端发送了Cache-Control: max-age=0",或者(更常见的)一个 Set-Cookie 标头.在这种情况下,您有 3,000 到 30,000 个客户端(3k req/s * 10sec)在队列中闲置,并且对于这些客户端中的每一个,必须完成相同的缓慢的一次一个后端请求才能为它们提供服务.这会缩短您的网站响应时间.

The issue arises when after Varnish has fetched the object it sees that it can't be cached. Reasons for this can be that the backend sends "Cache-Control: max-age=0", or (more often) a Set-Cookie header. In this case you have somewhere between 3,000 and 30,000 clients (3k req/s * 10sec) sitting idle in queue, and for each of these clients the same slow one-at-a-time backend request must complete to serve them. This will ruin your site response time.

所以 Varnish 通过创建一个 hit_for_pass 对象来保存这个请求不能被缓存的决定.

So Varnish saves the decision that this request cannot be cached by creating a hit_for_pass object.

在对同一 URL 的下一个请求中,缓存查找将返回一个 hit_for_pass 对象.这表示可以同时进行多次提取.您的后端可能对此不太满意,但至少 Varnish 不会无缘无故地让客户端排队.

On the next request for the same URL, the cache lookup will return a hit_for_pass object. This signals that multiple fetches may be done at the same time. Your backend might not be too happy about it, but at least Varnish isn't queuing the clients for no reason.

这篇关于清漆击中传球意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆