Scaling
Controls replica count and autoscaling behavior for app environments.
Attributes
| Attribute | Type | Description |
|---|---|---|
| replicas | Union[int, Tuple[int, int]] = (0, 1) | Number of replicas to run. Can be a single int or a tuple of two ints representing the min and max replicas. |
| metric | Optional[Union[Concurrency, RequestRate]] = null | Metric to use for autoscaling. Can be a concurrency or request rate. |
| scaledown_after | `int | timedelta |
Constructor
Signature
def Scaling(
replicas: Union[int, Tuple[int, int]] = (0, 1),
metric: Optional[Union[Concurrency, RequestRate]] = None,
scaledown_after: int | timedelta | None = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| replicas | Union[int, Tuple[int, int]] = (0, 1) | Number of replicas. An int for fixed count, or a (min, max) tuple for autoscaling. |
| metric | Optional[Union[Concurrency, RequestRate]] = None | Autoscaling metric such as Scaling.Concurrency(val) or Scaling.RequestRate(val). |
| scaledown_after | `int | timedelta |
Methods
get_replicas()
@classmethod
def get_replicas() - > Tuple[int, int]
Retrieves the normalized replica range for the environment. This method ensures the output is always a tuple, converting fixed integer replica counts into a (min, max) pair where both values are identical.
Returns
| Type | Description |
|---|---|
Tuple[int, int] | A tuple containing the minimum and maximum number of replicas to be maintained by the autoscaler. |