Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible in Varnish 3 to configure a backend to have multiple probes?

I have multiple varnish servers and multiple backend servers running Drupal. I've configured a basic 1 second interval healthcheck PHP file to verify the health of the application server, but I would also like to use a healthcheck for the Drupal stack, however this check would need to run less often than the basic healthcheck. e.g.: Every 5 seconds it could check the Drupal stack.

Is it possible to use 2 separate probes on a single backend for such a case?

Theoretical configuration:

probe healthcheck {
    .url = "/healthcheck.php";
    .interval = 1s;
    .timeout = 100 ms;
    .window = 5;
    .threshold = 5;
}

probe drupalcheck {
    .url = "/index.php";
    .interval = 5s;
    .timeout = 5s;
    .window = 5;
    .threshold = 5;
}

backend apache_1 {.host = "server01"; .port = "8080"; .probe = healthcheck; .probe = drupalcheck}
backend apache_2 {.host = "server02"; .port = "8080"; .probe = healthcheck; .probe = drupalcheck}
backend apache_3 {.host = "server03"; .port = "8080"; .probe = healthcheck; .probe = drupalcheck}
share|improve this question

Quick answer: no.

Longer answer: You can specify as many backends to a single actual backend server, and each can have it's own probe. You can then route traffic to them as you want.

You could also call something like a 'probe-check' script on your application server via the probe call, which could do it's own status checks. You're just calling a php/python/etc script anyway, so it can be a script you created.

There's more (not totally relevant) here: https://www.varnish-cache.org/lists/pipermail/varnish-misc/2011-October/021298.html

share|improve this answer

The probe just checks the header returned. Thus you can have ohne script /probe.php which first sends a request to /healthcheck.php and afterwards another one to index.php.

Inside /probe.php you can use $headers = get_headers($url,1); and analyze for a 40X or 50X return code on each of the urls.

At the end:

if($atleastOneOfTheUrlsReturnedSomeThingBad){
  header('HTTP/1.0 404 Not Found');
}
else{
  header( "HTTP/1.1 200 OK" );
}
exit();
share|improve this answer
    
yep I know quite an old post – but still relevant – Hafenkranich Jun 6 at 19:20

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.