In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Principle and practice of load balancing algorithm
Load balancing algorithm (load balancing algorithm) defines several basic traffic distribution methods. There are four standard load balancing algorithms in Istio.
Round_Robin: polling algorithm. As the name implies, requests will be sent to each instance in turn to share all requests.
Random: random algorithm that randomly distributes all requests to healthy instances
Least_Conn: the minimum number of connections. Choose two of all healthy instances and send the request to the instance with a smaller number of connections.
Next, we will combine the above algorithms with the monitoring topology diagram of APM (Application performance Management) to practice.
Actual combat environment
Huawei Cloud launched the CCE cluster of Istio service grid
Official best time for Bookinfo application, and five instances are configured for Reviews
Activate APM testing service (free)
We know that if the user does not make any configuration, the load balancing algorithm defaults to the polling algorithm, so we now set the load balancing algorithm to Random.
Step 1
Click Application Management on the interface of Cloud Container engine, and select Traffic Management.
Step 2
The topology diagram appears on the right. Select Cluster, Namespace, and Application in the options bar above. Then click on the component we want to configure. Here is reviews, and the interface for traffic governance will appear on the right.
Step 3
In the load balancing algorithm, Round_Robin is changed to random.
Step 4
Select Traffic Monitoring under Traffic Governance in the left navigation bar, and then select the appropriate cluster, namespace, and application. You can view the data from the topology diagram by visiting a few more times, or writing scripts in the background to curl productpage all the time.
Step 5
When there is traffic, right-click the reviews component and select the expand option. Then we can see how all the instances are distributed.
Instance number 1 2 3 4 5
The number of visits 62 38 39 42 52
The rest of the load balancing algorithms are basically the same. We will not repeat the steps and show the results directly.
Polling algorithm:
Instance number 1 2 3 4 5
Number of visits 47 47 48 46 47
Second, the principle of conversation persistence and actual combat.
Session persistence (Session Affinity) is calculated by a set metric, and requests with the same hash value are distributed to a fixed instance for processing. It now supports setting metrics based on HTTP headers and Cookie keys.
We are currently in the polling algorithm, so all requests are evenly distributed to all instances. Set session persistence to be based on HTTP request headers and set to Cookie. The request cookie of our backend curl is set to a fixed value, and theoretically all requests will be distributed to the same pod.
We still use traffic monitoring and expand the reviews component to observe the distribution.
All requests are distributed to the second instance, and the session link is maintained because the cookie is consistent.
Third, the principle and practice of fault injection
Fault injection (Fault Injection) is a means of verification of reliability and stability for developers and testers to actively introduce faults into the system to observe the behavior of the system under abnormal conditions. Istio also supports non-intrusive injection faults, which can be divided into delay faults and interrupt faults.
The steps for fault injection are roughly the same at the bottom of the traffic governance page, select delay fault, and enter the trigger percentage and delay time. Then open productpage to refresh manually several times, and you can obviously feel the change in delay. Of course, you can also open the F12 debugging interface to observe the status of network requests. It is not difficult to find that productpage requests take about 2 seconds.
At this time, we open the traffic monitoring interface and observe that productpage and reviews have been significantly affected. Red indicates that the request status is extremely poor, and the dotted line indicates that it is caused by delay.
Next we will test and use the interrupt fault, we configure the interrupt fault for details, and the interrupt return code is set to 501.
After the configuration, let's manually visit the productpage a few times to observe the results.
It is found that the details on the right has already reported error.
When we go back to the traffic monitoring diagram, we can see the access between components. After the interrupt failure is configured for ratings, the reviews component that originally called the ratings component can no longer communicate with ratings.
This article demonstrates the main functions of traffic governance based on Huawei cloud istio service and APM service. I hope you can take advantage of istio's flexible non-intrusive governance capabilities to improve the efficiency of development and testing in future development and testing.
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.