Raffael
Raffael

Reputation: 20045

Autoscaling for NetworkLoadBalancedFargateService with CDK?

I have Fargate on a cluster running behind a NLB. I'd like to add autoscaling for it. But I can't find an example for that.

This is the example I found for an ApplicationLoadBalancedFargateService:

fg = aws_ecs_patterns.ApplicationLoadBalancedFargateService(...)

scaling = fg.service.auto_scale_task_count(max_capacity=10)
scaling.scale_on_request_count(
    id="RequestScaling",
    requests_per_target=10000,
    target_group=fg.target_group
)

But this won't work because the target_group parameter expects an instance of ApplicationTargetGroup but for NetworkLoadBalancedFargateService the target_group field is of type NetworkTargetGroup.

Upvotes: 1

Views: 1041

Answers (1)

Zachary Ryan Smith
Zachary Ryan Smith

Reputation: 2768

NLBs don't have a RequestCount metric type just because I guess each TCP connection could contain a number of "requests" in the ALB sense.

In the short term, I think the ActiveFlowCount matches closest with Request Count - so you can use the scaleOnMetric method to scale on ActiveFlowCounit.

In the medium term, I'll try to get a consensus on the best metrics to create a function like ScaleOnRequestType for NLBs.

Upvotes: 1

Related Questions