github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/scaling.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: scaling Stanza - Job Specification
     4  description: The "scaling" stanza allows specifying scaling policy for a task group
     5  ---
     6  
     7  # `scaling` Stanza
     8  
     9  <Placement
    10    groups={[
    11      ['job', 'group', 'scaling'],
    12      ['job', 'group', 'task', 'scaling'],
    13    ]}
    14  />
    15  
    16  The `scaling` block allows configuring scaling options for a `task` or a
    17  `group`, for the purpose of supporting external autoscalers like the
    18  [Nomad Autoscaler](https://github.com/hashicorp/nomad-autoscaler) and scaling
    19  via the Nomad UI. This stanza is not supported within jobs of type `system`.
    20  
    21  When placed at the `group` level, the scaling policy will be of type
    22  [horizontal application scaling][horizontal_app_scaling], controlling the value
    23  of [`count`][] for the group.
    24  
    25  ```hcl
    26  job "example" {
    27    datacenters = ["dc1"]
    28  
    29    group "cache" {
    30      count = 1
    31  
    32      scaling {
    33        enabled = true
    34        min     = 0
    35        max     = 10
    36  
    37        policy {
    38          # ...
    39        }
    40      }
    41      # ...
    42    }
    43  }
    44  ```
    45  
    46  When placed at the `task` level, the scaling policy will be of type
    47  [Dynamic Application Sizing][das], controlling the [`resources`][] values of
    48  the task. In this scenario, the `scaling` block must have a label indicating
    49  which resource will be controlled. Valid names are `cpu` and `mem`.
    50  
    51  ```hcl
    52  job "example" {
    53    datacenters = ["dc1"]
    54  
    55    group "cache" {
    56      task "redis" {
    57        driver = "docker"
    58  
    59        config {
    60          image = "redis:7"
    61        }
    62  
    63        resources {
    64          cpu    = 100
    65          memory = 256
    66        }
    67  
    68        scaling "cpu" {
    69          enabled = true
    70          min     = 100
    71          max     = 500
    72  
    73          policy {
    74            # ...
    75          }
    76        }
    77  
    78        scaling "mem" {
    79          enabled = true
    80          min     = 64
    81          max     = 512
    82  
    83          policy {
    84            # ...
    85          }
    86        }
    87      }
    88    }
    89  }
    90  ```
    91  
    92  ## `scaling` Parameters
    93  
    94  - `min` - <code>(int: nil)</code> - The minimum acceptable count for the task group.
    95    This should be honored by the external autoscaler. It will also be honored by Nomad
    96    during job updates and scaling operations. Defaults to the specified task group [`count`][].
    97  
    98  - `max` - <code>(int: &lt;required&gt;)</code> - The maximum acceptable count for the task group.
    99    This should be honored by the external autoscaler. It will also be honored by Nomad
   100    during job updates and scaling operations.
   101  
   102  - `enabled` - <code>(bool: false)</code> - Whether the scaling policy is enabled.
   103    This is intended to allow temporarily disabling an autoscaling policy, and should be
   104    honored by the external autoscaler.
   105  
   106  - `policy` - <code>(map<string|...>: nil)</code> - The autoscaling policy. This is
   107    opaque to Nomad, consumed and parsed only by the external autoscaler. Therefore,
   108    its contents are specific to the autoscaler; consult the
   109    [Nomad Autoscaler documentation][autoscaling_policy] for more details.
   110  
   111  [autoscaling_policy]: /tools/autoscaling/policy
   112  [`count`]: /docs/job-specification/group#count 'Nomad Task Group specification'
   113  [`resources`]: /docs/job-specification/task#resources 'Nomad Task specification'
   114  [das]: /tools/autoscaling#dynamic-application-sizing
   115  [horizontal_app_scaling]: /tools/autoscaling#horizontal-application-autoscaling