At the March 28, 2017 Weave Online User Group, Abby Fuller presented on Amazon ECS, find the part 1 recap here. Her comments on ECS best practices are summarized below. Following her talk, Mike Lang of Weaveworks described Weave Cloud’s integration with ECS clusters, and how Weave Scope’s visual depiction of ECS clusters facilitates troubleshooting.
ECS Specific Best Practices
Abby apportioned ECS best practices into five topics. These include:
- Version Control everything
- ALB vs ELB
- Cattle and not pets
- Maximize your resources
Version Control Everything
Utilize the Docker tag for version control. Most people use the Docker tag as a human readable description such as “web_server,” “authentication_module,” “dev,” and so on. Others tag it to a specific commit. It is more useful to use the Docker tag to tie back to a CI/CD build.
ALB vs ELB
As previously mentioned, the benefits of using ALB verses ELB is that routing policies are based on content, thereby allowing dynamic port assignment. ALB’s efficient use of multiple services can save money.
Cattle, not pets
“Cattle and pets” is a term by Randy Bias that has spread widely in the DevOps world. Architect the container as immutable/disposable. The phrase means a containers can be terminated anytime without data loss.
Best practices to keep in mind:
Maximize your resources:
- Use ECS Task placement policy to maximize resources
- Set sensible resource limits
- Use a scaling policy to scale up or down and preclude resources from running idle
- Take advantage of the built-in AWS alert system such as aws-log driver or CloudWatch
- Put checks or limits on services or clusters scaling
- Log parsing is important to avoid unnecessarily sending an alert
Weave Cloud integration with ECS
After Abby’s presentation, Mike Lang of Weaveworks presented how Weave Cloud integrates with ECS clusters. He also demonstrated how Weave Scope can be used to view ECS clusters for troubleshooting.
There are 2 ways to integrate Weave Cloud with ECS.
First, use the ECS-optimized AMI (Amazon Machine Image) that has Weave Net and Weave Scope installed. This AMI will automatically:
- Install Weave Net for container and container networking
- Install Weave Scope probes on individual instances. This Scope probe is used to collect data on the instance and put that to Weave Cloud to render what is going on in the ECS cluster
- Install a configuration file to store the user credential/authentication token, which allows data to be pushed to Weave Cloud
The second way is to use an AMI provided from the user. The user will have to manually install the Weave Scope probe and the configuration file that stores the user credentials. The probe and config file make it possible to send the collected data to Weave Cloud.
This article describes in how to perform the integration of Weave Cloud with ECS.
Mike then showed how to view microservices deployed on ECS with Weave Cloud:
This is the view by services running on the ECS Cluster:
Here is the view by process:
Here is the view by hosts:
And finally, this is Weave Cloud showing the detail of a service: