In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you how nginx configures http load balancer, hoping to give you some help in practical application. Load balancing involves a lot of things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
According to the official documentation, the example shown below is given first.
Http {
Upstream myapp1 {
Server srv1.example.com
Server srv2.example.com
Server srv3.example.com
}
Server {
Listen 80
Location / {
Proxy_pass http://myapp1;
}
}
}
This example is to configure a http load balancer cloud server group named myapp1.
That is, the basic configuration format and syntax of http load balancing
Nginx load balancing includes three mechanisms: rotational training (round-robin), least connection (least-connected) and IP hash (ip-hash).
Rotational training: http requests sent to the server are rotated to the server in the load balancer configuration
Minimum connections: http requests sent to the server side are assigned to the server with the least number of active links in the load balancing configuration
IP hash: uses a hash method based on the client's IP address to determine which server is assigned to the request
The configuration method is as follows:
Least connection load balancer
Upstream myapp1 {
Least_conn
Server srv1.example.com
Server srv2.example.com
Server srv3.example.com
}
Ip hash
Upstream myapp1 {
Ip_hash
Server srv1.example.com
Server srv2.example.com
Server srv3.example.com
}
Rotational training
Upstream myapp1 {
Server srv1.example.com weight=3
Server srv2.example.com
Server srv3.example.com
}
Explanation: weight is weighted and defaults to 1. If there are five requests, the first three requests will be assigned to srv1, the fourth request to srv2, and the fifth request to srv3, and so on.
Note:
1. Default is rotational training.
2, the minimum number of connections and rotation mechanism will assign client requests to different servers during the client-server session, while ip hashes can maintain the session and keep the requests on the same server all the time
After reading the above about how nginx configures http load balancer, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.
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.