Skip to content

TASK: Add Redis-backed rate limiting to gateway routes #4

Closed

Description

@ramioooz

Parent: STORY: Implement API Gateway rate limiting and downstream resilience

Objective

Add request rate limiting to API Gateway routes.

Scope

  • Add the required Spring Cloud Gateway rate-limiter support.
  • Use Redis-backed rate limiting for Kubernetes/SIT readiness.
  • Configure route-level replenish rate, burst capacity, and requested tokens externally.
  • Add a deterministic test for HTTP 429 behavior.
  • Document how to tune limits per environment.

Acceptance Criteria

  • Rate limits can be configured without rebuilding the gateway image.
  • Exceeding the configured limit returns HTTP 429.
  • Limits are route-specific, not hardcoded globally.
  • No sensitive configuration is committed.

Activity

  1. self-assigned this
    on Jun 25, 2026
  2. added theissue type on Jun 29, 2026
  3. ramioooz commented on Aug 31, 2026

    @ramioooz
    MemberAuthor

    Implementation PR: #21
    Configuration PR: digital-bank-java/config-repo#36

    Related prerequisites:

    Preferred merge order:

    1. Merge infra-sit#23.
    2. Merge api-gateway#20 and config-repo#35.
    3. Retarget api-gateway#21 to main after api-gateway#20 is merged, then merge it.
    4. Merge config-repo#36.
    5. Roll out API Gateway in SIT and verify the Redis-backed HTTP 429 behavior.

    No fixed delay is required between merges; wait for CI and prerequisite readiness. SIT rollout is pending because the local Docker Desktop Kubernetes API is currently unavailable.

  4. ramioooz commented on Aug 31, 2026

    @ramioooz
    MemberAuthor

    Progress update

    This task remains In review pending PR merge.

  5. ramioooz commented on Sep 4, 2026

    @ramioooz
    MemberAuthor

    Proposed implementation design for review:

    • Use Spring Cloud Gateway’s official Redis RequestRateLimiter filter with the existing SIT Redis deployment.
    • Keep replenish rate, burst capacity, and requested tokens route-specific and externalized in config-repo; no image rebuild for tuning.
    • Resolve limits by authenticated principal when available, otherwise client IP, so unauthenticated routes remain protected.
    • Return HTTP 429 when a bucket is exhausted and keep credentials/secrets out of Git.
    • Add one load-bearing integration test for the 429 behavior, plus Maven, Helm, and configuration validation.

    Implementation is awaiting explicit design approval before gateway behavior is changed. This is based on the official Spring Cloud Gateway Redis rate-limiter documentation: https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway-server-webflux/gatewayfilter-factories/requestratelimiter-factory.html

  6. ramioooz commented on Sep 4, 2026

    @ramioooz
    MemberAuthor

    Completed by merged api-gateway#21 and integrated by api-gateway#22.

    Evidence:

    • Redis-backed Spring Cloud Gateway RequestRateLimiter is enabled.
    • Route-specific rate-limit settings are externalized through Config Server/config-repo.
    • Exhausted buckets return HTTP 429.
    • The focused Testcontainers integration test verifies an allowed request followed by 429.
    • Fail-closed Redis behavior, trusted client-address resolution, Helm/image changes, and documentation are included.

    The earlier platform-config wording in the historical issue body is superseded by config-repo; no business-domain logic or sensitive configuration was added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions