Back off by what a rate-limited destination asks for
Use MeshRetry with rateLimitedBackOff to wait for the interval named in a Retry-After or X-RateLimit-Reset header instead of the exponential schedule.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshRetry
metadata:
name: respect-retry-after
namespace: kong-mesh-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
default:
http:
numRetries: 3
retryOn:
- EnvoyRatelimited
rateLimitedBackOff:
maxInterval: 30s
resetHeaders:
- name: retry-after
format: Seconds
- name: x-ratelimit-reset
format: UnixTimestampCopied!
type: MeshRetry
name: respect-retry-after
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
default:
http:
numRetries: 3
retryOn:
- EnvoyRatelimited
rateLimitedBackOff:
maxInterval: 30s
resetHeaders:
- name: retry-after
format: Seconds
- name: x-ratelimit-reset
format: UnixTimestampCopied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_retry" "respect_retry_after" {
provider = konnect-beta
type = "MeshRetry"
name = "respect-retry-after"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "frontend"
}
}
to = [
{
target_ref = {
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend"
}
}
default = {
http = {
num_retries = 3
retry_on = [
"EnvoyRatelimited"
]
rate_limited_back_off = {
max_interval = "30s"
reset_headers = [
{
name = "retry-after"
format = "Seconds"
},
{
name = "x-ratelimit-reset"
format = "UnixTimestamp"
}
]
}
}
}
}
]
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}
Copied!