Resource Control
Summary
We have to handle resources both at the scheduler level and at the runtime level.
Swarm provided a single set of resources (CPU, Memory) which was used both for scheduling and constraining.
Several users were unhappy by this since specifying a resource limit resulted in reservation. For instance, if the user wanted to limit a container to 1GB of RAM (-m 1g) then the scheduler assumed that gigabyte was reserved and would "take it away" from the machine.
In SwarmKit , we should let users specify the two independently:
- Reservation: Amount of resources reserved for this task on the node. A node should not go beyond its total capacity, as in, the scheduler should only chose a node if:
sumOfAllTasksReservations(node) + task.Resources.Reserved < node.Resources - Limits: Limit the amount (quota) of resources the task can use. This is effectively the
-mand-cflags of the engine.
CPU:
Swarm was using --cpu-shares which is very approximate. Docker later introduced --cpu-period and --cpu-quota which use CFS (Completely Fair Scheduler). We should leverage that.
Memory:
Reservation is actually trickier than just scheduling.
Tasks can have higher limits than their reservation. There might also be tasks on the same node that simply don't have reservations nor limits. We might want to let tasks "burst" beyond their limits if no one else is using the resources.
Network:
@mrjana Is there anything we can do with network resources?
Disk:
Not sure if this is tied to volumes rather than containers.
/cc @aaronlehmann @LK4D4 @tonistiigi @icecrime
This is a combination of scheduling plus low-level system stuff, we're going to need to help of engine to design it.
See also:
--blkio-weight Block IO (relative weight), between 10 and 1000
--blkio-weight-device=[] Block IO weight (relative device weight)
--device-read-bps=[] Limit read rate (bytes per second) from a device
--device-read-iops=[] Limit read rate (IO per second) from a device
--device-write-bps=[] Limit write rate (bytes per second) to a device
--device-write-iops=[] Limit write rate (IO per second) to a device
There is requirement to support arbitrary resource, GPU, port number range, or even abstract resources. See #594.
Resources like CPU, memory, bandwidth, disk can be reported by agent, while abstract resource can be defined by Engine label. Docker/Swarm has partial support for this https://github.com/docker/swarm/pull/2205.
cc @runshenzhu.
Hey,
have anything changed in regards to this?
Right now we're manually putting nodes into "pause" availability to limit resource allocation to these nodes. Maybe I'm totally lost, is there anything around resource allocation that got into github.com/moby/moby so far that could help preventing a node from having its resources exhausted?
Thx!
Thanks for opening this issue. This has been implemented, so I’m closing it for now.
If you’re still seeing any related behavior, feel free to reopen it or open a new issue with additional details. Thanks!