Getting Started with Application Load Balancer
An Application Load Balancer is a load balancing option for the Elastic Load Balancing service that operates at the application layer and allows you to define routing rules based on content across multiple services or containers running on one or more Amazon Elastic Compute Cloud (Amazon EC2) instances.
Follow the below simple steps for setting up an application load balancer. This blog post also shows how you can switch from a classic load balancer to an application load balancer.Applications
We have two servers already setup with wordpress and drupal applications, respectively.Wordpress Application on one server
Drupal Application on another server
Create Target Groups for each of the application.Drupal Target Group:
Click on create target group.
Give name to the group. Select VPC and Configure the health checks.
Wordpress Target Group:
Similarly, create a target group for the wordpress application. Give a name. Select vpc and configure health checks.
Now, we have two targets groups for drupal and wordpress applications, respectively.
Register targets for each of the group.Drupal
Go to Targets tab. Click Edit.
Select the instance with drupal application running on it. Click Add to registered.
The instance will show under the Registered Instances.
Similarly, for the wordpress target group, register the instance with wordpress aplication running on it.
Go to Targets tab. Click Edit.
Select the wordpress server. Click Add to registered.
Save. The instance will get added to the Registered Instances.
Application Load Balancer
Create Load Balancer.
Select Application Load Balancer.
Configure the load balacer. Give a name. Choose subnets in each zone.
Select an existing one or create a new security group for the load balancer.
Configure Routing. Create new or select an already existing target groups for the default route.
We have selected drupal target group.
Since we have already registered the instance to the target group, the instance will automatically appear in Register Targets in the next screen.
Click Next and Reviews the configurations.
The Application Load Balancer will get started to provision.
The State will get changed from provisioning to active once it becomes available.
Now, add a rule to the listener so that whenever a path pattern for a rule is matched, ALB will route the traffic to the corresponding target group.
Go to Listeners tab, Click Add rule.
Specify path pattern and select the target group.
Similarly, create a rule set for wordpress.
Now, Hit the ALB’s DNS name with the path pattern /drupal. The Application will load.
Also, hit the ALB’s DNS name with path pattern /wordpress. The Application will load.
Let's enable SSL to our applications. Here, we are using ACM for the SSL certificates.
Specify path patterns for both the applications.
Switching Classic Load Balancer
If you want to migrate the classic load balancer to application load balancer, refer this link: https://github.com/aws/elastic-load-balancing-tools .
So, we have one classic load balancer as shown below:
The elastic-load-balancing-tool will copy the configuration of this classic load balancer to create a new application load balancer with same configurations. The command to create the application load balancer is:python copy_classic_load_balancer.py --name classic-load-balancer-name --region region-name
So a new application load balancer will be ready with same configurations as of classic load balancer.
To register instances, use the command:copy_classic_load_balancer.py --name my-load-balancer - region region-name --register-targets
and That's it..!! Happy Load Balancing across Applications..!! :)
本文开发（php）相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师