65f7abf2f4
Closes #12927 Closes #12958 This PR updates the version of redis used in our examples from 3.2 to 7. The old version is very not supported anymore, and we should be setting a good example by using a supported version. The long-form example job is now fixed so that the service stanza uses nomad as the service discovery provider, and so now the job runs without a requirement of having Consul running and configured.
116 lines
3.1 KiB
Plaintext
116 lines
3.1 KiB
Plaintext
---
|
|
layout: docs
|
|
page_title: scaling Stanza - Job Specification
|
|
description: The "scaling" stanza allows specifying scaling policy for a task group
|
|
---
|
|
|
|
# `scaling` Stanza
|
|
|
|
<Placement
|
|
groups={[
|
|
['job', 'group'],
|
|
['job', 'group', 'task'],
|
|
]}
|
|
/>
|
|
|
|
The `scaling` block allows configuring scaling options for a `task` or a
|
|
`group`, for the purpose of supporting external autoscalers like the
|
|
[Nomad Autoscaler](https://github.com/hashicorp/nomad-autoscaler) and scaling
|
|
via the Nomad UI. This stanza is not supported within jobs of type `system`.
|
|
|
|
When placed at the `group` level, the scaling policy will be of type
|
|
[horizontal application scaling][horizontal_app_scaling], controlling the value
|
|
of [`count`][] for the group.
|
|
|
|
```hcl
|
|
job "example" {
|
|
datacenters = ["dc1"]
|
|
|
|
group "cache" {
|
|
count = 1
|
|
|
|
scaling {
|
|
enabled = true
|
|
min = 0
|
|
max = 10
|
|
|
|
policy {
|
|
# ...
|
|
}
|
|
}
|
|
# ...
|
|
}
|
|
}
|
|
```
|
|
|
|
When placed at the `task` level, the scaling policy will be of type
|
|
[Dynamic Application Sizing][das], controlling the [`resources`][] values of
|
|
the task. In this scenario, the `scaling` block must have a label indicating
|
|
which resource will be controlled. Valid names are `cpu` and `mem`.
|
|
|
|
```hcl
|
|
job "example" {
|
|
datacenters = ["dc1"]
|
|
|
|
group "cache" {
|
|
task "redis" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "redis:7"
|
|
}
|
|
|
|
resources {
|
|
cpu = 100
|
|
memory = 256
|
|
}
|
|
|
|
scaling "cpu" {
|
|
enabled = true
|
|
min = 100
|
|
max = 500
|
|
|
|
policy {
|
|
# ...
|
|
}
|
|
}
|
|
|
|
scaling "mem" {
|
|
enabled = true
|
|
min = 64
|
|
max = 512
|
|
|
|
policy {
|
|
# ...
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## `scaling` Parameters
|
|
|
|
- `min` - <code>(int: nil)</code> - The minimum acceptable count for the task group.
|
|
This should be honored by the external autoscaler. It will also be honored by Nomad
|
|
during job updates and scaling operations. Defaults to the specified task group [`count`][].
|
|
|
|
- `max` - <code>(int: <required>)</code> - The maximum acceptable count for the task group.
|
|
This should be honored by the external autoscaler. It will also be honored by Nomad
|
|
during job updates and scaling operations.
|
|
|
|
- `enabled` - <code>(bool: false)</code> - Whether the scaling policy is enabled.
|
|
This is intended to allow temporarily disabling an autoscaling policy, and should be
|
|
honored by the external autoscaler.
|
|
|
|
- `policy` - <code>(map<string|...>: nil)</code> - The autoscaling policy. This is
|
|
opaque to Nomad, consumed and parsed only by the external autoscaler. Therefore,
|
|
its contents are specific to the autoscaler; consult the
|
|
[Nomad Autoscaler documentation][autoscaling_policy] for more details.
|
|
|
|
[autoscaling_policy]: /tools/autoscaling/policy
|
|
[`count`]: /docs/job-specification/group#count 'Nomad Task Group specification'
|
|
[`resources`]: /docs/job-specification/task#resources 'Nomad Task specification'
|
|
[das]: /tools/autoscaling#dynamic-application-sizing
|
|
[horizontal_app_scaling]: /tools/autoscaling#horizontal-application-autoscaling
|