In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
I would like to share with you the example analysis of load balancing algorithm and failover in Nginx. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.
Overview
Nginx load balancer provides upstream servers (servers accessed by real business logic), load balancing, failover, failure retry, fault tolerance, health check, etc.
When the upstream server (the server accessed by real business logic) fails, it can be transferred to another upstream server (the server accessed by real business logic).
Configuration
Upstream backServer {server 127.0.0.1 server 8080; server 127.0.0.1 server 8081;} server {listen 80; server_name www.itmayiedu.com; location / {# specify upstream server load balancing server proxy_pass http://backServer; server}}
Load balancing algorithm
Each request is allocated to different back-end services one by one in chronological order. if a back-end server crashes, the fault system is automatically eliminated, so that user access is not affected.
Weight (polling weight)
The higher the value of weight, the higher the access probability, which is mainly used in the case of uneven performance of each server in the backend. Or just to set different weights in the case of master and slave 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 allocated according to the hash result of accessing IP, which enables visitors from the same IP to regularly access a back-end server, and can effectively solve the session sharing problem of dynamic web pages. Commonly known as IP binding.
Upstream backServer {server 127.0.0.1 server 8080; server 127.0.0.1 VR 8081; ip_hash;}
Fair (third party)
More intelligent load balancing algorithm than weight and ip_hash, fair algorithm can intelligently balance the load according to the page size and loading time, that is, allocate requests according to the response time of the back-end server, and give priority to the short response time. Nginx itself does not support fair, and if you need this scheduling algorithm, you must install the upstream_fair module.
Url_hash (third party)
Distribute requests according to the hash results of the accessed URL, so that each URL is directed to a back-end server, which can further improve the efficiency of the back-end cache server. Nginx itself does not support url_hash, and if you need this scheduling algorithm, you must install the hash package for Nginx.
Nginx configuration failover
When the upstream server (real access server), if there is a failure or there is no timely response, it should be trained directly to the next server to ensure the high availability of the server.
Timeout between nginx and upstream server (real accessed server) timeout of connection to backend server _ initiating handshake waiting for response timeout proxy_connect_timeout 1s
Nginx sent to upstream server (real access server) timeout proxy_send_timeout 1s
Nginx accepts upstream server (real access server) timeout proxy_read_timeout 1s
The above is all the contents of the article "example Analysis of load balancing algorithm and failover in Nginx". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.