In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you the experiments and collisions of nginx load balancing and apache, hoping to give you some help in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
Experimental results:
40.129 for the web (apache) interface display (figure 1) # Love letter in the snapshot at unknown time. 133 (master) nginx {Upstream module configured in http and server intermediate load balancer ip address is 40.133} 132 (slave) nginx
Knowledge development: (excerpt)
1. Polling (default)
Each request is assigned to a different backend CVM one by one in chronological order. If the backend server down is dropped, it can be automatically deleted.
2 、 weight
Specify the polling probability. The weight is proportional to the access ratio, which is used in the case of uneven performance of the backend server.
For example:
Upstream bakend {
Server 192.168.159.10 weight=10
Server 192.168.159.11 weight=10
}
3 、 ip_hash
Each request is allocated according to the hash result of accessing the ip, so that each visitor accesses a back-end server on a regular basis, which can solve the session problem.
For example:
Upstream resinserver {
Ip_hash
Server 192.168.159.10:8080
Server 192.168.159.11:8080
}
4. Fair (third party)
Requests are allocated according to the response time of the back-end server, and priority is given to those with short response time.
Upstream resinserver {
Server server1
Server server2
Fair
}
5. Url_hash (third party)
Allocate requests according to the hash result of accessing url, so that each url is directed to the same backend server, which is more effective when the backend server is cached.
Example: add hash statement to upstream. Other parameters such as weight cannot be written in server statement. Hash_method is the hash algorithm used.
Upstream resinserver {
Server squid1:3128
Server squid2:3128
Hash $request_uri
Hash_method crc32
}
Tips:
Upstream resinserver {# defines the Ip and device status of load balancing devices
Ip_hash
Server 127.0.0.1:8000 down
Server 127.0.0.1:8080 weight=2
Server 127.0.0.1:6801
Server 127.0.0.1:6802 backup
}
Added in server where load balancing is required
Proxy_pass http://resinserver/;
The status of each device is set to:
1.down indicates that the server before the order does not participate in the load for the time being.
The default 2.weight is that the larger the 1.weight, the greater the weight of the load.
3.max_fails: the number of requests allowed to fail defaults to 1. Returns the error defined by the proxy_next_upstream module when the maximum number of times is exceeded
Time to pause after 4.fail_timeout:max_fails failure.
5.backup: all other non-backup machines down or request backup machines when they are busy. So this machine will be the least stressed.
Nginx supports setting multiple groups of load balancers at the same time, which can be used by unused server.
If client_body_in_file_only is set to On, the data from client post can be recorded into a file to be used as debug.
The directory of client_body_temp_path settings record files can be set up to 3-tier directories
Location matches the URL. You can redirect or do new agent load balancing.
After reading the above experiments and collisions between nginx load balancing and apache, if you have 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.