swarmkit icon indicating copy to clipboard operation
swarmkit copied to clipboard

Resource Control

Open aluzzardi opened this issue 10 years ago • 4 comments

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 -m and -c flags 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.

aluzzardi avatar Mar 25 '16 02:03 aluzzardi

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

icecrime avatar Mar 28 '16 23:03 icecrime

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.

dongluochen avatar May 31 '16 22:05 dongluochen

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!

cirocosta avatar Sep 14 '17 13:09 cirocosta

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!

smerkviladze avatar May 04 '26 11:05 smerkviladze