[ECS] [request]: Support Placement Strategy "spread" on Task Group
- Dominant language
- Shell
- Stars
- 5.4k
- Forks
- 334
- PR merge metrics
- No merged PRs in 30d
Description
### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
**Tell us about your request**
Please support the ECS task placement strategy `spread` using a Task Group (defined in task placement constraints).
**Which service(s) is this request for?**
ECS
**Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?**
I'm trying to deploy Zookeeper in ECS, which due to the need to have numerically indexed nodes (a la `myid`) I have opted to do 1 x ECS service per node, with desired count of 1 each, 3~ services total (initially) yielding 3 nodes total. Inspired by https://tech.smartling.com/self-healing-apache-zookeeper-cluster-470b248ccb12
I am then using the Task Family (or Service Name, same outcome) to extract the node number to inject accordingly.
I would like to ensure that the 3 x nodes do not end up on the same EC2 instance ID, by putting all 3 ECS services in the same Task Group, and then set them to `spread` on it.
According to [the docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html) standalone tasks are spread based on the task group, but services are not, and if you try use it, you get an error of `spread field 'group:zookeeper-1a' is invalid.`.
(these are AZ specific clusters intentionally btw, hence 1a in the naming)
Example configuration I would like to work with, defined on all 3 ECS services:
```
"PlacementConstraints": [
{
"Expression": "attribute:ecs.availability-zone =~ us-east-1a",
"Type": "memberOf"
},
{
"Expression": "task:group =~ zookeeper-1a",
"Type": "memberOf"
}
],
"PlacementStrategy": [
{
"Field": "group:zookeeper-1a",
"Type": "spread"
}
]
```
**Are you currently working around this issue?**
Deploy without the constraint and *hope* that 2 nodes don't end up on the same host, and that the host goes down. And don't put it into production use :) **Far** from ideal...
**Additional context**
Nothing specific, thanks :)
**Attachments**
N/A
Contributor guide
Research direction
Start with the linked ECS task placement strategies documentation and the placement configuration in the issue. Investigate how services validate task groups and spread strategies, then verify that three services can share a task group and distribute tasks across EC2 instances without the reported invalid-field error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws
- Domain
- cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100