[ECS] [placementConstraint]: runningTaskCount PER service
- 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**
Right now, in `placementConstraint`, you can use `runningTaskCount` to select instances with a specific task count. I would like to be able to select instances based on the task count **of a specific service**.
**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?**
To give a concrete example, if I have 3 instances, and they run 5 services, I want my services to always run 2 tasks per EC2. Right now, I have to use `distinctInstance` (which limits me to 1 task per EC2, but enforces spread), or `placementStrategy:spread(instanceId)` (which is a preference and is not applied well: I often run into tasks clustering on one EC2, or one EC2 staying empty).
In general, too many tasks of a single service on the same EC2 creates noise, and those tasks do not perform as well as if they were on separate EC2s. On the other hand, a single task is not always able to handle all the workload, so if I want to keep them separate, I have to use more EC2s.
I **could** use more, smaller EC2s. Unfortunately, I have other costs that are associated with the total number of EC2s, and so it is beneficial for me to find a middle ground and use slightly larger instances, and run more tasks on them. I just want those tasks to stay distributed equally.
On top of this, my clusters are auto-rotated. Ie every X time, one EC2 instance is killed and replaced automatically by the ASG. We do this because I have found that instances … decay, and weird problems start to appear when they run longer. Good old “reboot your router at night” fixes it. When instances are retired, the tasks on them have to migrate, and as far as I can tell, placementStrategy is not applied then. I often find clusters with 1 EC2 with 20 tasks while 2 other EC2 are empty. So constraint is needed.
**Are you currently working around this issue?**
I’m not really at the moment. This is a problem I’m trying to solve.
Contributor guide
Research direction
No repository files, tests, or code entry points are identified. Start by reviewing the ECS placementConstraint and placementStrategy behavior described in the issue, then determine the required service-scoped task-count semantics. Done means ECS can distribute each service's tasks per instance using an enforceable constraint rather than a preference.
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