Seven-layer load (application Gateway) + four-layer load (LB)

Source: Internet
Author: User

Last time an e-commerce client needs to be built as a framework.

192.168.1.100/URL1 (request URL)-->node1:10.0.0.4, 10.0.0.5 (server IP)

192.168.1.100/URL2 (request URL)-->node2:10.0.0.6, 10.0.0.7 (server IP)

A client allocates traffic based on the request URL,/URL1 traffic goes to Node1, and then Node1 the node for a traffic load. Then this scenario can use seven-layer load balancing (application Gateway) + four-layer load balancing (LB), the frame composition is as follows:

This architecture is easy to implement on Azure because Azure directly provides 7-tier and 4-tier load-balanced pass services.

1. Create a virtual machine (application server)

As shown in the schema, here I need to create four virtual machines, the specific steps to create a virtual machine here will not repeat.

As shown, I have created four virtual machines: IMAGEVM01, imagevm02, VIDEOVM01, videovm02

I then installed IIS for each of the four virtual machines and deployed a Web site with a unique identity for each virtual machine deployment site.

2. Create a four-tier load balancer (load Banlancer)

Create a two load Banlancer as shown in

As I've created two load Banlancer:imagelb, Videolb

Then we need to add imagevm01, imagevm02 to the Imagelb back-end pool, respectively.

VIDEOVM01, videovm02 join the Videolb backend pool

3. Create a seven-tier load balancer (application Gateway)sign in to Azure

Login-azurermaccount-environmentname Azurechinacloud

Create a resource group or get a resource group

Because we created the virtual machine and the four-tier load balancer already created the resource group, put application gateway and these resources in a resource group to

Get-azurermresourcegroup-name "{Resource group Name}"-location ""

Or you can create a new resource group.

New-azurermresourcegroup-name appgwrg-location "China East"

get a virtual network

$vnet = get-azurermvirtualnetwork-resourcegroupname "{Resource group name}"-name "{virual Network Name}"

Assign subnet variables to facilitate subsequent steps to create an application gateway.

$subnet = $vnet. Subnets[0]

Create a public IP address for the front-end configuration

Create the front-end public IP, which is the IP address of the application gateway we end up accessing

$publicip = New-azurermpublicipaddress-resourcegroupname appgwrg-name publicip01-location "China North"- Allocationmethod Dynamic

Create an Application gateway configuration

Create an application Gateway IP configuration named "GatewayIP01". When an application gateway is started, it obtains an IP address from the configured subnet and then routes network traffic to the IP address in the backend IP pool. Keep in mind that each instance requires an IP address.

$gipconfig = New-azurermapplicationgatewayipconfiguration-name gatewayip01-subnet $subnet

Configure the backend IP address pool named "Pool01" and "pool2" respectively, where the IP address of "Pool1" is Imagelb IP Address "42.159.242.134 (IMAGELBPUBLICIP)"; "Pool2" IP The address is Videolb IP address "139.219.185.186 (VIDEOLBPUBLICIP)".

$pool 1 = new-azurermapplicationgatewaybackendaddresspool-name pool01-backendipaddresses 134.170.185.46, 134.170.188.221,134.170.185.50

$pool 2 = new-azurermapplicationgatewaybackendaddresspool-name pool02-backendipaddresses 134.170.186.46, 134.170.189.221,134.170.186.50

Configure Application Gateway settings for network traffic that is load balanced in the backend pool "poolsetting01" and "poolsetting02"

$poolSetting new-azurermapplicationgatewaybackendhttpsettings-name = "Besetting01"-port 80-protocol Http- Cookiebasedaffinity Disabled-requesttimeout 120

$poolSetting new-azurermapplicationgatewaybackendhttpsettings-name = "besetting02"-port 80-protocol Http- Cookiebasedaffinity Enabled-requesttimeout 240

Configure the front-end IP with a public IP endpoint

$fipconfig new-azurermapplicationgatewayfrontendipconfig-name = "Frontend1"-publicipaddress $publicip

Configure the front-end ports for application gateways

$fp new-azurermapplicationgatewayfrontendport-name = "FEP01"-port 80

Configure the listener. This step configures the listener for the public IP address and connection port that is used to receive incoming network traffic.

$listener = New-azurermapplicationgatewayhttplistener-name "Listener01"-protocol http-frontendipconfiguration $ Fipconfig01-frontendport $fp 01

Configure the URL rule path for the back-end pool

$imagePathRule = New-azurermapplicationgatewaypathruleconfig-name "Pathrule1"-paths "/image/*"-backendaddresspool $ Pool1-backendhttpsettings $poolSetting 01

$videoPathRule = New-azurermapplicationgatewaypathruleconfig-name "Pathrule2"-paths "/video/*"-backendaddresspool $ Pool2-backendhttpsettings $poolSetting 02

Configure the default back-end pool, if the path does not conform to any of the predefined path rules, the rule path is mapped to the default back-end pool

$urlPathMap = New-azurermapplicationgatewayurlpathmapconfig-name "Urlpathmap"-pathrules $videoPathRule, $ Imagepathrule-defaultbackendaddresspool $pool 1-defaultbackendhttpsettings $poolSetting 02

Create Rule settings

$rule new-azurermapplicationgatewayrequestroutingrule-name = "Rule1"-ruletype Pathbasedrouting-httplistener $ Listener-urlpathmap $urlPathMap

Configure the number of instances and the size of the application gateway

$sku = New-azurermapplicationgatewaysku-name "Standard_small"-tier standard-capacity 2

Create an Application gateway

$APPGW = New-azurermapplicationgateway-name appgwtest-resourcegroupname appgwrg-location "China East"- Backendaddresspools $pool 1, $pool 2-backendhttpsettingscollection $poolSetting, $poolSetting 02- Frontendipconfigurations $fipconfig 01-gatewayipconfigurations $gipconfig-frontendports $fp 01-httplisteners $ Listener-urlpathmaps $urlPathMap-requestroutingrules $rule 01-sku $sku

Get the Application Gateway DNS name

Get-azurermpublicipaddress-resourcegroupname Appgw-rg-name publicIP01

Test Access

/image will be routed to IMAGE01 or IMAGE02

/video will be routed to VIDEO01 or Video02

Seven-layer load (application Gateway) + four-layer load (LB)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.