This article is a mirror article of machine translation, please click here to jump to the original article.

View: 27491|Reply: 2

[Web] Practical configuration of NGINX High Availability Load Balancing

[Copy link]
Posted on 6/14/2020 11:50:26 AM | | | |
I have been using Alibaba Cloud's load balancing for more than 6 years, and I have been using nginx for more than 6 years.

Load balancing builds on existing network structures and provides a cheap, effective, and transparent way to scale network equipment and servers bandwidth, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.
Load balance means that it is distributed to multiple operating units, such as web servers, FTP servers, enterprise critical application servers, and other mission-critical servers, so as to jointly complete work tasks.

Simply put, it distributes multiple requests to different servers on the backend to reduce the pressure on each server and achieve high availability, even if one server hangs up, it has no impact.

First of all

I installed node.js natively and installed http-server to emulate two web containers. (Use IIS, or implement the HTTP protocol with your own code)

After installing node.js, run the following command:

window, install http-server in nodejs and turn on the HTTP server
https://www.itsvse.com/thread-6838-1-1.html

Simulate two backend sites

I created two new folders, site1 and site2, under the E:\wwwroot directory, each with a index.html file in it.



The contents are: index 1 by:itsvse.com and index 2 by:itsvse.com


Then, listen to the two HTTP ports with the following command to open the two sites.

Try accessing both stations separately:The hyperlink login is visible. The hyperlink login is visible.The renderings are as follows:



NGINX load balancing configuration

Download the Windows version of nginx at the following address:The hyperlink login is visible.

Once downloaded, extract it to the E:\wwwroot\nginx-1.18.0 directory. Modify the E:\wwwroot\nginx-1.18.0\conf\nginx.conf file as follows:



Start the nginx program with the following command:



nginx -s stop        fast shutdown
nginx -s quit        graceful shutdown
nginx -s reload        changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
nginx -s reopen        re-opening log files

Accessing the nginx load balancing site via a browser:The hyperlink login is visible.



We refresh and revisit many times, and find that the content returned is different each time, and you can see that nginx distributes different requests to different http services on the backend,Trying to stop the site1 site, we can see that it does not affect our normal access, and nginx forwards all requests to the site2 site

Nginx load balancing configuration status
stateOverview
downThe current server does not participate in load balancing for the time being
backupReserved backup servers are enabled when all other servers are hung up
max_failsThe number of failed requests allowed, if the number of failed requests exceeds the limit, kill the server from the virtual service pool after fail_timeout time
fail_timeoutAfter a max_fails failure, the service pauses time, max_fails the fail_timeout value must be set
max_connsLimit the maximum number of connections for different server hardware configurations


Nginx load balancing scheduling policy

Scheduling algorithmsOverview
PollotPoll one by one, the default method
weightWeighted polling, the higher the weight, the higher the chance of distribution
ip_hashThe allocation of hash results from the accessing IP will cause requests from the same IP address to access a fixed background server
url_hashAssign according to the hash result of the visited URL
least_connThe minimum number of links, the server with fewer links will be assigned
hash key valuehash custom key


For more information about nginx configurations, see:The hyperlink login is visible.





Previous:Nginx log splitting and deletion
Next:The concept and difference between ITO, BPO, KPO, and the three
 Landlord| Posted on 3/16/2021 3:48:20 PM |
nginx: [emerg] CreateFile() "C:\360安全浏览器下载\nginx-1.18.0/conf/nginx.conf" failed (1113: No mapping for the Unicode character exists in the target multi-byte code page)
nginx: configuration file C:\360安全浏览器下载\nginx-1.18.0/conf/nginx.conf test failed


nginx paths cannot be created by Chinese
 Landlord| Posted on 1/10/2023 7:31:52 PM |
【Practical Action】Web high availability tutorial for Keepalived and Nginx
https://www.itsvse.com/thread-10118-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com