Skip to content

Commit

Permalink
add entry for ratelimit (#2565)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws authored Mar 19, 2024
1 parent 7a709fb commit dded552
Show file tree
Hide file tree
Showing 45 changed files with 341 additions and 84 deletions.
70 changes: 70 additions & 0 deletions content/en/docs/configuring-sdk/retries-timeouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,76 @@ if err != nil {
client := s3.NewFromConfig(cfg)
```

### Client-side rate limiting

The {{% alias sdk-go %}} introduces a new client-side rate-limiting mechanism
in the standard retry policy to align with the behavior of modern SDKs. This is
behavior is controlled by the [RateLimiter]({{< apiref "aws/retry#RateLimiter" >}})
field on a retryer's [options]({{< apiref "aws/retry#StandardOptions" >}}).

A RateLimiter operates as a token bucket with a set capacity, where operation
attempt failures consume tokens. A retry that attempts to consume more tokens
than what's available results in operation failure with a
[QuotaExceededError]({{< apiref "aws/ratelimit#QuotaExceededError" >}}).

The default implementation is parameterized as follows (how to modify each setting):
- a capacity of 500 (set the value of RateLimiter on StandardOptions using [NewTokenRateLimit]({{< apiref "aws/ratelimit#NewTokenRateLimit" >}}))
- a retry caused by a timeout costs 10 tokens (set RetryCost on StandardOptions)
- a retry caused by other errors costs 5 tokens (set RetryTimeoutCost on StandardOptions)
- an operation that succeeds on the 1st attempt adds 1 token (set NoRetryIncrement on StandardOptions)
- operations that succeed on the 2nd or later attempt do not add back any tokens

If you find that the default behavior does not fit your application's needs,
you can disable it with [ratelimit.None]({{< apiref "aws/ratelimit#pkg-variables" >}}).

#### Example: modified rate limiter

```go
import (
"context"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/ratelimit"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/config"
)

// ...

cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(func(o *retry.StandardOptions) {
// Makes the rate limiter more permissive in general. These values are
// arbitrary for demonstration and may not suit your specific
// application's needs.
o.RateLimiter = ratelimit.NewTokenRateLimit(1000)
o.RetryCost = 1
o.RetryTimeoutCost = 3
o.NoRetryIncrement = 10
})
}))
```

#### Example: no rate limit using ratelimit.None

```go
import (
"context"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/ratelimit"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/config"
)

// ...

cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(func(o *retry.StandardOptions) {
o.RateLimiter = ratelimit.None
})
}))
```

## Timeouts

You use the [context](https://golang.org/pkg/context/) package to set timeouts or deadlines when invoking a service
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/cloud9-go/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -127,7 +127,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/cloudwatch/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/dynamodb/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/ec2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/iam/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/kms/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/s3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/sns/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/sqs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/ssm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/code-examples/sts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/configuring-sdk/auth/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -126,7 +126,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/configuring-sdk/custom-http/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -126,7 +126,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/configuring-sdk/endpoints/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -126,7 +126,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/configuring-sdk/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand All @@ -123,7 +123,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
Loading

0 comments on commit dded552

Please sign in to comment.