650) this.width=650; "alt=" 9.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029897926031240.jpg "/>
The LBaaS configuration was completed in the previous section, and today we begin to implement the following LBaaS environment.
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029898381055917.jpg "alt=" upload-ueditor-image-20161206-1481029898 "/>
The environment is described as follows:
1. Create a Pool "Web Servers".
2. Two pool member "WEB1" and "WEB2" are all instance running Ubuntu cloud image.
3. The load balancer VIP is associated with the floating IP.
4. The client on the extranet accesses the Web server through the floating IP extranet.
We start with the first step.
Create Pool
Click on the "Add Pool" button on the Pools tab in the menu Project, Network, and Load balancers.
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029898564061948.jpg "alt=" upload-ueditor-image-20161206-1481029898 "/>
Displays the Pool creation page.
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029898969022368.jpg "alt=" upload-ueditor-image-20161206-1481029898 "/>
Name the Pool "Web Servers".
Provider Select the default "Haproxy".
Subnet Select "172.16.100.0/24". Protocol Select "HTTP".
Load balancing Method Select "Round_robin".
Click on the "Add" button and "Web Servers" was created successfully.
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899172073606.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Here is a description of several properties of the Pool.
LBaaS supports the following types of Protocol:
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899351008975.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Because we do experiments with Web server, we need to select "HTTP"
LBaaS supports multiple load balance method:
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899454081829.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Round_roubin
If the round robin algorithm is used, load balancer selects the connection request member the corresponding client from the pool in a fixed order. The inadequacy of this method is the lack of mechanisms to check whether the member is overloaded. It is possible that some member will have to continue to handle new connections because of weak processing power. If all pool member have the same processing power, memory capacity, and each connection lasts approximately the same amount of time, this is a good fit for round robin, and each member load is balanced.
Least_connections
If the least connections algorithm is used, the load balancer picks the pool member with the least current number of connections. This is a dynamic algorithm that requires real-time monitoring of the number and status of each member connection. The computationally powerful member can process the connection more quickly and then allocate more new connections.
Source_ip
If the source IP algorithm is used, a connection with the same source IP will be distributed to the same pool member. The source IP algorithm is especially useful for applications like shopping carts that need to be saved, because we want to use the same server to handle a continuous online shopping operation for a client.
In our experiment, we chose the round_roubin algorithm.
Add VIP to Pool
Now that the Pool is ready, you need to set up a VIP for it. In the "Web Servers" action list, click "Add VIP".
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899572061684.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
The VIP is named "VIP for Web Servers".
VIP Subnet Select "172.16.100.0/24", consistent with pool.
Specifies that the VIP is 172.16.100.11, and if not specified, the system is automatically assigned from the subnet.
Specify HTTP Port 80.
Session Persistence Select "SOURCE IP".
The number of connections can be restricted by Connection limit, or unrestricted if not specified.
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899669064057.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Click "Add" and the VIP creation is successful.
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899765041082.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Usually we want to have the same server handle a client's continuous request. Otherwise, the client may have to log back in due to a missing session.
This feature is the Session persistence. The VIP supports the following several Session persistence methods:
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899893007244.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Source_ IP
This is the same way as the previous load balance source_ip effect. After the initial connection is established, subsequent client requests from the same source IP are sent to the same member. When a large number of clients access the VIP through the same proxy server, such as the Internet in the company and the school, the Source_ip method causes member load inequality.
Http_cookie
Http_cookie works as follows: When the client first connects to the VIP, HAProxy picks up a member from the pool. When this member responds to a request, HAProxy injects a cookie named "SRV" in the response message that contains the unique identity of the member. Subsequent requests from the client will contain this "SRV" cookie. HAProxy analyzes the contents of the cookie and forwards the request to the same member.
Http_cookie is superior to source_ip because it does not rely on client IP.
App_cookie
App cookies rely on server-side app-defined cookies. For example, the app can differentiate between clients by creating a cookie in the session.
HAProxy will check the app cookie in the message to ensure that the request containing the app cookie is sent to the same member.
If there is no cookie (a new connection or a server app does not create a cookie), HAProxy uses the Round_roubin algorithm to allocate the member.
Compare Load Balance Method and Session persistence
We've introduced three Load Balance Method in front of us:
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899454081829.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
There are also three kinds of Session persistence:
650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029899893007244.jpg "alt=" upload-ueditor-image-20161206-1481029899 "/>
Because both involve how to choose pool Member, it is easy to confuse. The biggest difference between them is the different stages of choosing the pool member:
Load Balance method is a way to select member for a new connection
Session persistence is a way to select member for subsequent connections to the same client
For example, here are our settings:
Load Balance Method--Round_roubin
Session Persistence--SOURCE_IP
When client A sends the first request to the VIP, HAProxy selects member1 through Round_roubin. for client A subsequent requests, HAProxy applies the source_ip mechanism and still chooses member1 to process the request.
After the pool is created, we add Member to the pool in the next section.
650) this.width=650; "alt=" QR code + fingerprint. png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20161206-1481029900242091402.jpg "/>
Create Pool & VIP-Play 5 minutes a day OpenStack (122)