2

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.)

2 Answers 2

4

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

5
  • 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, 2012 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. Nov 24, 2012 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, 2012 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? Nov 25, 2012 at 19:36
  • Sorry for waking this thread up. But is it possible to let varnish check for both 200 AND 301?
    – Orphans
    Sep 20, 2016 at 13:30
2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .