AB testing with nginx

Maxim Dounin mdounin at mdounin.ru
Tue Nov 3 14:13:48 MSK 2009


On Tue, Nov 03, 2009 at 05:17:57AM -0500, dawe7 wrote:

> Thanks, but here is one problem:
> If I have 3 servers (or more) in upstream, I split traffic to 33%, 33%, 33%. No 50% and 50%.
> And second problem is If I use servers with different performance. I may overload one of this server.
> Because I can not combine ip_hash and weight methods for connection distribution and set one server weight=2 and others servers weight=1.
> And split traffic to 50%,25%+25%.

Well, if you need more generic aproach you may rewrite requests 
to another location and handle them differently.  Try something 
like this:

    location / {
        if ($remote_addr ~ "[02468]$") {
            rewrite ^(.*) /test/$1 last;

        proxy_pass http://normal_backend/;

    location /test/ {
        proxy_pass http://test_backend/;

Maxim Dounin

More information about the nginx mailing list