5

I want to have v1 of my application in one pool and version v1.1 in another pool and then slowly ramp up the traffic going to pool two and reduce it to pool one.

Can anyone show some concrete examples of doing this with HA Proxy, Varnish, Nginx or something else?

Bart De Vos
  • 17,911
  • 6
  • 63
  • 82
markba
  • 85
  • 1
  • 6
  • And how you intend to you mange the database schema changes? – Mircea Vutcovici May 01 '12 at 16:05
  • 1
    Schema changes can best be approached by staggering the change. Add a new column in v1.1, use the column in v1.2, stop using the column in v1.3, delete the column in v1.4. – markba May 01 '12 at 16:08

2 Answers2

6

The split clients module is designed specifically for this:

# I like starting my upstream names with _
# so they're not confused with hostnames
upstream _old_upstream {
  server 127.0.0.1:1234;
}

upstream _new_upstream {
  server 127.0.0.1:4321;
}

# Make sure the values here match the names of the upstream blocks above
split_clients $remote_addr $split_upstream {
   10% _new_upstream;
   -   _old_upstream;
}

server {
  location / {
    # EDIT: I forgot, when using variables in a proxy_pass, you have to
    # specify the entire request
    proxy_pass http://$split_upstream$request_uri;
  }
}

Then, as you want to move more traffic to the new server, just change the percentage and run nginx -s reload.

kolbyjack
  • 8,039
  • 2
  • 36
  • 29
  • I updated the config because I forgot that you have to specify the entire request when using variables in a proxy_pass – kolbyjack May 01 '12 at 16:34
  • The documentation is now located at: http://nginx.org/en/docs/http/ngx_http_split_clients_module.html – Thymine Feb 23 '16 at 22:03
0

Fro my testing the percentages need to be defined for both servers to work properly otherwise I got an error.

Andrej
  • 1