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.

I'm having trouble with Varnish, it works for a couple of views and then just goes sick... The weird thing is that it does work for about 20 or 30 requests. If I call apache directly it works fine. I'm running Varnish Version: 3.0.3-1 on Debian Squeeze and, for now, Apache on port 80 and Varnish on port 8080 on the same server..

I'm using https://github.com/mattiasgeniar/varnish-3.0-configuration-templates as base for my VCLs and modified the VCLs to support Concrete5.

Anyone any clue on how I should debug this?

backend default {
    .host = "127.0.0.1";
    .port = "80";
    .connect_timeout = 1.5s; 
    .first_byte_timeout = 45s; 
    .between_bytes_timeout = 30s; 
    .probe = {
        .url = "/";
        .timeout  = 1s;
        .interval = 10s;
        .window    = 10;
        .threshold = 8;
    }
}

LOG

    0 CLI          - Rd ping
    0 CLI          - Wr 200 19 PONG 1353791312 1.0
    0 CLI          - Rd ping
    0 CLI          - Wr 200 19 PONG 1353791315 1.0
    0 Backend_health - default Still sick 4--X-R- 0 8 10 0.000689 0.000000 HTTP/1.1 301 Moved Permanently

(the 301 is because I check for www.)

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Your backend is responding with a 301 to the health check; only 200 is an expected "healthy" response by default. Change your probe:

.probe = {
    .url = "/";
    .timeout  = 1s;
    .interval = 10s;
    .window    = 10;
    .threshold = 8;
    .expected_response = 301;
}

Edit :

Here is the reason why the log returned ok in the beginning but after a while it would drop one by one to eventually the state of sick : The settings for .interval, .threshold, and .window - the health checks were getting an "unhealthy" response but they didn't consider the worker to be sick until they had gotten enough bad responses to drop the number of successes in the window to under the threshold

share|improve this answer
    
Awesome this works! But I don't quite understand why the log returns ok in the beginning but after a while it will drop one by one to eventually the state of sick... Even the browser calls to varnish give a 503 at that time. –  PvdL Nov 24 '12 at 21:44
3  
@junke1990 The reason for that is the settings for .interval, .threshold, and .window - the health checks are always getting an "unhealthy" response but they don't consider the worker to be sick until they've gotten enough bad responses to drop the number of successes in the window to under the threshold. –  Shane Madden Nov 24 '12 at 23:42
    
I get that, the explains why the logger says it's not healthy but it doesn't seem logic that if the logger things varnish is sick to block or shutdown varnish. I was getting only blank pages after the logger says varnish is sick. That's my confusing part. –  PvdL Nov 25 '12 at 16:16
    
@junke1990 You should be getting a 503 response when all backends are sick - what's it look like in varnishlog when one of those requests occurs? –  Shane Madden Nov 25 '12 at 19:36

The 301 happens because the probe is sending a request with Host: 127.0.0.1 while your server is expecting a Host: example.com ( your domain ), so it doesn't match any server so the catch all server redirects it.

To avoid this you can use a .request instead of a .url in the probe

.probe = {
    .request =  "GET / HTTP/1.1"
                "Host: example.com"
                "Connection: close"
                "Accept: text/html" ;
    .timeout  = 1s;
    .interval = 10s;
    .window    = 10;
    .threshold = 8;
}

Here's the reference for probes

share|improve this answer

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.