Post

My Api Gateway Runs On A Raspberry Pi 4 In My Closet And Handles 2 Million Requests Per Month

My Api Gateway Runs On A Raspberry Pi 4 In My Closet And Handles 2 Million Requests Per Month

My API Gateway Runs On A Raspberry Pi 4 In My Closet And Handles 2 Million Requests Per Month

1. Introduction

In an era where “cloud-first” has become dogma, a Raspberry Pi 4 humming quietly in a home closet handling production traffic seems almost heretical. Yet this is exactly where my team’s internal API infrastructure has lived for the past eight months - routing 2 million monthly requests while consuming less power than a nightlight.

This experiment began as a technical challenge to counter the assumption that all infrastructure must live in AWS. What started as a proof-of-concept evolved into a fully functional API gateway handling authentication, rate limiting, and request routing for our internal services. When a power outage nearly took down our company’s API infrastructure, the realization hit: we’d built mission-critical systems on a $75 device in a residential closet.

For DevOps engineers and sysadmins, this case study demonstrates:

  • The untapped potential of ARM-based homelab setups
  • Cost/benefit analysis of alternative infrastructure approaches
  • Practical implementations of enterprise patterns on constrained hardware
  • Resilience engineering principles in unconventional environments

You’ll learn how to replicate this setup while understanding its limitations, tradeoffs, and appropriate use cases. We’ll cover hardware selection, software optimization, and operational practices that make this possible - without sugarcoating the realities of residential-grade infrastructure.

2. Understanding the Technology Stack

What Makes This Possible?

The core components enabling this setup:

  1. Raspberry Pi 4 Model B (8GB RAM)
    • Broadcom BCM2711 Quad core Cortex-A72 @ 1.5GHz
    • 8GB LPDDR4-3200 SDRAM
    • USB 3.0 ports + Gigabit Ethernet (Realtek RTL8111G)
    • Power draw: 4-6W under load
  2. API Gateway Software (Kong Gateway)
    • Lightweight Lua-based reverse proxy
    • Plugin architecture for auth (JWT, OAuth2), rate limiting
    • Native WebSocket support
    • <5MB memory footprint per worker
  3. Network Configuration
    • Carrier-grade NAT bypass via Cloudflare Tunnels
    • QoS-enabled router (OpenWRT)
    • Static IP with DHCP reservation

Performance Characteristics

Benchmarks on our production workload:

MetricMeasurement
Average CPU Utilization18-22%
Peak HTTP Requests/sec83
95th Percentile Latency27ms
Memory Usage (with caching)1.2GB
Network Throughput723Mbps sustained

Architectural Comparison

Cloud vs. Pi 4 Tradeoffs:

FactorRaspberry Pi 4AWS API Gateway
Cost (Monthly)$0.56 (electricity)$350+ (2M requests)
Uptime SLA~99.2% (home internet)99.95%
Deployment SpeedMinutesMinutes
ObservabilityCustom (Prometheus/Grafana)CloudWatch Integration
Security SurfaceControlledShared Responsibility

When Does This Make Sense?

  • Internal APIs with non-critical uptime requirements
  • Development/staging environments
  • Cost-sensitive edge deployments
  • Hybrid cloud architectures needing on-prem presence

3. Prerequisites

Hardware Requirements

  • Raspberry Pi 4 (4GB+ RAM recommended)
  • Quality Power Supply (Official USB-C 5.1V/3A)
  • Heat Sink/Fan Combo (Sustained load temps >80°C throttle CPU)
  • Reliable Storage:
    • Minimum: A2-rated microSD (SanDisk Extreme Pro)
    • Recommended: USB 3.0 SSD (Samsung T7)

Software Requirements

  • Operating System: Raspberry Pi OS Lite (64-bit)
    1
    2
    3
    
    # Verify OS architecture
    uname -a
    # Should show aarch64
    
  • Docker Engine >= 20.10.14
  • Docker Compose >= 2.6.0

Network Considerations

  1. Residential ISP Limitations:
    • Dynamic IP handling (DDNS or Cloudflare Tunnels)
    • Business
This post is licensed under CC BY 4.0 by the author.