I want to load balance my website with nginx.
The load balancing in nginx wiki is proxy, so the actual file being downloaded from the frontend server. (http://wiki.nginx.org/LoadBalanceExample)
This is how I need the balancing:
user request file:
nginx redirect user to one of the servers (with Location header):
Is this possible with nginx?
A load balancer acts as the “traffic cop” sitting in front of your servers and routing client requests across all servers capable of fulfilling those requests in a manner that maximizes speed and capacity utilization and ensures that no one server is overworked, which could degrade performance.
It is possible to use nginx as a very efficient HTTP load balancer to distribute traffic to several application servers and to improve performance, scalability and reliability of web applications with nginx.
There are 2 types of Load Balancer that can be built using Nginx. First is Layer 4 Load Balancer, the second one is Layer 7 Load Balancer.
The comprehensive Layer 7 load balancing capabilities in NGINX Plus enable you to build a highly optimized application delivery network. When you place NGINX Plus in front of your web and application servers as a Layer 7 load balancer, you increase the efficiency, reliability, and performance of your web applications.
http {
split_clients "${remote_addr}" $server_id {
33.3% 1;
33.3% 2;
33.4% 3;
}
server {
location ~* \.(gif|jpg|jpeg)$ {
return 301 "${scheme}://s${server_id}.site.com${request_uri}";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With