Post

Introducing Throttling to Downstream APIs

After a sudden traffic surge brought down a partner API, we built in throttling using Spring Cloud Gateway and a basic token bucket algorithm.

Sample config:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
spring:
  cloud:
    gateway:
      routes:
        - id: throttled_route
          uri: http://backend/
          predicates:
            - Path=/partner/**
          filters:
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 10
                redis-rate-limiter.burstCapacity: 20

With Redis-backed rate limiting, we shed load predictably and protected upstream services.

If your system fails under unexpected load, it’s not reliable — it’s fragile.

This post is licensed under CC BY 4.0 by the author.