ALB and 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.
- Access CloudFormation
- Select STACK_NAME
- Select Outputs
- Select LoadBalancerDNS

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

- Access ECS
- Select Clusters
- Select Cluster-STACK_NAME

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

- 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

- Service updated successfully.

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

- Access CloudFormation
- Select STACK_NAME
- Select Outputs
- Select S3WebsiteURL

- Use a browser to access the S3WebsiteURL

- Perform actions to experience the user interface

- 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)

- Select Logs

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

- Check CloudWatch logs from ECS to ensure Like processed

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

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

- 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.
