-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allocate resources automatically to containers in a container app #856
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a move in the right direction, but we will probably need to come up with a way to define more strategies for balancing the allocation.
@@ -2129,6 +2129,27 @@ module ContainerApp = | |||
| PublicImage (container, version) -> | |||
let version = version |> Option.defaultValue "latest" | |||
$"{container}:{version}" | |||
type ContainerAppResourceLevel = ContainerAppResourceLevel of cores:float<VCores> * memory:float<Gb> | |||
module ResourceLevels = | |||
let ``CPUs = 0.25, RAM = 0.5`` = ContainerAppResourceLevel (0.25<VCores>, 0.5<Gb>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is difficult syntax to use. An editor/IDE helps, but if that's not available or someone is unfamiliar with F#, the double backticks add complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I just don't know what to call these values otherwise! Any ideas?
let containers = 5. | ||
|
||
|
||
let optimise containers (cores:float<VCores>, memory:float<Gb>) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in most cases, this can't really be evenly distributed. We probably need some different strategies where containers are weighted to prioritize them or where some of the containers have a fixed size and any extra resources are allocated to certain containers that would need more elasticity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify a bit - you might have some sidecars to handle things like logging that have low, fixed resource usage. And then an HTTP frontend might need more CPU, but low memory needs. And then maybe one or two containers that do most of the application logic and need all the rest of the capacity. Does that make sense? I think it's difficult to come up with a "one size fits all" solution and should design it around multiple user-defined strategies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true. One idea I had was either to set a percentage, or a simple T-Shirt size e.g. S/M/L, and distribute it that way. Once we get out of that world and into the world of more complex scenario, this is something that I suspect will then require manual creation - there are so many permutations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to loop in @matthewcrews to see if he has any thoughts on this kind of problem (although might be overkill!). Ideally I really don't want to bring in any external library but it sounds like a kind of constraint solving problem:
- We have x amount of CPU and y amount of RAM
- We have 5 containers, C1-C5
- C1 never needs more than a specific amount of CPU and RAM
- C2 is CPU hungry
- C3 needs more RAM
- C4 and C5 should take up the remaining resources, although C5 is more important
- All containers should have a minimum of resources that they must always have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd need to unpack this more but this is sounding like a straightforward allocation/assignment problem. I don't think you need to go full optimization model on this.
There are some known heuristics that should be able to do this for you and only take a few lines of F#. I'd be happy to jump on a call if you wanted to discuss this in more detail.
@isaacabraham is it worth merging and shipping this one and iterating on it to come up with more allocation strategies? |
@isaacabraham attempted to merge master into this pull request. Need some input on the addition of |
The changes in this PR are as follows:
I have read the contributing guidelines and have completed the following:
Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure: