Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to specify a weight for a backend in Varnish? I need to be able to serve different page if my main backend is unaccessable.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If you have varnish in front of a single backend, you can define the 503 page that is displayed when the backend isn't reachable. You could increase your grace time so that you serve old content if the backend fails.

If you have varnish in front of two backends, you can define a director with healthchecks that will remove the bad backend, leaving the other backend responding.

You can also intercept the 503 to report a page from a separate backend that has a static page. The directors don't really support weights, but since VCL is just compiled C code, there really isn't much you can't do. You can see if the beresp object is an error and select a different backend, perhaps the one for your error message.

Unless you're running varnish in front of a webfarm, putting the 503 page in Varnish is probably the easiest.

share|improve this answer
    
I've tried going with director and I intentionally brought one of the backends down, yet varnish still serving content from backend that isn't responding. unless i didn't do it right inside of default.vcl configuration file. I even gave 1 weight to backend that I want to serve just 503 page and 10 to my real website. Where can I find a good example for creating 503 custom page? –  alexus Oct 13 '10 at 21:42
    
varnish-cache.org/docs/2.1/tutorial/… has some snippets that you can use. Then you could define a known-good backend, and check req.backend.healthy and set the backend to your failmessage backend. –  karmawhore Oct 13 '10 at 21:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.