Ultra-fast, zero-allocation, authenticated in-memory & persistent cache service written in pure Go.
Horreum is a high-performance distributed key-value caching system designed with a strict zero-allocation hot-path architecture. Powered by custom memory-mapped arena allocators, S3-FIFO eviction queues, pure-Go LZ4 compression, and authenticated AES-256-GCM encryption at rest, Horreum achieves microsecond latency with zero garbage collection overhead on value storage.
- Zero-Allocation Hot Path: Custom
mmaparena allocator (internal/arena) operating onunsafe.Slicehandles. No heap GC pressure on value mutations. - S3-FIFO Eviction: Lock-free touch operations via atomic frequency counters and dual ring-buffer queues (Small & Main) outperforming classic LRU.
- Dual Transport Layer:
- TCP: Connection-pinning router hashing
(remoteIP + localPort)to shard workers. - QUIC: Native TLS 1.3 multiplexed stream support using
quic-go.
- TCP: Connection-pinning router hashing
- Pure-Go LZ4 Compression: Optional fast value compression with pooled buffer recycling achieving ~2 GB/s decompress throughput.
- Authenticated Encryption at Rest: AES-256-GCM AEAD encryption with automated 32-byte key generation (~4.9 GB/s decrypt throughput via AES-NI).
- Stdlib-Only YAML Config: Zero-dependency YAML configuration parser supporting binary unit sizes (
256MiB,1GiB). - Low-Overhead Logging:
log/slogstructured logging with token-bucket rate-limiting on network errors and slow-log threshold tracking for WAL syncs. - Durable Persistence: Write-Ahead Logging (WAL) with cold-start replay and atomic HashIndex checkpointing.
Measured on AMD Ryzen 9 7950X3D (Go 1.22, Windows/Linux)
| Payload Size | Encrypt Throughput | Encrypt Latency | Decrypt Throughput | Decrypt Latency |
|---|---|---|---|---|
| 256 B | 1201 MB/s | 213 ns | 2302 MB/s | 111 ns |
| 4 KB | 2532 MB/s | 1.6 µs | 3713 MB/s | 1.1 µs |
| 64 KB | 3072 MB/s | 21.3 µs | 4164 MB/s | 15.7 µs |
| 1 MB | 4230 MB/s | 247 µs | 4930 MB/s | 212 µs |
| Payload Size | Compress Throughput | Decompress Throughput |
|---|---|---|
| 256 B | 8.9 MB/s | 1796 MB/s |
| 4 KB | 131 MB/s | 2051 MB/s |
| 64 KB | 881 MB/s | 2179 MB/s |
| 1 MB | 1242 MB/s | 2052 MB/s |
# Build binary
go build -o horreum ./cmd/horreum
# Run with standard YAML configuration
./horreum --config config.yaml# Build Docker image
docker build -t horreum:latest .
# Run container
docker run -d -p 7373:7373 -p 9090:9090 --name horreum horreum:latestHorreum uses a lightweight 10-byte binary wire protocol. Ready-to-use client implementations are provided in the examples/ directory:
- Python Client
- Node.js Client
- Go Client
from examples.client import HorreumClient
client = HorreumClient('127.0.0.1', 7373)
client.connect()
# Set key
client.set("user:1001", "Alice")
# Get key
val = client.get("user:1001")
print("User:", val.decode())
client.close()For comprehensive guides and architecture details, refer to the docs/ directory:
- Getting Started Guide — Detailed setup, client usage, and Docker deployment.
- Configuration Reference — Full
config.yamland CLI flag specifications. - Protocol Specification — 10-byte binary frame specification.
- Architecture Deep Dive — Memory layout, concurrency, and persistence design.
Standard repository license applies. See AGENTS.md for project directives and code style conventions.
