CPU sizing
Multicloud measures the CPU that each container of your pool uses, every 30 seconds. From this usage, Multicloud recommends a CPU units request and a burst limit for each container. CPU units measure CPU by benchmark: 500 units are one baseline core. See CPU units on your cluster.
By default (mode Advise), CPU sizing only reads. Multicloud does not change your workloads. You decide which values to use, and you put them in your manifests. To let Multicloud apply the values, see Let Multicloud apply the values (Auto).
Read the recommendations
Use one of these:
- The CLI:
mctl pool cpu-sizing <pool>. For the hourly values of one workload:mctl pool cpu-sizing-history <pool> <namespace> <owner-kind> <owner-name>. - Your AI assistant, through the Multicloud MCP server: the tools
get_cpu_sizingandget_cpu_sizing_history. - The API:
GET /api/v1/orgs/<org-id>/pools/<pool-id>/cpu-sizingandGET /api/v1/orgs/<org-id>/pools/<pool-id>/cpu-sizing/workloads/<namespace>/<owner-kind>/<owner-name>/history.
A page in the console comes later.
You must be a member of the organization, or use an API key with the Read (org:read) scope.
MCP: get_cpu_sizing(slug=<org-id>, pool_id=<pool-id>)
mctl pool cpu-sizing ci
WORKLOAD CONTAINER NOW (REQ/LIM) P95 MAX RECOMMENDED (REQ/LIM) CLIPPED
shop/Deployment/web app 500/1000m 200 500 230/600u yes
jobs/StatefulSet/db pg 100/200u 90 140 wait (9/72h) no
What the numbers mean
All values are per container, for one pod. A workload with 3 replicas gets the value for one replica.
| Value | Meaning |
|---|---|
| NOW | The request and limit in the pod spec now. u = CPU units. m = raw CPU in millicores (1000m = 1 core). - = no CPU request. |
| P95 | Each hour, Multicloud keeps the 95th percentile of the use in that hour. P95 is the 95th percentile of these hourly values. A peak that lasts less than some minutes in an hour does not show in P95. |
| MAX | The highest use that Multicloud saw. |
| RECOMMENDED | The CPU units request and the burst limit that Multicloud recommends. |
| CLIPPED | yes: the CPU limit stopped the container at its peak. See Clipped. |
--window-days (1 to 35, default 14) changes the days for P95, MAX and the history.
It does not change the recommendation.
How Multicloud calculates the recommendation
Multicloud always uses the last 14 days.
Both values use only qualifying hours. See The 72-hour minimum.
- Request = the 90th percentile of the hourly P95 values, plus 15 %. The minimum is 10 units.
- Burst limit = the highest hourly MAX, plus 20 %. The limit is never less than the request.
If a pod ran on more than one node in one hour, Multicloud uses the higher values of the nodes. For P95, a node where the pod ran less than 15 minutes in that hour does not count if a longer node exists. A pod that starts on a new node often uses much CPU for some minutes. That start-up peak still counts for MAX and the limit.
The 72-hour minimum
Multicloud gives a recommendation only after 72 qualifying hours in the last 14 days. An hour qualifies when Multicloud measured the container for at least half of the hour.
Before that, RECOMMENDED shows wait, with the qualifying hours so far, for example wait (9/72h).
In the API, recommendation.status is insufficient_data and qualifying_hours gives the hours so far.
Hours do not count when your pool is hibernated, because no pod runs. A new workload, or a pool that hibernates often, needs more calendar days to get to 72 hours.
Clipped
CLIPPED is yes when the container used 90 % or more of its CPU limit in more than 5 % of the measurements.
The limit then stopped the container, so its real peak is higher than MAX shows.
The recommended limit comes from MAX, so it can be too low too.
What to do:
- Increase the CPU limit of the container, for example to two times the recommended limit.
- Wait some days, so that Multicloud can measure the real peak.
- Read the recommendation again.
Apply a value by hand
The steps are for one container. Do them in your manifest, Helm values or Git repository, so that your next deploy keeps the values.
-
Make sure the namespace has the label
multicloud.io/cpu-units=enabled:kubectl get namespace shop --show-labelsIf the label is not there, add it. See Turn on CPU units for a namespace.
-
In the container, set the recommended request as the
multicloud.io/cpu-unitsrequest and limit. Both must be equal. Remove thecpurequest and thecpulimit of that container. -
Set the burst limit in the pod annotation
multicloud.io/cpu-units-limit. The annotation is for the whole pod. Without the annotation the pod has no CPU limit and can use idle CPU on the node. If you keep a rawcpulimit in such a container, Multicloud removes it when the pod is created. The pod QoS class then can change from Guaranteed to Burstable. In a namespace with a CPU ResourceQuota or a CPU LimitRange, Multicloud keeps the raw limit, and the limit then follows the CPU units request. If the pod has more than one container with CPU units, add the limits of these containers.For the recommendation
230/600uof containerapp:spec: template: metadata: annotations: multicloud.io/cpu-units-limit: "600" spec: containers: - name: app resources: requests: multicloud.io/cpu-units: "230" limits: multicloud.io/cpu-units: "230" -
Deploy the change. The new values apply to new pods. A Deployment replaces its pods when you change the pod template.
-
After some days, read the recommendation again. The values change when the use of your workload changes.
Let Multicloud apply the values (Auto)
Each pool has one mode:
| Mode | What Multicloud applies |
|---|---|
advise (default) |
Nothing. You copy values into your manifests. |
selected |
The recommendation (or a value you pin) to each workload that you select. |
full |
The recommendation to every workload in an opted-in namespace, new workloads too, except the workloads that you exclude. |
Rules in selected and full:
-
Only Deployments, StatefulSets and DaemonSets. Only namespaces with the label
multicloud.io/cpu-units: enabled. The API refuses a selection inkube-system,kube-public,kube-node-lease,cert-managerormulticloud-system, and the cpu-units webhook never changes pods inkube-system,kube-node-lease,cert-managerormulticloud-system. -
A container that sets
multicloud.io/cpu-unitsin its manifest keeps it. Your manifest wins. -
A workload needs 72 hours of data first. Before that it shows "Waiting for data". In
full, a new workload gets its first value after at least 3 days. -
A container that sets raw
cpukeeps it, unless you convert it. Converting removes its raw CPU request and limit. This can change the pod QoS class, and the effect on a HorizontalPodAutoscaler is not verified. Inselectedyou convert per workload (--convert-raw). Infullone pool setting (full_convert_raw) converts all of them. -
Multicloud changes no running pod. A value applies when a pod is created. To apply it now, use Roll now (section 5), or restart the workload:
kubectl rollout restart deployment/web -n shop
You must be an organization owner, or use an API key with the Write (org:write) scope, to change the mode or a selection. Members and Read keys can see them.
1. Preview the change
A switch up (advise to selected or full, selected to full, or converting raw CPU on) always starts with a preview. The preview lists each workload that changes (current to target), the raw workloads (kept or converted), the excluded workloads, and how many wait for data.
MCP: get_cpu_units_mode(slug=<org-id>, pool_id=<pool-id>)
MCP: preview_cpu_units_mode(slug=<org-id>, pool_id=<pool-id>, mode="full")
mctl pool cpu-units-mode ci --preview full
2. Switch the mode
MCP: set_cpu_units_mode(slug=<org-id>, pool_id=<pool-id>, mode="full", plan_hash=<plan-hash>)
mctl pool cpu-units-mode ci --set full
--set shows the preview again and asks you to confirm. The API and the MCP tool set_cpu_units_mode need the plan_hash of the preview (GET .../cpu-sizing/mode/preview, MCP preview_cpu_units_mode). If your workloads or selections changed after the preview, the switch fails with 409 PLAN_STALE: preview again. The hash does not cover the target values, so the hourly update of a recommendation does not fail it. A switch down (to advise, or full to selected) needs no preview.
Multicloud computes the values once per hour, and again within about 30 seconds after you change the mode or a selection. After a switch up or a selection change, the first values appear within about 2 minutes (a workload that needs more data still shows wait). After a switch down, Multicloud removes the values within about 5 minutes. Running pods keep their values until they are replaced. Your selections stay, so a switch back restores them.
3. Select workloads (selected), pin or exclude
MCP: set_cpu_units_selection(slug=<org-id>, pool_id=<pool-id>, namespace="shop", owner_kind="Deployment", owner_name="web", choice="follow")
mctl pool cpu-units-select ci shop Deployment web # follow the recommendation
mctl pool cpu-units-select ci shop Deployment web --convert-raw # also convert raw CPU
mctl pool cpu-units-select ci shop Deployment web --pin app=230:600 # fixed 230 units, limit 600
mctl pool cpu-units-select ci shop Deployment batch --exclude # full mode: leave it alone
mctl pool cpu-units-unselect ci shop Deployment web # remove the selection
- A pinned value must be at least 10 units and at most the largest node of the pool. The limit must be at least the request.
- A pinned value does not change with the recommendation. A manifest value still wins, and raw CPU stays unless you convert it.
- A pool holds at most 2000 selections. The API selects up to 200 workloads in one call (
PUT .../cpu-sizing/selections), all or nothing. - MCP tools:
get_cpu_units_mode,preview_cpu_units_mode,set_cpu_units_mode,set_cpu_units_selection,delete_cpu_units_selection,set_cpu_units_selections.
4. Check the result
MCP: get_cpu_sizing(slug=<org-id>, pool_id=<pool-id>)
mctl pool cpu-sizing ci --json shows, per container, the selection, the applied value with pods_on_rev of pods_total, and the status:
setting_status |
Meaning |
|---|---|
auto_pending |
Multicloud set a value. Pods get it when they are created: use Roll now, or restart the workload. |
auto_applied |
All pods run with the value. |
auto_waiting_data |
Fewer than 72 hours of data. No value yet. |
auto_raw_kept |
The container sets raw CPU and is not converted. |
auto_excluded |
You excluded the workload (full). |
auto_over_cap |
The pool has more values than one cluster object can hold. The busiest workloads come first. |
5. Roll now
Roll now replaces the pods of one workload now, so the new pods get the Auto value. You do not need to restart the workload yourself.
How it works:
- Multicloud evicts the pods one at a time through the Eviction API. The Deployment, StatefulSet or DaemonSet object does not change. ArgoCD and Flux have nothing to revert.
- It waits until the new pod is Ready before it evicts the next pod. A DaemonSet rolls one node at a time.
- Only one workload rolls at a time in a pool. The other rolls wait in the queue. A workload has one active roll at a time. A pool holds at most 50 active rolls.
- Roll now needs mode
selectedorfull, and a workload with statusauto_pending. - A PodDisruptionBudget (PDB) applies. If the PDB blocks an eviction, the roll shows "Blocked by PDB" and retries every 30 seconds. After 30 minutes without progress the roll ends as
blocked_pdbwith reasonpdb_timeout. A PDB that allows no disruption always blocks. For such a workload, usekubectl rollout restart. It follows the rollout strategy, not the PDB. - A workload with 1 replica needs
allow_downtime. Eviction has no surge: the workload is down until the new pod is Ready. A new, larger value can also wait for a new node. Withoutallow_downtimethe API answers 409DOWNTIME_REQUIRED. A DaemonSet does not need it. - A sleeping pool refuses with 409
POOL_ASLEEP. The pods get the value when the pool wakes. - You can cancel a roll. Multicloud stops before the next eviction. The pod in flight is not rolled back. Pods that are already replaced keep their new values.
You must be an organization owner, or use an API key with the Write (org:write) scope. Members and Read keys can list the rolls.
mctl pool cpu-units-roll ci shop Deployment web # asks first; --yes skips the question
mctl pool cpu-units-roll ci shop Deployment web --allow-downtime # a workload with 1 replica
mctl pool cpu-units-rolls ci # the active rolls; --all adds finished ones
mctl pool cpu-units-roll-cancel ci 42 # cancel roll 42
The API routes are POST .../cpu-sizing/workloads/{namespace}/{owner_kind}/{owner_name}/roll, POST .../cpu-sizing/rolls (1 to 50 workloads, all or nothing), GET .../cpu-sizing/rolls?state=active|all and DELETE .../cpu-sizing/rolls/{roll_id}. The MCP tools are roll_cpu_units_workload, roll_cpu_units_workloads, list_cpu_units_rolls and cancel_cpu_units_roll. mctl pool cpu-sizing ci --json shows the latest roll of each workload in the field roll.
A request fails with 409 for these reasons, checked in this order:
| Code | Meaning |
|---|---|
POOL_ASLEEP |
The pool is asleep. |
MODE_ADVISE |
The mode is advise. Nothing is applied. |
NOTHING_TO_ROLL |
The workload has no value that waits for new pods. |
ROLL_ACTIVE |
The workload already has a queued or running roll. |
DOWNTIME_REQUIRED |
The workload has 1 replica. Send allow_downtime. |
ROLL_QUEUE_FULL |
The pool has more than 50 active rolls. |
The state of a roll:
state |
Meaning |
|---|---|
queued |
The roll waits for its turn. |
rolling |
Multicloud evicts the pods. pods_rolled of pods_total shows the progress. |
blocked_pdb |
A PDB blocks the eviction. Multicloud retries. With reason pdb_timeout the roll is over. |
done |
Every pod runs with the value. |
stalled |
A new pod was not Ready after 15 minutes. Pods already replaced keep their new values. |
not_applied |
The first new pod did not get the value. Multicloud stopped. Check that the cpu-units webhook runs and that no container sets the value in its manifest. |
canceled |
The roll stopped. The reason says why: user, mode_advise, selection_removed, pool_hibernated, workload_gone, overrides_not_written or downtime_required. |
The alternative is always kubectl rollout restart deployment/web -n shop.
Limits of the data
- Multicloud measures every 30 seconds. A peak that is shorter than this can be missed, so MAX is a lower limit of the real peak.
- CPU units come from a multi-core benchmark. A single-thread workload is measured against the average core of the node.
- The usage data comes from your cluster. Multicloud uses it for recommendations only, never for billing.
- Multicloud keeps the usage data for 35 days.