diff --git a/examples/terraform/envoy-ratelimiter/ratelimit.tf b/examples/terraform/envoy-ratelimiter/ratelimit.tf index 795edf9c7b4d..2f0004043c1f 100644 --- a/examples/terraform/envoy-ratelimiter/ratelimit.tf +++ b/examples/terraform/envoy-ratelimiter/ratelimit.tf @@ -189,6 +189,14 @@ resource "kubernetes_deployment" "ratelimit" { name = "STATSD_PORT" value = "9125" } + env { + name = "GRPC_MAX_CONNECTION_AGE" + value = var.ratelimit_grpc_max_connection_age + } + env { + name = "GRPC_MAX_CONNECTION_AGE_GRACE" + value = var.ratelimit_grpc_max_connection_age_grace + } resources { requests = var.ratelimit_resources.requests @@ -214,6 +222,17 @@ resource "kubernetes_deployment" "ratelimit" { container_port = 9125 protocol = "UDP" } + # statsd-exporter does not use much resources, so setting resources to the minimum + resources { + requests = { + cpu = "50m" + memory = "64Mi" + } + limits = { + cpu = "100m" + memory = "128Mi" + } + } } volume { diff --git a/examples/terraform/envoy-ratelimiter/variables.tf b/examples/terraform/envoy-ratelimiter/variables.tf index 661a1531f31f..714638934c9f 100644 --- a/examples/terraform/envoy-ratelimiter/variables.tf +++ b/examples/terraform/envoy-ratelimiter/variables.tf @@ -89,7 +89,7 @@ variable "min_replicas" { variable "max_replicas" { description = "Maximum number of replicas for rate limit deployment" type = number - default = 5 + default = 100 } variable "hpa_cpu_target_percentage" { @@ -128,6 +128,19 @@ variable "ratelimit_log_level" { default = "debug" } +variable "ratelimit_grpc_max_connection_age" { + description = "Duration a connection may exist before it will be closed by sending a GoAway" + type = string + default = "5m" +} + +variable "ratelimit_grpc_max_connection_age_grace" { + description = "Period after MaxConnectionAge after which the connection will be forcibly closed" + type = string + default = "1m" +} + + variable "redis_resources" { description = "Compute resources for Redis container" type = object({ @@ -136,11 +149,11 @@ variable "redis_resources" { }) default = { requests = { - cpu = "100m" + cpu = "250m" memory = "128Mi" } limits = { - cpu = "500m" + cpu = "1000m" memory = "512Mi" } } @@ -154,8 +167,8 @@ variable "ratelimit_resources" { }) default = { requests = { - cpu = "250m" - memory = "256Mi" + cpu = "150m" + memory = "128Mi" } limits = { cpu = "500m" diff --git a/sdks/java/io/components/src/main/java/org/apache/beam/sdk/io/components/ratelimiter/EnvoyRateLimiterFactory.java b/sdks/java/io/components/src/main/java/org/apache/beam/sdk/io/components/ratelimiter/EnvoyRateLimiterFactory.java index fa512d38ab9d..9a68cb4142e9 100644 --- a/sdks/java/io/components/src/main/java/org/apache/beam/sdk/io/components/ratelimiter/EnvoyRateLimiterFactory.java +++ b/sdks/java/io/components/src/main/java/org/apache/beam/sdk/io/components/ratelimiter/EnvoyRateLimiterFactory.java @@ -39,8 +39,9 @@ /** A {@link RateLimiterFactory} for Envoy Rate Limit Service. */ public class EnvoyRateLimiterFactory implements RateLimiterFactory { private static final Logger LOG = LoggerFactory.getLogger(EnvoyRateLimiterFactory.class); - private static final int RPC_RETRY_COUNT = 5; - private static final long RPC_RETRY_DELAY_MILLIS = 1000; + // Retry up to 1 min rather than failing fast and asking runner to retry full bundle. + private static final int RPC_RETRY_COUNT = 10; + private static final long RPC_RETRY_DELAY_MILLIS = 6000; private final RateLimiterOptions options;