Hongyu Jiang
Hongyu Jiang

Reputation: 41

Why my varnish health check always return the backend server is sick?

I used varnish as cache server before my nginx web server. I configured the health check for the definition of backend server in varnish configuration file. But the varnish always return my backend server is sick, while I stopped my varnish and directly connected nginx server, it can works well. I try to use .url or .request to enable backend server check, it never work well. Its crarzy how to resovle it.

My configuration is :

probe backend_healthcheck {   
.url = "/";
.window = 5;
.threshold = 3;
.interval = 300s;
}

backend nginx2 {
.host = "10.161.78.249";
.port = "80";
.probe = backend_healthcheck;
}

backend nginx2 {
.host = "10.161.78.249";
.port = "80";
.probe = backend_healthcheck;
}

import directors;
import std;
sub vcl_init {
new webserver = directors.hash();
webserver.add_backend(nginx1,1.0);
webserver.add_backend(nginx2,1.0);
}

sub vcl_recv {
set req.backend_hint = webserver.backend(req.http.cookie);
}

I really don't know which configuration is error? The varnish is running on the server has public ip and the backend server only has internal ip.

Hope some help me, Thanks a lot.

Upvotes: 0

Views: 3044

Answers (1)

Kessem Lee
Kessem Lee

Reputation: 1373

Note that the request has to return 200 OK for Varnish to accept this as healthy. Could it be that your framework returns 302 on the / URL?

Also, your .window size means that the servers start as sick and remain sick until you get .threshold consecutive healthy responses, which would take 15 minutes in your case.

Also, what does the log show?

Documentation: https://www.varnish-cache.org/trac/wiki/BackendPolling

Upvotes: 1

Related Questions