| What you want | Use |
|---|---|
| Resize once, predictably | scale() |
| Track memory pressure automatically | set_autoscale() |
| Freeze the current size | set_scaling_lock() |
How the three interact
- Manual
scale()disables autoscale on the sandbox as a side effect — explicit user intent overrides the loop. Re-enable withset_autoscale(enabled=True, ...)after if you want. - Setting a scaling lock disables autoscale at the same time (single knob: “I don’t want this scaling, period”). While locked, both
scale()andset_autoscale(enabled=True)raiseScalingLockedError. Unlocking does NOT auto-re-enable autoscale. - Plan caps apply everywhere. Free-tier orgs are capped at 4 GB. Calls above the cap raise
PlanLimitError.
sandbox.scale(memory_mb)
Manually resize the sandbox. HTTP API →
Target memory in MB.
dict with sandboxID, memoryMB, cpuPercent.
Raises:
ScalingLockedError— sandbox has a scaling lock active.PlanLimitError—memory_mbexceeds the org’s plan cap.
sandbox.set_autoscale(enabled, *, min_memory_mb=None, max_memory_mb=None)
Enable or disable per-sandbox autoscale.
Whether autoscale should be active.
Lower bound when
enabled=True.Upper bound when
enabled=True. Must be ≥ min_memory_mb.dict with sandboxID, enabled, minMemoryMB, maxMemoryMB.
Raises:
ScalingLockedError— sandbox has a scaling lock active.PlanLimitError—max_memory_mbexceeds the org’s plan cap.
enabled=True, the platform watches the sandbox’s memory pressure and resizes it within the bounds:
- Scale up on a single 1-min sample above 75% memory utilization. Cooldown 60s between up-scales.
- Scale down only when 1-min, 5-min, AND 15-min averages all sit below 25%. Cooldown 5 min between down-scales.
sandbox.get_autoscale()
Get the current autoscale configuration.
Returns: dict with sandboxID, enabled, minMemoryMB, maxMemoryMB.
sandbox.set_scaling_lock(locked)
Lock or unlock the sandbox’s resources against any size change.
True to freeze, False to allow scaling again.dict with sandboxID, locked.
While locked:
scale()raisesScalingLockedError.set_autoscale(enabled=True)raisesScalingLockedError.- The platform autoscaler skips this sandbox entirely.
set_autoscale(enabled=True, ...) explicitly if you want it back.
sandbox.get_scaling_lock()
Get the current scaling-lock state.
Returns: dict with sandboxID, locked.
Errors
ScalingLockedError
Raised when the sandbox has a scaling lock active. Has a class attribute code = "scaling_locked" for parity with the HTTP API’s error code.