Varnish hit-for-pass means?

前端 未结 1 997
终归单人心
终归单人心 2021-01-30 08:29

As Varnish Version 3 has some objects for different operations.

For Example, pass is used when it has to retrieve data from backend. and it uses hit when it finds reque

相关标签:
1条回答
  • 2021-01-30 09:15

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

    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.

    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.

    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.

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

    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.

    0 讨论(0)
提交回复
热议问题