Symptoms
- The public endpoint returns
502or503; the load balancer shows all backends missing orCRITICAL. - The instance pool in the console shows size
0(or far fewer instances than normal), or the pool state isSTOPPED. - Instances in the pool are
TERMINATINGorTERMINATED, and the audit log shows the autoscaling service, not a person, made the change. - It often starts right after a change to an autoscaling policy, a copied schedule from non-production, or a metric that went quiet (agent stopped, so CPU reads as low).
1. Confirm scope and impact (3 minutes)
export COMP=ocid1.compartment.oc1..xxxx
export POOL=ocid1.instancepool.oc1..xxxx
oci compute-management instance-pool get --instance-pool-id $POOL \
--query 'data.{state:"lifecycle-state", size:size, config:"instance-configuration-id"}' --output table
oci compute-management instance-pool list-instances \
--compartment-id $COMP --instance-pool-id $POOL \
--query 'data[].{name:"display-name", state:state, ad:"availability-domain"}' --output table
Find the autoscaling configuration attached to the pool and its policies:
oci autoscaling configuration list --compartment-id $COMP --all \
--query 'data[?resource.id==`'"$POOL"'`].{id:id, name:"display-name", enabled:"is-enabled", cooldown:"cool-down-in-seconds"}' \
--output table
export ASC=ocid1.autoscalingconfiguration.oc1..xxxx
oci autoscaling configuration get --auto-scaling-configuration-id $ASC \
--query 'data.policies[].{name:"display-name", type:"policy-type", enabled:"is-enabled", capacity:capacity}'
Look at the capacity block (min, max, initial) of each policy. A min of 0, or a schedule-based policy that sets the target size to 0, explains the outage.
2. Fastest mitigation: freeze autoscaling, then restore the size
Disable the autoscaling configuration first. If you resize the pool while it is still enabled, the next evaluation can scale you straight back down.
oci autoscaling configuration update --auto-scaling-configuration-id $ASC \
--is-enabled false
If the pool is STOPPED, start it. Otherwise set the size back to the normal production count:
# Only if lifecycle-state is STOPPED
oci compute-management instance-pool start --instance-pool-id $POOL
# Restore the size (use your normal peak count, not the minimum)
oci compute-management instance-pool update --instance-pool-id $POOL --size 6
New instances are launched from the pool's instance configuration. If they are attached to a load balancer backend set through the pool, they are registered automatically once they are running.
Warning
If the launch fails with
Out of host capacityor a service limit error, the pool cannot grow in that availability domain. Add placement configurations in other availability domains, or temporarily switch the instance configuration to another shape that has capacity. See the post on out-of-host-capacity errors for the details.
Caution
Instances terminated by a scale-in are terminated together with their boot volumes. Anything written only to the local boot volume (uploaded files, local caches, logs not shipped elsewhere) is gone. Do not plan on recovering it; check whether the application kept state on block volumes, File Storage or Object Storage, and tell the data owner what was lost.
3. Find out why it scaled in
| Finding | Cause | Fix |
|---|---|---|
Threshold policy has min: 0 | Bad policy edit or copied from dev | Set min to the smallest count that serves peak with one fault domain down |
| Schedule-based policy fired at a fixed time | Non-production "scale to zero at night" schedule applied to prod | Delete the schedule or move it to the right pool |
| CPU metric reads 0 or no data | Cloud Agent monitoring plugin stopped, so scale-in rule saw low CPU | Fix the agent; use a metric that reflects load |
Pool STOPPED, no autoscaling event | Someone or a Resource Scheduler schedule stopped the pool | Remove the pool from the schedule |
| Size dropped after a manual change | Operator ran update --size with the wrong number | Restore size; add change review |
Check the audit log to see who or what made the change in the last hours:
oci logging-search search-logs \
--search-query 'search "'"$COMP"'/_Audit" | where data.resourceId = '"'$POOL'"' | sort by datetime desc' \
--time-start $(date -u -d '-6 hours' +%Y-%m-%dT%H:%M:%SZ) \
--time-end $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--query 'data.results[].data.{time:datetime, event:data.eventName, who:data.identity.principalName}'
Event names vary by API version; look for UpdateInstancePool, StopInstancePool and autoscaling configuration or policy updates. For a Resource Scheduler cause, list your schedules and check whether the pool or its compartment is a target.
Confirm the metric the threshold policy uses had data:
oci monitoring metric-data summarize-metrics-data \
--compartment-id $COMP --namespace oci_computeagent \
--query-text 'CpuUtilization[1m]{instancePoolId = "'"$POOL"'"}.mean()' \
--start-time $(date -u -d '-6 hours' +%Y-%m-%dT%H:%M:%SZ)
Dimension names can differ by agent version; if the query returns nothing, query by resourceId for one instance and check the dimensions in the output.
4. Fix the policy and re-enable autoscaling
Edit the policy in the console (Instance pool > Autoscaling configuration > Edit policy) or with the CLI, and set a safe floor. The capacity block for a threshold policy looks like this:
{ "min": 4, "max": 12, "initial": 6 }
oci autoscaling policy update --auto-scaling-configuration-id $ASC \
--auto-scaling-policy-id ocid1.autoscalingpolicy.oc1..xxxx \
--policy-type threshold \
--capacity '{"min": 4, "max": 12, "initial": 6}'
Check oci autoscaling policy update --help on your CLI version for the required fields; the policy type must match the existing policy.
Re-enable the configuration only after the pool is healthy and the policy is corrected:
oci autoscaling configuration update --auto-scaling-configuration-id $ASC --is-enabled true
5. Verify recovery
oci lb backend-health get --load-balancer-id $LB --backend-set-name app-bs \
--backend-name 10.0.2.15:8080
oci lb backend-set-health get --load-balancer-id $LB --backend-set-name app-bs \
--query 'data.{status:status, total:"total-backend-count", critical:"critical-state-backend-names"}'
- Backend set health is
OKand the total backend count matches the pool size. - The application endpoint returns
200from outside OCI. - The pool size holds steady across one full cooldown period after autoscaling is re-enabled.
Communicate
Tell users: "The
Prevent it next time
- Never allow
min: 0on a production pool. Set the floor so the pool survives the loss of one fault domain. - Keep schedule-based policies for non-production pools only, and name them so the scope is obvious.
- Alarm on pool size: page when the running instance count drops below the policy minimum.
- Alarm on missing data for the scaling metric (
.absent()in MQL), so a dead agent does not look like zero load. - Keep application state off boot volumes; pool instances are disposable.
- Review autoscaling and Resource Scheduler changes the same way you review code.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get