Skip to content

Commit

Permalink
Use varnish's round-robin director instead of random director to avoi…
Browse files Browse the repository at this point in the history
…d getting 503 errors when some (but not all) back-ends are down. (The random director doesn't necessarily try all back-ends, even if retries is set >= than the number of back-ends.)

BTW this is only for balancing between back-end nginx servers and there's no problem doing round-robin here, the web servers themselves are still using Passenger's global queueing to balance between the Rails back-ends so there is no issue with one slow request holding up all the others.
  • Loading branch information
pauldowman committed Oct 23, 2009
1 parent 533d5b2 commit 4c9bd50
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions server/files/etc/varnish/default.vcl.erb
@@ -1,8 +1,7 @@
#This is the VCL configuration file for varnish. See the vcl(7)
#man page for details on VCL syntax and semantics.

director director_1 random {
.retries = <%= roles[:web].size * 3 %>;
director director_1 round-robin {
# One backend for each instance in the "web" role. If that instance is also in
# the "proxy" role then it's listening on port 81, otherwise it's on port 80
<% roles[:web].each_with_index do |address, i| %>
Expand All @@ -12,10 +11,9 @@ director director_1 random {
.port = "<%= roles[:proxy] && roles[:proxy].include?(address) ? 81 : 80 %>";
.max_connections = 100;
.connect_timeout = 10s;
.first_byte_timeout = 60s;
.first_byte_timeout = 30s;
.between_bytes_timeout = 10s;
}
.weight = 1;
}
<% end %>
}
Expand Down

0 comments on commit 4c9bd50

Please sign in to comment.