Create and use AWS-elastic load balance (I)

Source: Internet
Author: User
Tags elastic load balancer

Elastic Load balancer is an important feature in EC2. It can be used with auto scaling and The multip-Az of RDS to implement a very cost-effective and highly available structure.


Let's first look at the most basic ELB structure. ELB uses DNS rotation to distribute data and achieve high availability for user requests.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/36/wKioL1PgEBnC017wAABe3K-X22s819.png "style =" float: none; "Title =" 0.png" alt = "wKioL1PgEBnC017wAABe3K-X22s819.png"/>

The following experiment designs enterprise training teaching plans from Amazon (beans are found online but not bad ). Here I will create two web servers and automatically configure the bootstrap shell script through user data. The advantage is that I do not need to manually configure the server after it is set up.


The process of creating an EC2 instance is very simple. in step 3, you need to add some shell scripts to the advanced layer. This command downloads a sh script from the specified URL and runs


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/35/wKiom1PgDwGy82SPAACnWmOJHt4495.png "style =" float: none; "Title =" 1.png" alt = "wkiom1pgdwgy82spaacnwmojht4495.png"/>

The sh Content is to automatically install lamp-related programs and decompress some pre-configured PHP files in the Apache directory.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/35/wKiom1PgEKnyZgDHAAAuuZl9vYM675.png "Title =" Sh. PNG "alt =" wkiom1pgknyzgdhaaauuzl9vym675.png "/>


Virtual Machine created


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/35/wKiom1PgDwHDUVQEAABjbIWnttI653.png "style =" float: none; "Title =" 2.png" alt = "wkiom1pgdwhduvqeaabjbiwnti653.png"/>


If the script is not executed, you can see that examplefiles.zip has been decompressed. In this way, when we open the public address or DNS of the server, the index. php file will be automatically loaded and some data we want to see will be displayed for comparison.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/36/wKioL1PgEBuQJ9s8AAA11XLHkQM416.png "style =" float: none; "Title =" 3.png" alt = "wkiol1pgbuqj9s8aaa11xlhkqm416.png"/>


See what the index. php file is.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/36/wKioL1PgEBuS2q4uAACFzh3E9vA114.png "style =" float: none; "Title =" 4.png" alt = "wkiol1pgbus2q4uaacfzh3e9va114.png"/>

Enter the DNS of EC2 in the browser and you can see the instance number of the virtual machine, AZ region and CPU load.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/44/35/wKiom1PgDwKhRnaXAAAvNKBJ1S8601.png "style =" float: none; "Title =" 5.png" alt = "wkiom1pgdwkhrnaxaaavbj1s8601.png"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/35/wKiom1PgDwKR8Hk_AAApxZwTPGA293.png "style =" float: none; "Title =" 6.png" alt = "wkiom1pgdwkr8hk_aaapxzwtpga293.png"/>


Now let's create an ELB

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/36/wKioL1PgEByyyl3hAACGQXFrbMA662.png "style =" float: none; "Title =" 7.png" alt = "wkiol1pgbyyyl3haacgqxfrbma662.png"/>


Enter the name and subnet. Here we only need a simple port 80.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/44/36/wKioL1PgEB3Qrp8UAAB9GqGUNsA247.png "style =" float: none; "Title =" 8.png" alt = "wkiol1pgb3qrp8uaab9gqgunsa247.png"/>

Ping protocol is used for health check. It is automatically pinged to port 80 every five seconds.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/35/wKiom1PgDwSQw2ubAABsab_k5Dw258.png "style =" float: none; "Title =" 9.png" alt = "wkiom1pgdwsqw2ubaabsab_k5dw258.png"/>

Configure Security Group

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/44/36/wKioL1PgEB3AgCZrAABZ5s1-9QA688.png "style =" float: none; "Title =" 10.png" alt = "wKioL1PgEB3AgCZrAABZ5s1-9QA688.png"/>

Add the two web servers we configured earlier to ELB

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/44/35/wKiom1PgDwTApw16AACD3woJ9qk880.png "style =" float: none; "Title =" 11.png" alt = "wkiom1pgdwtapw16aacd3woj9qk880.png"/>


Just confirm it.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/35/wKiom1PgDwXR85iuAACHBjcjbgE861.png "style =" float: none; "Title =" 12.png" alt = "wkiom1pgdwxr85iuaachbjcjbge861.png"/>

In this way, it is created. Note his port configuration. ELB is a bit similar to the proxy server or NAT server, so port 80 enters him and forwards it to port 80 of the server in the cluster.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/36/wKioL1PgEB-CB-VKAABMitujfbE126.png "style =" float: none; "Title =" 13.png" alt = "wKioL1PgEB-CB-VKAABMitujfbE126.png"/>

You can use cname to create a simple and memorable name.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/36/wKioL1PgEB_g8Mh-AACRIbHN6EU982.png "style =" float: none; "Title =" 14.png" alt = "wKioL1PgEB_g8Mh-AACRIbHN6EU982.png"/>

The status surface is already Inservice, ready


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/44/35/wKiom1PgDwaT7ELPAAB3WTYW0vM766.png "style =" float: none; "Title =" 15.png" alt = "wkiom1pgdwat7elpaab3wtyw0vm766.png"/>

Finally, let's test. Enter the elb url. Each refresh will point to different Web servers for shunting.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/44/35/wKiom1PgDwaAKVSGAAAigc_bPME131.png "style =" float: none; "Title =" 16.png" alt = "wkiom1pgdwaakvsgaaaigc_bpme131.png"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/36/wKioL1PgECDCN6ZwAAAnqaUYRwU574.png "style =" float: none; "Title =" 17.png" alt = "wkiol1pgcdcn6zwaaanqauyrwu574.png"/>


We can also use cloudwatch to check the metric parameters of elb.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/44/36/wKioL1PgECLwu0hbAADlM3xDCXU299.png "style =" float: none; "Title =" 18.png" alt = "wkiol1pgeclwu0w.adlm3xdcxu299.png"/>



This is a basic ELB implementation.


In the next blog, let's take a look at how to use auto scaling to dynamically create and delete virtual machines under different loads.

This article from the "Mapo tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1535769

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.