Back to Portfolio
API Gateway Case Study
Backend Gateway Infrastructure

Microservices API Gateway

A high-performance backend API gateway proxying downstream requests, performing high-speed memory caching, and throttling traffic with rate-limiting algorithms.

-0%Redis Caching BoostSub-15ms response latency
0/secRate Limiting WindowToken Bucket threshold
0DDoS Deflected LogsThrottled requests recorded
0.9%Overall System UptimePostgres connection pools

Project Overview

The microservices API Gateway coordinates routing behaviors across independent backend nodes. It handles CORS configs, decrypts authorization keys, checks rate limits, and caches requests to minimize core CPU cycles.

The Problem Statement

As applications scale, each microservice must repeat authorization checks and rate-limiting gates. This redundancy increases service latency, duplicates codebase requirements, and leaves downstream services vulnerable.

The Solution Engineered

Created a unified Node.js API Gateway. Configured high-performance Redis cache middlewares reducing repetitive downstream database reads by 75%, and created a token bucket rate-limiter in memory to throttle requests.

System Architecture & Orchestration

Click a Layer to Trace Data Flow

Details Panel

Serves as the entry boundary routing incoming HTTP requests to target downstream microservices dynamically.

Key Features Demonstrated

  • Dynamic path proxies mapping routes to service configurations
  • Centralized CORS handles routing client security preflights
  • Unified JSON error controllers formatting backend stack traces
  • SSL termination and certificate validation configurations

Network Traffic Simulator

Trigger request methods to observe latency changes between database fetches (cache misses) and RAM queries (cache hits), and see rate-limit throttling in action.

Traffic Controller

Send Test Requests

Rate Limiter capacity10/10 tokens
Tokens leak and regenerate by 1 key every 3 seconds.

Gateway Output (Tail -f logs)

MISSGET /api/v1/users
19:02:15
Status: 200Latency: 320ms
Info: Cache MISS (fetched from database)

Engineering Solutions

DoS Deflection via Token-Bucket Throttling

Problem: Public endpoints (e.g. GET articles or auth checks) can be targets of massive script queries, increasing PostgreSQL connection limits and taking down services.

Solution: Engineered a Token Bucket rate-limiter middleware. User IP tokens are stored in high-speed Redis keys, decrementing values on queries. When capacity falls below limits, requests are returned directly with HTTP status 429 in under 2ms, saving core computing power.

Redis Cache Evictions & Parity

Problem: Keeping queries cached forever causes database parity logs—for example, if users update record titles, other guests continue reading stale cached details.

Solution: Configured a Stale-While-Revalidate TTL strategy in memory keys. Furthermore, database write endpoints automatically dispatch eviction requests, removing keys in memory whenever a POST, PUT, or DELETE request completes successfully, keeping caches accurate.