Skip to content

Instantly share code, notes, and snippets.

@DoumanAsh
Created March 27, 2026 11:51
Show Gist options
  • Select an option

  • Save DoumanAsh/32831ea31d8fd7be4926225506afb63e to your computer and use it in GitHub Desktop.

Select an option

Save DoumanAsh/32831ea31d8fd7be4926225506afb63e to your computer and use it in GitHub Desktop.
KEDA concurrent request scaling object. AWS doesn't seem to have concurrent request count per individual request so we can only simulate it
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: alb-littles-law-per-second-scaledobject
namespace: default
spec:
scaleTargetRef:
name: my-app-deployment
minReplicaCount: 2
maxReplicaCount: 30
pollingInterval: 30
cooldownPeriod: 300
advanced:
scalingModifiers:
formula: "(request_rate / 60 * response_time)" # λ (req/s) × W (seconds) = concurrent requests
target: "150" # Desired approximate concurrent requests **per pod**
activationTarget: "1" # Minimum target number to start scaling. Has no effect if min replica is greater than 0
metricType: "AverageValue"
triggers:
# Get total number of requests in 60 seconds period
- type: aws-cloudwatch
name: request_rate
metadata:
namespace: AWS/ApplicationELB
metricName: RequestCount
# You can also use just TargetGroup
dimensionName: LoadBalancer;TargetGroup
dimensionValue: "app/my-alb/1234567890abcdef;targetgroup/my-tg-name/abcdef1234567890"
awsRegion: "us-east-1"
metricStat: "Sum"
metricStatPeriod: "60"
metricCollectionTime: "180"
metricUnit: "Count"
authenticationRef:
name: keda-aws-auth
# Get apprximate response time for the duration of 60 seconds
- type: aws-cloudwatch
name: response_time
metadata:
namespace: AWS/ApplicationELB
metricName: TargetResponseTime
dimensionName: LoadBalancer;TargetGroup
dimensionValue: "app/my-alb/1234567890abcdef;targetgroup/my-tg-name/abcdef1234567890"
awsRegion: "us-east-1"
metricStat: "Average"
metricStatPeriod: "60"
metricCollectionTime: "180"
metricUnit: "Seconds"
authenticationRef:
name: keda-aws-auth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment