DEV Community

MustafaSamedYeyin
MustafaSamedYeyin

Posted on

Nginx load balancing

  • If you want to load balance request from nginx you can use upstreams.

  • I have one application in ubuntu machine :

  • And one from windows machine :

They are just plain static files serves on 8080 port.

I will upstream for load balancing for above two application :

    upstream my_upstream {
        server 172.30.16.1:8080 weight=5;
        server 192.168.137.133:8080 weight=4;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://my_upstream;
        }
    }

Enter fullscreen mode Exit fullscreen mode
  • You should start nginx.exe .

  • Send request to :

http://localhost/Sample.html

  • When you sent request over and over again, you will see there is some kind of balanced handling (depends on weight paramater):

Happy serving 🐋

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.