HyperCache - Distributed Cache

HyperCache is a high-performance, Redis-compatible distributed cache with advanced memory management, integrated probabilistic data structures (Cuckoo filters), and comprehensive monitoring stack. Built in Go for cloud-native environments.
๐ฏ Latest Features โ
Production-ready distributed cache with full observability stack:
- โ
Multi-node cluster deployment with hash-ring partitioned routing
- โ
Full Redis client compatibility (RESP protocol + inline commands)
- โ
Lamport timestamps for causal ordering of distributed writes
- โ
Quorum writes โ
consistency_level: "quorum" waits for majority ACKs
- โ
Read-repair for replication propagation window
- โ
Sharded locks (32 independent shards) for high-concurrency writes
- โ
Non-blocking snapshots โ per-shard copy, no global read lock
- โ
Enterprise persistence (AOF + Snapshots) with background writes
- โ
Probabilistic eviction sampling (Redis-style random-key selection)
- โ
Prometheus metrics with latency histograms (p50/p95/p99)
- โ
Config validation CLI โ
hypercache config validate <path>
- โ
Structured JSON logging with correlation ID tracing
- โ
HTTP API + RESP protocol support
- โ
Advanced memory management with pressure detection
- โ
Cuckoo filter integration for negative lookup acceleration
๐ฅ Monitoring & Observability
- Prometheus Metrics: Latency histograms, memory pressure, operation counters on
/metrics
- Grafana Dashboards: Pre-built Prometheus dashboard (throughput, latency p50/p95/p99, memory, cluster)
- Elasticsearch + Filebeat: Centralized log aggregation and search
- Health Checks: Built-in monitoring endpoints
๐ Quick Start
๐ณ Docker (Recommended โ no setup required)
Pull from Docker Hub and start the full stack:
# Download the compose file
curl -O https://raw.githubusercontent.com/rishabhverma17/HyperCache/main/docker-compose.cluster.yml
# Start everything (3 HyperCache nodes + Elasticsearch + Grafana + Filebeat)
docker compose -f docker-compose.cluster.yml up -d
That's it. All configs are baked into the Docker image โ no cloning, no local files needed.
# Verify the cluster
curl http://localhost:9080/health
# Store a key
curl -X PUT http://localhost:9080/api/cache/hello \
-H "Content-Type: application/json" -d '{"value": "world"}'
# Read it from a different node (replication)
curl http://localhost:9082/api/cache/hello
# Open Grafana dashboards
open http://localhost:3000 # admin / admin123
Prerequisites (Local Development)
- Go 1.23.2+
redis-cli (optional, for RESP testing)
Local Cluster (N nodes)
# Start a 3-node cluster (default)
make cluster
# Start a 5-node cluster
make cluster NODES=5
# Start a 10-node cluster
make cluster NODES=10
# Check cluster health
curl -s http://localhost:9080/health | python3 -m json.tool
# Add a node to a running cluster (auto-discovers ports and seeds)
./scripts/add-node.sh
./scripts/add-node.sh --node-name=node-6
# Stop the cluster
make cluster-stop
# Full reset (stop + wipe data/logs/binaries + restart)
make cluster-stop && make clean && make cluster
Single Node
Docker Deployment
# Pull the latest image from Docker Hub
docker pull rishabhverma17/hypercache:latest
# Start full stack (3-node cluster + Elasticsearch + Grafana + Filebeat)
docker compose -f docker-compose.cluster.yml up -d
# Add a 4th node to a running Docker cluster (auto-joins via gossip)
docker run -d --name hypercache-node4 \
--network cache_hypercache-cluster \
-p 8083:8080 -p 9083:9080 \
rishabhverma17/hypercache:latest \
--protocol resp --node-id node-4
# Or build locally and start
make docker-build && make docker-up
# Stop
docker compose -f docker-compose.cluster.yml down
Kubernetes
# Prerequisites: minikube (brew install minikube) + kubectl (brew install kubectl)
# Start Minikube
minikube start
# Deploy full stack (HyperCache + Elasticsearch + Filebeat + Grafana)
make k8s-up
# or: kubectl apply -f k8s/
# Check cluster status
make k8s-status
# Scale to 5 nodes (or use Minikube Dashboard UI)
make k8s-scale NODES=5
# Access HyperCache from your machine
kubectl port-forward -n hypercache svc/hypercache 9080:9080 8080:8080
# Then: curl http://localhost:9080/health
# Then: redis-cli -p 8080 PING
# Open dashboards
make k8s-dashboard # Kubernetes Dashboard (select "hypercache" namespace)
make k8s-grafana # Grafana (same dashboards as Docker โ admin/admin123)
# View logs
make k8s-logs
# Tear down
make k8s-down
๐ Access Points
Local / Docker:
Default 3-node cluster: HTTP on 9080/9081/9082, RESP on 8080/8081/8082.
Kubernetes (after kubectl port-forward -n hypercache svc/hypercache 9080:9080 8080:8080):
| Service |
Access |
Notes |
| HTTP API |
http://localhost:9080 |
Same APIs as local |
| RESP |
redis-cli -p 8080 |
Same commands as local |
| Grafana |
make k8s-grafana |
Opens browser via Minikube tunnel |
| K8s Dashboard |
make k8s-dashboard |
Select "hypercache" namespace |
๐งช Testing
Unit Tests
Lint & Format
Benchmarks
Postman Collection
Import HyperCache.postman_collection.json into Postman for a full test suite covering:
health, metrics, CRUD, cross-node replication, delete replication, value types, Cuckoo filter, and cleanup.
HTTP API Examples
# --- Default store (backward-compatible) ---
curl -X PUT http://localhost:9080/api/cache/mykey \
-H "Content-Type: application/json" \
-d '{"value": "hello world"}'
curl http://localhost:9080/api/cache/mykey
curl -X DELETE http://localhost:9080/api/cache/mykey
# --- Multi-store APIs ---
# List all stores
curl http://localhost:9080/api/stores
# Create a new store (config is immutable after creation)
curl -X POST http://localhost:9080/api/stores \
-H "Content-Type: application/json" \
-d '{"name":"sessions","eviction_policy":"ttl","max_memory":"1GB","default_ttl":"30m","cuckoo_filter":true,"persistence":"aof"}'
# Get store info and stats
curl http://localhost:9080/api/stores/sessions
# Write to a specific store
curl -X PUT http://localhost:9080/api/stores/sessions/cache/user:123 \
-H "Content-Type: application/json" \
-d '{"value": {"token":"abc","role":"admin"}}'
# Read from a specific store
curl http://localhost:9080/api/stores/sessions/cache/user:123
# Drop a store (cannot drop "default")
curl -X DELETE http://localhost:9080/api/stores/sessions
# Cuckoo filter stats
curl http://localhost:9080/api/filter/stats
# Prometheus metrics
curl http://localhost:9080/metrics
Redis CLI
redis-cli -p 8080 SET foo bar
redis-cli -p 8080 GET foo
redis-cli -p 8081 GET foo # verify replication
redis-cli -p 8080 DEL foo
redis-cli -p 8080 INFO
redis-cli -p 8080 DBSIZE
# Multi-store commands
redis-cli -p 8080 STORES # list all stores
redis-cli -p 8080 SELECT sessions # switch to "sessions" store
redis-cli -p 8080 SET user:123 token # writes to "sessions" store
redis-cli -p 8080 SELECT default # switch back
Scenario Tests
Real-world pattern tests that run on every push and daily:
# Run all scenario tests
go test -v -race ./tests/scenarios/...
# Reproduce a randomized test that failed in CI
SCENARIO_SEED=1712438400 go test -run TestRandomizedMixedWorkload ./tests/scenarios/...
Deterministic (same every run): session overflow, concurrent read/write, TTL expiry, persistence recovery, store lifecycle, hot key thundering herd.
Randomized (seed-based, different each run): mixed workload, burst writes, concurrent multi-store.
Makefile Reference
make build Build the binary
make run Run single node (RESP)
make cluster Start N-node cluster (default 3)
make cluster NODES=5 Start 5-node cluster
make cluster-stop Stop all HyperCache processes
make clean Remove binaries, logs, data
make test-unit Run unit tests with coverage
make test-integration Run integration tests
make bench Run benchmarks
make lint Run golangci-lint
make fmt Format code
make docker-build Build Docker image
make docker-up Start Docker stack
make docker-down Stop Docker stack
make k8s-up Deploy to Kubernetes (full stack)
make k8s-down Remove from Kubernetes
make k8s-scale NODES=5 Scale to N replicas
make k8s-status Show K8s pod/service status
make k8s-dashboard Open Minikube dashboard
make k8s-grafana Open Grafana (K8s)
make k8s-logs Tail HyperCache pod logs
make deps Download and tidy dependencies
๐ Key Features
Redis Compatibility
- Full RESP protocol implementation
- Works with any Redis client library
- Drop-in replacement for many Redis use cases
- Standard commands: GET, SET, DEL, EXISTS, PING, INFO, FLUSHALL, DBSIZE
- Multi-store commands: SELECT, STORES
Distributed Resilience
- Hash-Ring Routing: Consistent hashing with 256 virtual nodes routes each key to its primary owner. Non-owner nodes transparently proxy requests to the correct node
- Quorum Writes:
consistency_level: "quorum" waits for majority of hash-ring replicas to ACK before returning OK. Parallel replication with 5s timeout and early-fail if quorum is unreachable. Default is "eventual" (async fire-and-forget)
- Targeted Replication: Writes replicate to N hash-ring replicas (default 3) via direct HTTP โ not gossip broadcast to all nodes
- Lamport Timestamps: Logical clocks for causal ordering of distributed operations. Stale writes from out-of-order replication are automatically rejected
- Read-Repair: On local cache miss, hash-ring replicas are queried before returning 404. Bridges the replication propagation window
- Sharded Concurrency: 32 independent lock shards eliminate the global mutex bottleneck. Each key locks only its shard
- Probabilistic Eviction: Redis-style random sampling (5 keys per round, evict least-recently-accessed) โ O(1) per eviction instead of O(n) linked-list walk
- Non-Blocking Snapshots:
SnapshotRawData() copies data per-shard with brief RLock, then releases. Writes to other shards proceed concurrently during snapshot
- Correlation ID Tracing: Every request gets a unique ID that flows across all nodes for end-to-end debugging
Enterprise Persistence & Recovery
- Hybrid Persistence: AOF (Append-Only File) + Snapshot dual strategy
- Background AOF: 10,000-entry buffered channel โ writes never block the SET critical path
- Configurable per Store: Each data store can have independent persistence policies
- Fast Recovery: Complete data restoration from AOF replay + snapshot loading
- Snapshot Support: Point-in-time recovery with configurable intervals
- Durability Guarantees: Configurable sync policies (always, everysec, no)