AWS SQS Average Backlog
AWS SQS Average Backlog is defined as the AWS SQS pending queue length averaged over all replicas that the autoscaler is designed to maintain.
The pending queue length refers to the number of messages that are currently in the queue but have not yet been processed. These are messages waiting to be consumed and processed by the relevant workers or services.
The average backlog is the average or mean value of the pending queue length across multiple replicas. In a distributed and auto-scaling system, there can be multiple instances or replicas of your service, each with its own queue. The average backlog provides a way to measure the workload across all replicas.
This Average Backlog is a valuable metric for determining how to scale your application efficiently.
Note:
This metric is only available in case you are using AWS SQS for your input queue
Parameters for SQS Average Backlog
- Threshold (Queue Lag Threshold): Upper limit of the number of backlog messages the auto-scaler will try to maintain per replica. If you set this number to 10 and have 30 messages in the queue and one replica, the auto-scaler will scale the number of replicas to 3.
Configuring AWS SQS Average Backlog
Configuring AWS SQS Backlog Metric:
Via the User Interface (UI)
- In the Deployment Form, find the
Show advanced fields
toggle button at the bottom.

- Once activated, the Replicas Section will become visible.
- Enable the
Enable Autoscaling
toggle .

- The
AWS SQS Average Backlog
Autoscaling Metric should be preselected.

- Set the value of
Threshold
Via the Python SDK
In your Service deployment code deploy.py
, include the following:
from servicefoundry import AsyncServiceAutoscaling, SQSQueueMetricConfig
...
service = AsyncService(
...
replicas = AsyncServiceAutoscaling(
min_replicas=1,
max_replicas=3,
metrics=SQSQueueMetricConfig(
queue_length=30
),
cooldown_period=300,
polling_interval=30
)
...
)
...
Via the CLI
In your Service deployment configuration servicefoundry.yaml
, include the following:
...
replicas:
min_replicas: 1
max_replicas: 3
metrics:
type: sqs
queue_length: 30
cooldown_period: 300
polling_interval: 30
...
Updated 2 days ago