VelocityEdge demonstrates how to achieve Sub-Millisecond Latency for API endpoints using L7 Edge Caching. By placing Varnish Configuration Language (VCL) logic in front of a Node.js backend, it reduces response times by 99% and protects the database from "Thundering Herd" traffic spikes.
Run the infrastructure:
# Start Varnish and Backend
docker-compose up -d --buildPorts: Varnish (:8081), Backend (:3000), Dashboard (:5173).
Compare "Direct" vs "Edge" latency in real-time.
Client -> Varnish (Hit?) -> Node.js -> DB
Visualizing the VCL decision tree (Receive -> Lookup -> Deliver)
Deep Dive: See ARCHITECTURE.md for the VCL script.
- ⚡ 1ms Response Times: Delivers content from RAM, bypassing the application loop.
- 🛡️ Thundering Herd Protection: Coalesces concurrent requests to spare the Database.
- 🧟 Grace Mode: Serves "Stale" content if the backend crashes (Automatic High Availability).
- 🧠 Programmable Edge: Uses VCL to strip cookies, rewrite headers, and route traffic.
- Intercept: User requests
/api/data. - Lookup: Varnish checks in-memory hash map.
- Hit: If found, return instantly (<1ms).
- Miss: If missing, fetch from Node.js (500ms), store in RAM, and return.
- Protect: If 1000 users ask for the same missing key, Varnish makes 1 request to Node.js.
| Document | Description |
|---|---|
| Architecture Guide | VCL Logic, Key Patterns, and Decision Log. |
| Getting Started | Setup guide and Benchmarking scripts. |
| Failure Scenarios | Grace Mode and Backend Kill tests. |
| Interview Q&A | "Varnish vs Redis" and "Cache Invalidation". |
| Component | Technology | Role |
|---|---|---|
| Edge Engine | Varnish Cache 7 | Reverse Proxy & Caching. |
| Backend | Node.js | Simulated API. |
| Dashboard | React + Vite | Metrics Visualization. |
| Ops | Docker Compose | Orchestration. |
Harshan Aiyappa
Senior Full-Stack Hybrid AI Engineer
Voice AI • Distributed Systems • Infrastructure
This project is licensed under the MIT License - see the LICENSE file for details.
