Back to Projects
Backend Engineering

Custom API Gateway .

Go Redis Docker
Custom API Gateway

Overview

A custom-built API gateway in Go that sits in front of microservices, providing authentication, rate limiting, caching, and observability.

Core Features

Rate Limiting

Token bucket algorithm with Redis backend for distributed rate limiting.

func (r *RateLimiter) Allow(userID string) bool {
    key := fmt.Sprintf("ratelimit:%s", userID)
    tokens, _ := r.redis.Get(key).Int()
    
    if tokens < 1 {
        return false
    }
    
    r.redis.Decr(key)
    return true
}

Circuit Breaker

Prevents cascading failures by opening circuit after consecutive failures.

Response Caching

Redis-backed cache with TTL and cache invalidation strategies.

Performance

  • Latency Overhead: < 5ms p99
  • Throughput: 50k requests/second per instance
  • Memory: 128MB average footprint

Observability

  • Prometheus metrics for request counts, latency, errors
  • Jaeger tracing for distributed request tracing
  • Structured JSON logging

Deployment

Containerized with Docker, deployed on Kubernetes with horizontal autoscaling.