Elastic pool and prewarm

Plan where Spaces go and what it costs, add and remove cloud hosts, set the budget, and keep Spaces ready.

With clouds linked, on auto (or a cloud) places Spaces by one solve over your devices, your hosts and new cloud machines, under the budget. Spaces.cloud_plan shows that decision without doing it; Spaces.cloud_hosts, cloud_add_host and cloud_remove_host manage the hosts; cloud_budget sets the caps; Spaces.prewarm keeps Spaces of one shape ready so the next creates of it start at once.

Elastic pool methods#

Methods of Spaces.

Spaces.cloud_plan#

What the elastic pool would do for some Spaces: where each goes (your devices first, then hosts with room, then new cloud machines at the least cost) and what that costs. With apply, it adds the machines (create the Spaces with on auto).

async def cloud_plan(self, request: ElasticPlanRequest) -> ElasticPlan
ParameterTypeDefault
requestElasticPlanRequestrequired

Returns ElasticPlan · Async · Raises CuaError

Spaces.cloud_hosts#

The hosts the elastic pool added in your clouds, with their cost.

async def cloud_hosts(self) -> List[ElasticHost]

Returns Vec<ElasticHost> · Async · Raises CuaError

Spaces.cloud_add_host#

Adds count hosts of instance_type in a linked cloud by hand (the scaler never removes them); each ends at its TTL.

async def cloud_add_host(self, provider: str, instance_type: str, region: Optional[str], count: Optional[int], ttl_hours: Optional[int]) -> List[ElasticHost]
ParameterTypeDefault
providerStringrequired
instance_typeStringrequired
regionOption<String>required
countOption<u32>required
ttl_hoursOption<u32>required

Returns Vec<ElasticHost> · Async · Raises CuaError

Spaces.cloud_remove_host#

Removes hosts this home added to the pool.

async def cloud_remove_host(self, names: List[str]) -> ElasticRemoved
ParameterTypeDefault
namesVec<String>required

Returns ElasticRemoved · Async · Raises CuaError

Spaces.cloud_budget#

The elastic pool's budget and autoscale switch, after setting the fields update gives.

async def cloud_budget(self, update: ElasticBudgetUpdate) -> ElasticBudget
ParameterTypeDefault
updateElasticBudgetUpdaterequired

Returns ElasticBudget · Async · Raises CuaError

Spaces.cloud_reconcile#

One scale-in pass now: idle hosts go at the end of their paid time, the least-used one is cordoned when the others have room.

async def cloud_reconcile(self) -> List[ElasticDecision]

Returns Vec<ElasticDecision> · Async · Raises CuaError

Spaces.prewarm#

Keeps Spaces of image ready where the elastic pool puts them (the same solve as on auto, under the budget and pins), so the next creates of that shape start in a fraction of a second. Refused, and nothing bought, when the budget or pins cannot fit it.

async def prewarm(self, image: str, options: PrewarmOptions) -> Prewarm
ParameterTypeDefault
imageStringrequired
optionsPrewarmOptionsrequired

Returns Prewarm · Async · Raises CuaError

Spaces.prewarms#

The prewarms, with how many each keeps ready now.

async def prewarms(self) -> List[Prewarm]

Returns Vec<Prewarm> · Async · Raises CuaError

Spaces.remove_prewarm#

Ends prewarm id (its ready Spaces go). false: no such prewarm.

async def remove_prewarm(self, id: str) -> bool
ParameterTypeDefault
idStringrequired

Returns bool · Async · Raises CuaError

ElasticAssignment record#

Some Spaces of one group on one machine.

FieldTypeDefaultDescription
groupStringThe group (request-0).
hostStringA machine in the pool by name, or empty when it is a new one.
new_index / newIndexOption<u32>The index into new_hosts (when host is empty).
countu32How many Spaces.
syncboolThe checkpoint is copied there first.

ElasticBudget record#

The budget, and what the clouds cost now.

Returned by Spaces.cloud_budget.

FieldTypeDefaultDescription
autoscalebool
max_usd_per_hour / maxUsdPerHourf64
monthly_usd / monthlyUsdf64
max_new_hosts / maxNewHostsu32
warmbool
allow_metal / allowMetalbool
month_usd / monthUsdf64USD spent on elastic hosts this month.
running_usd_per_hour / runningUsdPerHourf64USD per hour of the hosts running now.
hostsu32Hosts running.

ElasticBudgetUpdate record#

The elastic pool's caps and switches (cloud_budget): set those given.

FieldTypeDefaultDescription
max_usd_per_hour / maxUsdPerHourOption<f64>None
monthly_usd / monthlyUsdOption<f64>None
autoscaleOption<bool>None
max_new_hosts / maxNewHostsOption<u32>None
warmOption<bool>None
allow_metal / allowMetalOption<bool>None

ElasticDecision record#

One scale-in decision.

Returned by Spaces.cloud_reconcile.

FieldTypeDefaultDescription
hostString
actionStringkeep, cordon or remove.
reasonString
untilu64keep: unix seconds it is looked at again.
saves_usd / savesUsdf64remove: USD saved against keeping it a billing step longer.

ElasticHost record#

A host the elastic pool added in one of your clouds.

Returned by Spaces.cloud_add_host, Spaces.cloud_hosts.

FieldTypeDefaultDescription
nameStringIts pool name (hetzner-1).
providerString
type_name / typeNameString
regionString
idStringThe cloud's id.
machineStringIts relay machine once joined.
stateStringcreating, booting, joined, cordoned, offline, gone.
startedu64Unix seconds.
expiresu64Unix seconds it ends on its own.
usd_per_hour / usdPerHourf64
billing_step_secs / billingStepSecsu64
billing_min_secs / billingMinSecsu64
pinnedboolAdded by hand: never removed by the scaler.

ElasticNewHost record#

A machine the plan adds.

FieldTypeDefaultDescription
providerString
type_name / typeNameString
regionString
usd_per_hour / usdPerHourf64
boot_secs / bootSecsu32
billed_secs / billedSecsu64Seconds billed for the work it gets.
one_space / oneSpaceboolA Spaces supplier's Space (Modal), not a host.
rtt_ms / rttMsu32Estimated round trip from the requester, ms (0: unknown).

ElasticPlan record#

The elastic pool's decision (cloud_plan).

Returned by Spaces.cloud_plan.

FieldTypeDefaultDescription
assignmentsVec<ElasticAssignment>
new_hosts / newHostsVec<ElasticNewHost>
unplacedVec<ElasticUnplaced>
added_usd_per_hour / addedUsdPerHourf64USD per hour the new machines add.
projected_usd / projectedUsdf64USD the new machines cost for the work, billed.
lower_bound_usd / lowerBoundUsdf64A lower bound for any plan of the same work.
solverStringexact, exact-incumbent or greedy.
ready_in_secs / readyInSecsu32Seconds until the last Space can start.
explainVec<String>One line per decision.
addedVec<ElasticHost>The hosts added (with apply).
jsonStringThe whole answer as JSON (the demand it detected, the pool it saw): what an agent inspects or edits.

ElasticPlanRequest record#

What to plan for (cloud_plan). Pins are constraints of the same solve: leave them unset to let the pool decide.

FieldTypeDefaultDescription
countOption<u32>NoneHow many Spaces (default 1).
imageOption<String>NoneImage (default linux).
kindOption<String>Nonecontainer, vm or microvm (default: from the image).
cpusOption<u32>NonevCPUs each (default: learned from earlier Spaces of the image).
memory_mb / memoryMbOption<u64>NoneMiB each.
togetherOption<bool>NoneKeep them on one machine (forks of one checkpoint).
callerOption<String>Noneinteractive, batch, compat or persistent_agent.
duration_secs / durationSecsOption<u64>NoneExpected lifetime, seconds.
providerOption<String>NoneOnly this cloud.
regionOption<String>NoneOnly this region.
instance_type / instanceTypeOption<String>NoneOnly this machine type.
hostsOption<u32>NoneExactly this many new machines.
no_scale / noScaleOption<bool>NoneAdd no machines.
devices_only / devicesOnlyOption<bool>NoneOnly your own devices.
max_usd_per_hour / maxUsdPerHourOption<f64>NoneA $/hour cap for this plan.
applyboolfalseAdd the machines the plan needs.

ElasticRemoved record#

What cloud_remove_host did.

Returned by Spaces.cloud_remove_host.

FieldTypeDefaultDescription
removedVec<String>
failedVec<String>name: error per host not removed.

ElasticUnplaced record#

Spaces with no place, and why.

FieldTypeDefaultDescription
groupString
countu32
reasonString

Prewarm record#

Spaces of one shape the elastic pool keeps ready: the next creates of that shape claim them in a fraction of a second.

Returned by Spaces.prewarm, Spaces.prewarms.

FieldTypeDefaultDescription
idStringpw-xxxxxx.
imageString
kindString
cpusu32
memory_mb / memoryMbu64
countu32Asked.
readyu32Ready now.
placementsVec<PrewarmPlacement>
expires_at / expiresAtu64Unix seconds.
new_hosts / newHostsVec<String>Hosts added for it.

PrewarmOptions record#

What to keep ready (Spaces::prewarm).

FieldTypeDefaultDescription
countOption<u32>NoneHow many, 1 to 256 (default 1).
onOption<String>Noneauto (default), local, a linked cloud or host:<machine>.
kindOption<String>Nonecontainer, vm or microvm (default: the image's).
cpusOption<u32>None
memory_mb / memoryMbOption<u64>None
ttl_secs / ttlSecsOption<u64>NoneSeconds to keep them (default 3600).
instance_type / instanceTypeOption<String>NoneOnly this cloud machine type.
regionOption<String>NoneOnly this cloud region.

PrewarmPlacement record#

Where a prewarm keeps Spaces ready.

FieldTypeDefaultDescription
hostStringThe machine's name.
machineStringlocal or its relay machine id.
countu32
readyu32