0

I have varnish setup with 2 backend servers with a round-robin director.

The 2 backends are showing up in varnishstat and varnishadm as healthy.

varnishadm output:

Backend name                   Admin      Probe
boot.app1                      probe      Healthy 5/5
boot.app2                      probe      Healthy 5/5

VCL Configuration:

probe ping {
  .interval = 5s;
  .timeout = 1s;
  .threshold = 3;
  .window = 5;
  .url = "/ping";
}
backend app1 {
  .host = "app-1.example.com";
  .port = "80";
  .probe = ping;
}

backend app2 {
  .host = "app-2.example.com";
  .port = "80";
  .probe = ping;
}

new application_servers = directors.round_robin();
application_servers.add_backend(app1);
application_servers.add_backend(app2);

set req.backend_hint = application_servers;

varnishstat output:

VBE.boot.app1.happy                                                                                                                        ffffffffff     VVVVVVVVVVVVVVVVVVVVVVVV
VBE.boot.app1.bereq_hdrbytes                                                                                                                    66.17K         0.00         91.00          0.00          0.00          0.00
VBE.boot.app1.beresp_hdrbytes                                                                                                                   76.72K         0.00        106.00          0.00          0.00          0.00
VBE.boot.app1.beresp_bodybytes                                                                                                                  11.91M         0.00         16.50K         0.00          0.00          0.00
VBE.boot.app1.conn                                                                                                                                251          0.00           .          251.00        251.00        251.00
VBE.boot.app1.req                                                                                                                                 251          0.00           .            0.00          0.00          0.00
VBE.boot.app2.happy                                                                                                                        ffffffffff     VVVVVVVVVVVVVVVVVVVVVVVV

You can see from the varnishstat command that traffic appears to only be sent to the first server in the round-robin configuration. There's no other lines for the app2 server other than .happy

Any thoughts on what would be causing the director to pick the first server every time?

  • The Round-Robin method does not really equally check all metrics to see who is the most available server and send the request there. Round-robin simply randomly selects a server to send the request. – jarvis Apr 26 '16 at 1:17
  • The round robin appears to always send the traffic to app1. app2 never receives any traffic – Stephen Mahood Apr 26 '16 at 20:47
  • Is set req.backend_hint = application_servers; in sub vcl_recv {} ? – Kirrus Apr 28 '16 at 16:34
1

You need to change your VCL file to something like this

probe ping {
   .interval = 5s;
   .timeout = 1s;
   .threshold = 3;
   .window = 5;
   .url = "/ping";
}
backend app1 {
   .host = "app-1.example.com";
   .port = "80";
   .probe = ping;
}

backend app2 {
   .host = "app-2.example.com";
   .port = "80";
   .probe = ping;
}

sub vcl_init {
    new application_servers = directors.round_robin();
    application_servers.add_backend(app1);
    application_servers.add_backend(app2);
}

sub vcl_recv{
    set req.backend_hint = application_servers;
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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