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.



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)

  1. In the Deployment Form, find the Show advanced fields toggle button at the bottom.
  1. Once activated, the Replicas Section will become visible.
  2. Enable the Enable Autoscaling toggle .
  1. The AWS SQS Average Backlog Autoscaling Metric should be preselected.
  1. Set the value of Threshold

Via the Python SDK

In your Service deployment code, include the following:

from servicefoundry import AsyncServiceAutoscaling, SQSQueueMetricConfig

service = AsyncService(
    replicas = AsyncServiceAutoscaling(


Via the CLI

In your Service deployment configuration servicefoundry.yaml, include the following:

  min_replicas: 1
  max_replicas: 3
    type: sqs
    queue_length: 30
  cooldown_period: 300
  polling_interval: 30