ALB and ECS Service

Scale the adoption platform monolith with an ALB and an ECS Service

Scale the adoption platform monolith with an ALB and an ECS Service

The Run Task method used in the previous section is great for testing, but if you need to run the adoption platform as a long-running process, you need to use an Elastic Load Balancing Application Load Balancer (ALB) to distribute requests to your running containers. Besides simple load balancing, it also enables capabilities like path-based routing to different services.

ECS helps maintain the number of desired tasks (the number of containers running over a long period) and integrates with ALB (handling the registration / deregistration of containers with the ALB).

The initial ECS service and ALB were created by CloudFormation. In this lab, you will update those resources to host the containerized monolith service. Later, you will create a new service from scratch after breaking up the monolith.

  1. Access CloudFormation
  • Select STACK_NAME
  • Select Outputs
  • Select LoadBalancerDNS

Deploy the container using AWS Fargate

  1. Use a browser to access the LoadBalancerDNS (remember to access via HTTP)

Deploy the container using AWS Fargate

  1. Access ECS
  • Select Clusters
  • Select Cluster-STACK_NAME

Deploy the container using AWS Fargate

  1. In the Cluster-STACK_NAME interface, we proceed to update the service
  • Select Services
  • Click on Update

Deploy the container using AWS Fargate

  1. In the service update interface
  • Select the latest Revision (the image shows 3 because a previous creation failed causing a revision increase; if done correctly, it will be revision 2)
  • Select Update

Deploy the container using AWS Fargate

  1. Service updated successfully.

Deploy the container using AWS Fargate

  1. In the Cluster-STACK_NAME interface
  • Select Tasks
  • Verify that Monolith-Definition-STACK_NAME has been updated

Deploy the container using AWS Fargate

  1. Access CloudFormation
  • Select STACK_NAME
  • Select Outputs
  • Select S3WebsiteURL

Deploy the container using AWS Fargate

  1. Use a browser to access the S3WebsiteURL

Deploy the container using AWS Fargate

  1. Perform actions to experience the user interface

Deploy the container using AWS Fargate

  1. Access ECS
  • Select Cluster
  • Select Cluster-STACK_NAME
  • Select Tasks
  • Select Monolith-Definition-STACK_NAME (the image shows 3 because a previous creation failed causing a revision increase; if done correctly, it will be revision 2)

Deploy the container using AWS Fargate

  1. Select Logs

Deploy the container using AWS Fargate

  1. Check the logs to ensure the monolith can read and write to DynamoDB and can process likes.

Deploy the container using AWS Fargate

  1. Check CloudWatch logs from ECS to ensure Like processed

Deploy the container using AWS Fargate

  1. To distinguish between a service and a task. We can perform the following steps:
  • Select the service with the latest Revision
  • Select Update

Deploy the container using AWS Fargate

  1. Increase the number of Desired tasks to 3 and update.

Deploy the container using AWS Fargate

  1. After a successful update.
  • Select Tasks and you will see 3 running tasks.
  • From there, we see that ECS services is a concept where ECS allows running and maintaining a specific number of containers of task definitions within an ECS cluster. A service consists of multiple tasks and is maintained.

Deploy the container using AWS Fargate