Skip to content

Commit

Permalink
configure default client-side throttle for ELBv2 APIs (#2810)
Browse files Browse the repository at this point in the history
  • Loading branch information
kishorj committed Sep 22, 2022
1 parent e56aa96 commit 32f423b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/deploy/configurations.md
Expand Up @@ -129,10 +129,10 @@ Once disabled:

### throttle config

The default throttle config used is.
Controller uses the following default throttle config:

```
WAF Regional:^AssociateWebACL|DisassociateWebACL=0.5:1,WAF Regional:^GetWebACLForResource|ListResourcesForWebACL=1:1,WAFV2:^AssociateWebACL|DisassociateWebACL=0.5:1,WAFV2:^GetWebACLForResource|ListResourcesForWebACL=1:1
WAF Regional:^AssociateWebACL|DisassociateWebACL=0.5:1,WAF Regional:^GetWebACLForResource|ListResourcesForWebACL=1:1,WAFV2:^AssociateWebACL|DisassociateWebACL=0.5:1,WAFV2:^GetWebACLForResource|ListResourcesForWebACL=1:1,Elastic Load Balancing v2:^RegisterTargets|^DeregisterTargets=4:20,Elastic Load Balancing v2:.*=10:40
```
Client side throttling enables gradual scaling of the api calls. Additional throttle config can be specified via the `--aws-api-throttle` flag. You can get the ServiceID from the API definition in AWS SDK. For e.g, ELBv2 it is [Elastic Load Balancing v2](https://github.com/aws/aws-sdk-go/blob/main/models/apis/elasticloadbalancingv2/2015-12-01/api-2.json#L9).

Expand Down
13 changes: 13 additions & 0 deletions pkg/aws/throttle/defaults.go
@@ -1,6 +1,7 @@
package throttle

import (
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/aws/aws-sdk-go/service/wafregional"
"github.com/aws/aws-sdk-go/service/wafv2"
"golang.org/x/time/rate"
Expand Down Expand Up @@ -35,6 +36,18 @@ func NewDefaultServiceOperationsThrottleConfig() *ServiceOperationsThrottleConfi
burst: 1,
},
},
elbv2.ServiceID: {
{
operationPtn: regexp.MustCompile("^RegisterTargets|^DeregisterTargets"),
r: rate.Limit(4),
burst: 20,
},
{
operationPtn: regexp.MustCompile(".*"),
r: rate.Limit(10),
burst: 40,
},
},
},
}
}
2 changes: 1 addition & 1 deletion pkg/ingress/group_loader.go
Expand Up @@ -152,7 +152,7 @@ func (m *defaultGroupLoader) checkGroupMembershipType(ctx context.Context, group
}
return groupMembershipTypeNone, ClassifiedIngress{}, nil
}

// tolerate errInvalidIngressGroup error since an Ingress with a wrong IngressGroup name means to leave the IngressGroup anyway.
if errors.Is(err, errInvalidIngressGroup) {
if hasGroupFinalizer {
Expand Down

0 comments on commit 32f423b

Please sign in to comment.