Nginx as reverse proxy scalability

Maxim Dounin mdounin at mdounin.ru
Tue May 10 15:56:21 UTC 2016


Hello!

On Tue, May 10, 2016 at 05:37:55PM +0200, Artur wrote:

> Thanks for your answer.
> 
> Le 10/05/2016 à 17:04, Maxim Dounin a écrit :
> > As long as you are using TCP/IP and have only one backend (ip + 
> > port), and only one local address on nginx side, then you are 
> > limited by the number of local ports nginx can use.
> I currently have nginx running on the same host that my backends.
> I have 4 of them listening on different ports on 127.0.0.1.
> In this situation may I expect 4 times 65000 simultaneous connections ?

Yes.

(Note though, that this may not be true on all OSes.  And this 
also won't be true when using proxy_bind, as OS will have to 
choose a local port before the destination address is known.)

> > - add more local addresses on nginx side and use proxy_bind to 
> >   balance users between these addresses.
> Yes, I've seen this, however I didn't catch how to dynamically assign a
> value to proxy_bind from a pool of IP addresses in nginx (not Nginx Plus).

The blog post as linked by Maxim Konovalov uses the split_clients 
module, it's not nginx-plus specific.  See here for details:

http://nginx.org/en/docs/http/ngx_http_split_clients_module.html

Depending on your particular case, there may be even easier 
solutions.  E.g., if you have two URIs in your application with 
more or less equal load, you can use two locations with distinct 
addresses configured statically:

    location /one {
        proxy_pass http://127.0.0.1:8080;
        proxy_bind 127.0.0.2;
    }

    location /two {
        proxy_pass http://127.0.0.1:8080;
        proxy_bind 127.0.0.3;
    }

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list