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 for a fixed count, or a tuple of two ints representing the min and max replicas for autoscaling. Defaults to (0, 1). |
| metric | Optional[Union[Concurrency, RequestRate]] = None | Metric to use for autoscaling. Can be a Concurrency instance (scale when concurrent requests per replica exceeds val) or a RequestRate instance (scale when requests per second per replica exceeds val). Defaults to None. |
| 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. Default (0, 1). |
| metric | Optional[Union[Concurrency, RequestRate]] = None | Autoscaling metric — Scaling.Concurrency(val) (scale when concurrent requests per replica exceeds val) or Scaling.RequestRate(val) (scale when requests per second per replica exceeds val). Default None. |
| scaledown_after | `int | timedelta |
Methods
get_replicas()
@classmethod
def get_replicas() - > Tuple[int, int]
Retrieves the minimum and maximum replica counts for the scaling configuration. This method ensures that the replica count is always returned as a tuple of two integers, even if it was initially set as a single integer.
Returns
| Type | Description |
|---|---|
Tuple[int, int] | A tuple containing two integers: (min_replicas, max_replicas). |