Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Varnish hit-for-pass means?

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 requesting content in cache.

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.

like image 459
Muneeb Nasir Avatar asked Oct 02 '12 13:10

Muneeb Nasir


People also ask

How do I know if Varnish is running?

To verify that Varnish is proxying look for the existence of the X-Varnish header in the response. The Age header will be 0 on a cache miss and above zero on a hit. The first request to a page will always be a miss.

What is grace in Varnish?

Grace mode allows Varnish to deliver slightly stale content to clients while getting a fresh version from the backend. The result is faster load times at lower cost. It is possible to limit the grace during lookup by setting req. grace and then change the behavior when it comes to grace.

What is synth in Varnish?

synth - Generate a synthetic response from Varnish. This synthetic response is typically a web page with an error message. synth may also be used to redirect client requests. It's also common to use vcl_recv to apply some security measures.


1 Answers

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.

like image 132
lkarsten Avatar answered Sep 30 '22 18:09

lkarsten