Inference Mesh is a high-performance, edge-scalable PyTorch inference engine designed for executing open-weight LLMs locally. It features a blistering-fast Go API Gateway that orchestrates real-time Server-Sent Events (SSE) streaming from decoupled Python PyTorch gRPC workers.
- High-Throughput Go Gateway: Achieves 438+ requests per second with sub-5µs JSON overhead.
- Decoupled PyTorch Workers: Scalable Python backend running isolated gRPC nodes.
- Hardware Agnostic: Defaults to optimized PyTorch CPU execution but seamlessly supports CUDA.
- Secure Next.js Frontend: Beautiful, responsive UI built on Turbopack with edge-middleware Supabase authentication.
graph LR
Client((Client)) --> NextJS[Next.js Frontend]
NextJS -- "Supabase Auth" --> Supabase[(Supabase)]
NextJS -- "Proxies Req" --> GoGateway[Go API Gateway]
GoGateway -- "gRPC Streams" --> Worker1[Python Worker 1]
GoGateway -- "gRPC Streams" --> Worker2[Python Worker 2]
- Frontend (Next.js): Handles user interactions, Markdown rendering, and edge-level authentication via Supabase JWTs.
- Gateway (Go): Validates requests, enforces token-bucket rate limits, and routes payloads to workers via gRPC.
- Workers (Python): Loads HuggingFace models into VRAM/RAM and streams tokens back via gRPC.
Tested on an Intel i5-1135G7 (4 Cores, 32GB RAM) without CUDA acceleration. (For comprehensive methodology, P95 latency distributions, chaos testing results, and system capacity profiles, see the full Performance Benchmark Report).
| Metric | Result |
|---|---|
| Gateway Routing Scalability | 100+ concurrent connections (1.6 ms P95 Latency) |
| Worker Chaos Recovery | 100% gateway recovery during 25s worker failure |
| Gemma 3 (270M) TTFT | 553.2 ms (CPU FP32) |
| Middleware Pipeline Overhead | 8.18 µs/op |
- Built a production-ready multi-modal AI inference platform exposing OpenAI-compatible streaming APIs for open-weight LLMs using a containerized Go gateway and Python inference workers, architected for independent scaling through Kubernetes, HPAs, and Docker.
- Engineered a Go API gateway providing API Key authentication, token-bucket rate limiting, health-aware worker routing, persistent HTTP/2 gRPC communication, and Server-Sent Events (SSE), reducing Gateway→Worker connection establishment latency by 88% (4.43 ms → 0.51 ms) through persistent connection reuse.
- Validated production readiness using reproducible Go benchmarks, k6 load testing, pprof profiling, OpenTelemetry instrumentation, and chaos testing, achieving 454 ms P95 end-to-end production latency, 291 sustained requests/sec under 100 concurrent users, and deterministic recovery from worker failures with 0% request failures during public load testing.
This project is fully containerized and deployable to edge/cloud platforms. The current reference deployment uses Vercel (Frontend) and Railway (Backend Go Gateway).
Warning
Known Infrastructure Limitations (Free Tier): Deploying the Python PyTorch Worker to standard Free Tier cloud environments (like Railway Free Tier or Hugging Face Spaces) has known limitations. Hugging Face Spaces load-balancers actively strip HTTP/2 gRPC headers, breaking Go→Python communication. Railway's Free Tier (1GB RAM limit) results in Out-Of-Memory (OOM) kills when PyTorch attempts to load standard open-weight LLMs into memory. For a fully functional end-to-end deployment, the Python Worker requires a dedicated GPU instance or a minimum of 8GB+ RAM.
- Link your GitHub repository to Railway.
- Railway will automatically detect the Dockerfile and deploy the Go Gateway.
- Expose the gateway publicly via Railway networking to obtain your URL (e.g.,
https://inference-mesh-production.up.railway.app).
- Import the repository into Vercel.
- Set the Root Directory to
frontend. - Under Environment Variables, add:
NEXT_PUBLIC_SUPABASE_URL= Your Supabase URLNEXT_PUBLIC_SUPABASE_ANON_KEY= Your Supabase Anon KeyNEXT_PUBLIC_API_BASE_URL= The Railway Gateway URL you got in Step 1.
- Deploy to obtain your public frontend URL.
Copy the .env.example file:
cp .env.example .envFill in your Supabase URL and keys, along with your HuggingFace token.
The easiest way to launch the entire stack locally is via Docker Compose.
# Starts the Go Gateway and Python PyTorch Worker
docker-compose -f docker-compose.prod.yml up -d --buildNote: The worker image installs PyTorch CPU wheels by default to save bandwidth and image size.
cd frontend
npm install
npm run dev- Edge Authentication: Next.js middleware verifies Supabase sessions before granting access to
/chat. - API Protection: The Go Gateway is protected by internal API keys, ensuring isolated external-facing security.
- Dynamic worker auto-scaling based on queue depth.
- Native Kubernetes Helm charts for multi-node deployments.
- vLLM or TGI integration for the Python workers.