Skip to content

Use request count for autoscaling policy#1303

Merged
tomrf1 merged 1 commit intomainfrom
tf-asg-policy
Mar 3, 2025
Merged

Use request count for autoscaling policy#1303
tomrf1 merged 1 commit intomainfrom
tf-asg-policy

Conversation

@tomrf1
Copy link
Member

@tomrf1 tomrf1 commented Mar 3, 2025

Currently we scale up when average cpu hits 40%. This is bad because:
a) cpu clearly isn't the only relevant factor when considering error spikes
b) it soon scales back down because cpu goes down, even if traffic is still high

Instead we can use the RequestCountPerTarget metric (documented here) to scale up when traffic increases. This is more suitable for e.g. the morning traffic spike.

I've set it to 20,000 requests per target (where target means an ec2 instance).
This means e.g. at 80k requests per minute the ASG will have 4 instances.
I've reset the minimum count to 3, so during the night (UTC) when it's quiet it'll go back to 3 instances.

Recent requests per minute:
Screenshot 2025-03-03 at 09 48 53

@tomrf1 tomrf1 requested a review from a team as a code owner March 3, 2025 09:48
@tomrf1 tomrf1 merged commit 347a5c8 into main Mar 3, 2025
4 checks passed
@tomrf1 tomrf1 deleted the tf-asg-policy branch March 3, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants