Reputation: 6340
I have used AWS ECS before. I understand the basic concepts between ECS Cluster vs ECS Service vs ECS task. What I haven't quite wrapped my head around is when I should create a new Cluster vs re-using an existing ECS Cluster and creating a new service within it.
To give a more concrete example if I have 2 microservices, what factors I should consider when deciding whether to use a new ECS cluster vs just creating a new ECS Service for the 2 microservices? The only thing that I can think of is if I want to re-use the ec2 instances within the cluster across ECS services. i.e. to squeeze more containers onto the ec2 instances. However if I use Fargate then this doesn't seem to be a factor.
I'd be curious to know what factors I am overlooking and what factors people have come across in the real world.
Upvotes: 8
Views: 3437
Reputation: 238269
You've already partially answered your own question - for EC2 launch type you can re-use the instances. A container instance can be registered to only one cluster. Thus if you want to squeeze as much as possible of your container instances, you would re-use them across multiple services.
One reason to use different EC2 cluster for services is separation. Your different application may have different level of importance, and usually you wouldn't want to mix non-important testing services with the production level services. So you would separate them to different clusters, to reduce the risk of accidental configuration for example. What's more, different EC2 clusters can have different capacity providers, and instance types. So obviously you would create different clusters for different requirements.
With Fargate, the reasons for different clusters are not that clear. Naturally, separation of your, lets say, production type services from development services is one important factor to have different clusters. The other reason, which would also apply to EC2, would be grouping of services. You can have one Fargate cluster only for on-demand services (Fargate capacity provider) and second only for spot services (Fargate-spot capacity provider); even though, you can use both in a single cluster.
For both EC2 and Fargate, you can manage access to them using IAM. This means that different clusters can have different people who are allowed to manage them. This is enabled by the fact that you can create ECS conditions in your IAM policies based on cluster. Thus you can have, for example, junior developers access to junior cluster, but they are prohibited through IAM conditions to operate on other clusters.
Upvotes: 4
Reputation: 1162
In my experiences, completely new cluster is for different environments, different applications.
Basically, you can wrap all your applications and environments into 1 cluster. It's about your coding. But it's difficult to maintenance all rolling update,...
Upvotes: 2