当前位置:网站首页>ECS 7-day practical training camp (Advanced route) -- day03 -- ecs+slb load balancing practice

ECS 7-day practical training camp (Advanced route) -- day03 -- ecs+slb load balancing practice

2022-06-25 19:07:00 Student Zhao who loves learning

ECS+SLB Load balancing practice

Server load balancing (Server Load Balancing), Can be seen as HSRP( Hot backup router protocol ) An extension of , Achieve load balancing between multiple servers .
A virtual server represents a cluster of real servers , When a client initiates a connection to a virtual server , Through some kind of load balancing algorithm , Forward to a real server .
There are two load balancing algorithms :
Weighted round robin(WRR) and Weighted least connections(WLC),
WRR Use weighted polling algorithm to allocate connections ,WLC Through certain weight , Assign the next connection to a server with a small number of active connections .
Configuration is divided into two parts ,
The first part is to use slb serverfarm serverfarm_name Command definition SLB Options , Including specifying the real server address ;
The second part is the use of ip slb vserver virtual_server-name To specify the virtual server address .

Load balancing checks the ECS pool by default ECS The health of the instance , Automatic isolation of abnormal state ECS example , Eliminates the need for a single machine ECS Single point of failure of the instance , Improve the overall service ability of the application .
Besides , Load balancing also has the ability to resist DDoS Ability to attack , Enhance the protection ability of application services .

There are three core concepts of load balancing service :

Load balancing instance (Server Load Balancer instances)

A load balancing instance is a running load balancing service , Used to receive traffic and allocate it to back-end servers . To use load balancing services , You must create a load balancing instance , And add at least one monitor and two ECS example .

monitor (Listeners)

Listening is used to check client requests and forward them to back-end servers . Monitoring will also check the health of the back-end server .

Back end servers (Backend Servers)

A set of ECS example . You can add... Separately ECS Instance to server pool , It can also be added and managed in batches through virtual server group or primary and standby server group .
 Insert picture description here

From Baidu Encyclopedia : What is? SLB

Let's do one here today SLB Load balancing practice , The platform used is still the online experiment module of Alibaba training camp , I think it's very good , There are the introduction and operation steps of the experiment , It's more suitable for Xiaobai entry , In addition, you don't need to apply for it yourself Ecs resources , This platform can provide online resources , But there is a quota every day , Interested partners can learn about : Ali training camp

Don't talk much , Let's start today's experiment : First, enter the advanced route of Ali training camp ( Here, you are considered to have registered an alicloud account and passed the authentication , Of course, if you have your own server, you can follow suit ), Click to enter today's experiment  Insert picture description here Click to enter the experiment ( Because I've done it before , So here's another experiment , Click in the same interface )
 Insert picture description here The steps of applying for resources after entering and ecs Refer to the previous tutorial for the meaning of each parameter : Quickly build Docker Environmental Science

Careful partners may have found that the resources applied for today are not the same as before , The difference is that after applying for resources today, we will be given two ecs example , Many people think that the system is wrong ? Actually, it's not what you think , Today's experiment is the load balancing experiment , In fact, to put it bluntly, it means to distribute things from one server to multiple servers to jointly handle various tasks  Insert picture description here After applying for resources, we need to put two ecs The public ip Copy and paste them into the browser to see if they work properly , Then we will find two ip The contents are similar , Just back-end servers IP It's different there , This means that the task can be run on two servers respectively
 Insert picture description here After verification, we will find that only when we enter two different ip To access different pages , In fact, the two servers are still running independently . Then we will think , Can you enter one of them ip We can visit two different pages at the same time ? Certainly. , We need to configure it first , Associate the two servers , The configuration operation is as follows :

Load balancing configuration

The main content of this section : Mount the two servers to the back end of load balancing , such , Users only need to access one IP Address or domain name , The load balancing server will automatically forward the user request to the corresponding back-end server according to the weight .

1. Through the following steps , Check the alicloud load balancing console :

1) Click... On the left navigation bar Cloud product resources View resource information , Click on One click Copy url, Invisible window with browser ( Or traceless mode ) Log in to the console ,
 Insert picture description here

2) Enter the information provided by the experiment Subuser name and Subuser password , Click when finished Sign in . Alicloud login management console .( This is not the account and password of the server . It is recommended that you log in with a new privacy window or another server , Otherwise, it will squeeze the main account we logged in before , It is not convenient for subsequent operations

 Insert picture description here 3) Click... On the left navigation bar Products and services , Drop down menu , stay Elastic calculation Under the entry, choose Load balancing .
 Insert picture description here 2. Click on the left Instance management , Then open the example provided by the experiment , On the instance list page , Click... To the right of the target instance Click I start to configure .( Here we need to pay attention to the area )
 Insert picture description here 3. Through the load balancing business configuration wizard , Configure load balancing Listening port 、 Back end servers and health examination :

1) stay agreement & monitor page , Enter the following information , After completion , Click on next step .

 Load balancing protocol : choice  HTTP
 Listening port : Set to  80
 Advanced configuration remains the default 

 Insert picture description here 2) stay Back end servers page , Listening requests are forwarded to Default server group , Click... At the added server Continue to add .

 Insert picture description here 3) In the pop-up server to be added page , Check the two pre configured cloud servers to select , And then click next , Then click add to ;
 Insert picture description here  Insert picture description here 4) In the list of added servers in the backend server interface , You can see the two new cloud servers , Separately port Set to 80, And click the next step .

explain : The load balancer will distribute requests in proportion to the weight of the input .
 Insert picture description here 5) stay health examination Configuration in progress , Turn on the health check button in green On state , Click on next step .
 Insert picture description here 6) stay Configuration audit page , Confirm that the above configuration is operating correctly , Click on Submit ; The following interface appears , After successful configuration , Click on got it ;
 Insert picture description here 7) here , The page will display a status of Running Load balancing monitoring instance of , Two back end server groups have been added ECS The server , And health examination The status of is normal .

Be careful : Usually waiting for 1 About 20 minutes, the state of health check became normal , Click on the right Refresh see .
 Insert picture description here  Insert picture description here Load balancing verification

The main contents of this section are as follows :

 Verify how load balancing works ;
 Verify by configuring different back-end server weights , Distribute users' requests to different back-end servers in proportion ;
 Verify that when a back-end server opens a session request , Requests will only be distributed to this server during session opening time .
  1. here , The weight ratio of the two back-end servers is the same . Through the following steps , Verify that the load balancing server is polling to access the back-end cloud server ECS example :

1) Click on the left side of the console Instance management , In the red box on the right page, you can see the load balanced Service address ( That is to say Cloud product resources Provided Load balancing Of IP Address ) ;
 Insert picture description here 2) Create a new page in the browser , And access Load balancing Of Service address . The interface shows Back end servers IP by Cloud server ECS-1( or Cloud server ECS-2) Of Intranet address .

explain : The address displayed on the interface is the intranet address , This is because load balancing accesses the back end ECS example , It's through the intranet .

 Insert picture description here 3) Refresh Browse page , According to the Back end servers IP It's going to change , Turn into Cloud server ECS-2( or Cloud server ECS-1) Of Intranet address ;
 Insert picture description here 4) Repeat the refresh operation , Observe Back end servers IP It's on two cloud servers Intranet address Take turns to change .

5) The above results prove that : Load balancing will send users' requests to different back-end servers for processing . such , It can reduce the load pressure of a single server , To ensure business continuity .

  1. Through the following steps , Modify the back-end server weight , Verify that the proportion of requests sent by load balancing to the back-end server is adjusted in proportion to the weight .

1) return Instance management page , Click on the Default server group ;
 Insert picture description here 3) Pop up dialog , Check Set different weights .

4) Set two instances of The weight Respectively 30 ,90 .

explain : The weights are configured as above , Load balancing through user access ,1/4 A request sent to a back end server ,3/4 The request is sent to another back-end server .

5) After completing the above configuration , Click on determine , Effective configuration information .
 Insert picture description here  Insert picture description here 7) Browser , Refresh multiple load balancing Service address The page of , And record what the page shows Back end servers IP . You can find : Every time 4 Refresh times , There will be 3 visit The weight by 90 Of ECS example ,1 The weight of each visit is 30 Of ECS example .

8) The above results prove that : Users can adjust the load balancer's request distribution according to the actual situation , Generally, set the weight of the server with high configuration , Lower the weight of server settings . This can avoid high concurrency , The server with lower configuration is under high pressure, and service exception occurs .

  1. Follow these steps , Turn on load balancing Conversation retention function .

1) Click on the left side of the monitor , On the monitor page, click... On the right To configure .

 Insert picture description here 2) Configure the Advanced configuration It's about , Click on modify ;
 Insert picture description here 3) Turn on Conversation retention , Timeout time Input 180 ( namely 3 minute ); Click when finished next step . Insert picture description here 4) Below Back end servers 、 health examination and Configuration audit All pages have default values , Complete the configuration in turn . Insert picture description here 5) Back to monitor page , Conversation retention state Enabled .
 Insert picture description here 4. Enter... Again in the browser Load balancing Of IP Address , Refresh many times , It is found that during the timeout period of session persistence, requests will only be distributed to one station ECS On ( Which one is it ECS There's no rule ), After the time has passed , Redistribute according to weight ratio .
 Insert picture description here 5. We turn it off and turn it on Conversation retention The one ECS . Default server group page , Added servers , Click on the target ECS The highlight of ( namely Cloud server ID).

 Insert picture description here 6. Instance details page , Click on... In the upper right corner 【 stop it 】 , Click on the pop-up page 【 determine 】 Close the current ECS.
 Insert picture description here  Insert picture description here wait for 1 About minutes , The state of the instance changes to Has stopped .
 Insert picture description here 7. Return to the load balancing management console , On the default server group page, click on... In the upper right corner 【 Refresh 】, The page is stopped after refreshing ECS Of state Turn into Has stopped .
 Insert picture description here 【 monitor 】 page , Also appear abnormal Tips .
 Insert picture description here alike , Click on the top left 【 Instance management 】, Return to the main page of the load balancing management console , abnormal The alarm will also appear .
 Insert picture description here 8. Refresh the browser again Load balancing Of IP Address , here , Request to Health check status by normal Of ECS On .
 Insert picture description here 9. it turns out to be the case that , When one of them ECS After exception , Load balancing will automatically send the request to the health check status normal ECS On .

原网站

版权声明
本文为[Student Zhao who loves learning]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190526002411.html