Overview Nginx load balancing provides upstream servers (servers accessed by real business logic), load balancing, failover, failure retry, fault tolerance, health checks, etc. Configuration upstream backServer{ server 127.0.0.1:8080; server 127.0.0.1:8081; } server { listen 80; server_name www.itmayiedu.com; location / { ### Specify the upstream server load balancing server proxy_pass http://backServer; index index.html index.htm; } } Load Balancing Algorithm Each request is assigned to a different backend service in chronological order. If a backend server crashes, the faulty system will be automatically removed so that user access is not affected. weight (polling weight) The larger the weight value is, the higher the probability of access is. It is mainly used when the performance of each backend server is uneven. Or just set different weights in the master-slave situation to achieve reasonable and effective use of host resources. Usually in proportion upstream backServer{ server 127.0.0.1:8080 weight=1; server 127.0.0.1:8081 weight=2; } ip_hash Each request is assigned according to the hash result of the access IP, so that visitors from the same IP address can access a fixed backend server and effectively solve the session sharing problem of dynamic web pages. Commonly known as IP binding. upstream backServer{ server 127.0.0.1:8080 ; server 127.0.0.1:8081 ; ip_hash; } fair (third party) The fair algorithm is a smarter load balancing algorithm than weight and ip_hash. It can intelligently balance the load according to the page size and loading time. That is, it allocates requests according to the response time of the backend server, giving priority to requests with shorter response time. Nginx itself does not support fair. If this scheduling algorithm is required, the upstream_fair module must be installed. url_hash (third party) Distributing requests according to the hash results of the accessed URLs so that each URL is directed to a backend server can further improve the efficiency of the backend cache server. Nginx itself does not support url_hash. If this scheduling algorithm is required, you must install the Nginx hash package. Nginx configuration failover
The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL multi-table join query example explanation
>>: Detailed explanation of two methods for setting global variables and session variables in MySQL
Table of contents Local Mixin Global Mixins Summa...
Centos7 uses yum to install MySQL and how to achi...
Table of contents 1. Build basic styles through E...
Without further ado, these three methods are: ren...
Table of contents 1. Developer Platform Configura...
Table of contents Effect Start creating text Firs...
1. Requirements: Database backup is particularly ...
In MySQL, we usually use limit to complete the pa...
During the work development process, a requiremen...
Today we will learn how to use CSS to create a co...
dl:Definition list Definition List dt:Definition t...
Table of contents What utilities does VueUse have...
1 What is MVCC The full name of MVCC is: Multiver...
Table of contents Easy to use Create a project vu...
When you write buttons (input, button), you will f...