API gateway
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    API gateway: the 60-second story

    API gateway

    Three apps, six services. Why write auth six times?

    Without a gateway, 18 client-to-service links and 24 copies of TLS, auth, limits and logging that should behave identically, and won’t.

    What belongs at the front door

    1. TLS, JWT checks and scopes
    2. Rate limits, quotas and body-size caps
    3. Routing by path and version
    4. Access logs and trace IDs

    Strip, then set, the identity headers

    The gateway verifies the JWT, deletes any X-User-Id the client sent and writes its own. Services trust it only because nothing else can reach them.

    Put the coupon check in the gateway?

    Bad: A god gateway

    Business rules, reshaping and sessions pile up; every change queues.

    Good: Policy only

    The same for every service. Logic stays in services or a BFF.

    Cheapest rejection first

    TLS, IP and size checks cost microseconds, and cached JWT keys need no network call. Only the rate-limit step leaves the box before the upstream call.

    50%

    of requests get 429 after 0.5 s

    50,000 taps in 10 s is 5,000 RPS against AWS’s 2,500 RPS refill in Hyderabad. The 1,250-request burst empties in half a second. Raise the limit before launch.

    Budgets shrink as you go inward

    The client waits longest, then the gateway, the service and each dependency. Inverted, the user sees a 504 at 3 s while the charge commits at 6 s.

    N + 1 instances across three zones. Can they all fail at once?

    The trap

    Yes, if every instance loads the same bad config. Ship config like code: validate, roll out by region, keep a last-known-good.

    Say it like this

    Behind the load balancer, a stateless gateway terminates TLS, checks the JWT, enforces per-key limits and routes. Business logic stays in services, and config ships like code.