How to Customize your Service Resources

Notice

This documentation set has been merged with the Maestro Version 2 documentation and is officially deprecated. These pages will be redirected to their equivalents in that doc set within the next few weeks.

Limiting CPU and RAM usage

By default, Docker services will use as much CPU and memory as they require. You may wish to set a hard limit on memory, or the relative CPU shares used by a service.

This can be accomplished in Maestro by adding the constraints/resources directive to your service’s service.yml.

CPU limits

The default number of CPU shares given to a service is 1024. This is a relative number - if the service of container A has 1024 CPU shares, and the service of container B has 512 CPU shares, and both containers attempt to use 100% of the CPU, then container B will receive half of the total CPU time. This only applies when CPU-intensive tasks are running, as if one container is idle then the others can use the remaining CPU time.

RAM limits

The memory limit will apply to RAM usage, and SWAP usage. A valid entry is a positive number, followed by one of, "K", "M", or "G", with the minimum being "4M". (You can also use the power-of-two equivalents like Gi, Mi, Ki if you prefer.)

For example:

services:
    your_service_name:
        constraints:
            resources:
                memory: "100M"
                cpu: 512

Removing existing constraints

If you have added constraints to your Maestro application in the past and now need to remove them, you will need to explicitly recreate your services (and the containers that embody them) via the Dashboard.

To recreate your services without constraints:

  1. Remove the constraints/resources directive from your configuration file(s) and ensure you’ve saved them.
  2. In the Cloud 66 Dashboard navigate to the application in question.
  3. Click on the name of the service in question under App Services
  4. Click the Recreate Service button to the right of the Containers list. This will recreate your containers and remove the constraints on that service.

Recreate service button