Skip to content
Browse files

Use varnish's round-robin director instead of random director to avoi…

…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...
1 parent 533d5b2 commit 4c9bd50201ea6ef2186790b60871999f95ea234b @pauldowman committed Oct 23, 2009
Showing with 2 additions and 4 deletions.
  1. +2 −4 server/files/etc/varnish/default.vcl.erb
View
6 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| %>
@@ -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 %>
}

0 comments on commit 4c9bd50

Please sign in to comment.
Something went wrong with that request. Please try again.