Real-World Problem: The Single-Thread Bottleneck Under Spike Traffic
Our team ran into a brutal bottleneck during Black Friday sales traffic. Our ingress controllers and worker pods scaled across 12 Kubernetes nodes without breaking a sweat, but our caching layer folded. We were running standard Redis 7 on dedicated cloud compute nodes equipped with 32 vCPUs and 64 GB of RAM.
Throwing larger hardware at the cluster solved nothing. Tail latency (p99) surged from 1.8 ms to 142 ms. Total throughput hit an immovable ceiling at 112,000 requests per second. Node metrics told the full story: core 0 was pegged at 100%, while the other 31 cores sat idle at 3% utilization. Microservices began dropping connection pools waiting for session tokens, which triggered a cascade of connection timeouts across our primary PostgreSQL instances.
Root Cause: Why the Classic Redis Architecture Stalls on Modern Hardware
Redis runs on a single-threaded event loop for command execution. This design avoids concurrency locks and race conditions completely. However, it cannot exploit symmetric multiprocessing (SMP) on modern cloud instances.
Under 25,000 active client connections, the main execution thread becomes an unavoidable serialization choke point. Redis 6 introduced multi-threaded I/O to handle socket reading and writing. Even so, the engine still executes commands sequentially on one core.
Teams usually work around this using three familiar patterns, but each introduces operational overhead:
- Redis Clustering: Sharding 8 or 16 Redis instances on a single machine spreads CPU load. However, it introduces cluster bus overhead, rigid 16,384 hash slot boundaries, and painful cross-slot multi-key restrictions.
- Memory Bloat: Running isolated instances duplicates process overhead. Worse, background RDB snapshots risk aggressive copy-on-write memory spikes that trigger the Linux out-of-memory (OOM) killer.
- Hot-Shard Cascade: If traffic hits a celebrity key or a single hot partition, that shard maxes out. Latency immediately backs up into upstream gateway services.
Benchmarking the Field: Redis, KeyDB, Dragonfly, and Garnet
Before re-architecting our caching topology, we benchmarked four drop-in candidates on identical c6i.8xlarge AWS instances (32 vCPUs, 64 GB RAM, 12.5 Gbps network).
| Engine | Concurrency Model | Protocol Compatibility | Key Architecture Advantage | Operational Trade-off |
|---|---|---|---|---|
| Redis 7.2 | Single-threaded execution + I/O threads | Native RESP2 / RESP3 | Battle-tested stability, ubiquitous tooling | Stalls on multi-core instances per single node |
| KeyDB | Multi-threaded shared-state event loops | RESP2 / RESP3 | Direct Redis fork, familiar operational tooling | Project maintenance and commit cadence have slowed |
| Dragonfly | Thread-per-core (shared-nothing) | RESP compatible | High memory density, custom hash index | BSL licensing limits commercial cloud hosting |
| Microsoft Garnet | Multi-threaded execution (.NET 8 runtime) | Full RESP parser | Tsavorite hybrid-log storage, zero-copy networking | Requires configuring .NET GC and thread pool settings |
KeyDB pushed throughput past 450,000 ops/sec, but p99 latency fluctuated wildly whenever memory usage exceeded 70%. Dragonfly posted impressive throughput numbers, yet its BSL license raised red flags with our legal team.
Microsoft Garnet proved to be the strongest open-source option. Open-sourced by Microsoft Research in early 2024, Garnet is built on the Tsavorite storage engine. It scales linearly across available cores, delivers millions of operations per second, and communicates over standard RESP.
Deploying Microsoft Garnet with Docker
Garnet speaks native RESP. That means standard Redis drivers—including redis-py, ioredis, go-redis, and StackExchange.Redis—work out of the box. You will not have to modify application-level queries.
Docker provides the fastest path to validate Garnet locally before rolling it out to staging clusters.
1. Run Garnet via Docker CLI
Microsoft maintains official container images on the GitHub Container Registry (GHCR). Launch a standalone instance bound to port 6379:
docker run -d \n --name garnet-cache \n -p 6379:6379 \n --memory="8g" \n --cpus="4.0" \n ghcr.io/microsoft/garnet:latest
Confirm the service booted cleanly by checking the container logs:
docker logs -f garnet-cache
The output will show Garnet initializing its network listeners, allocating Tsavorite memory segments, and setting worker thread counts equal to your assigned vCPUs.
2. Production Deployment with Docker Compose
Production environments demand tuned storage tiers, memory limits, and thread parameters. Define your settings in a dedicated garnet.conf file.
Create garnet.conf:
{\n "Port": 6379,\n "Address": "0.0.0.0",\n "EnableStorageTier": true,\n "Recover": true,\n "MemorySize": "8g",\n "PageSize": "32m",\n "ThreadPoolMinThreads": 16,\n "ThreadPoolMaxThreads": 64\n}
Next, assemble your docker-compose.yml file with resource reservations and persistent volume mappings:
version: '3.8'\n\nservices:\n garnet:\n image: ghcr.io/microsoft/garnet:latest\n container_name: garnet-cache-prod\n restart: always\n ports:\n - "6379:6379"\n deploy:\n resources:\n limits:\n cpus: '8.0'\n memory: 12G\n reservations:\n cpus: '4.0'\n memory: 8G\n volumes:\n - ./garnet.conf:/app/garnet.conf:ro\n - garnet-data:/app/data\n command: ["--config-import-path", "/app/garnet.conf", "--checkpoint-dir", "/app/data"]\n\nvolumes:\n garnet-data:\n driver: local
Start the container in the background:
docker compose up -d
3. Seeding Data and Verifying Compatibility
Connect with your existing redis-cli tool to verify protocol compatibility:
redis-cli -h 127.0.0.1 -p 6379 PING\n# Output: PONG\n\nredis-cli -h 127.0.0.1 -p 6379 SET user:1001 '{"name":"Alex","role":"DevOps"}'\nredis-cli -h 127.0.0.1 -p 6379 GET user:1001
We tested cache warming by converting a 120,000-row customer export into JSON records. You can format tabular dumps locally with in-browser tools like Toolcraft’s CSV to JSON converter to avoid leaking customer PII to external web services. Once formatted, pipeline the batch directly into Garnet using Python:
import json\nimport redis\n\nclient = redis.Redis(host='localhost', port=6379, db=0)\n\nwith open('seed_data.json', 'r') as f:\n records = json.load(f)\n\npipeline = client.pipeline(transaction=False)\nfor idx, record in enumerate(records):\n key = f"customer:{record.get('id', idx)}"\n pipeline.set(key, json.dumps(record), ex=3600)\n if idx % 500 == 0:\n pipeline.execute()\n\npipeline.execute()\nprint(f"Successfully imported {len(records)} records into Garnet.")
4. Stress Testing: Garnet vs. Redis
Run redis-benchmark from an adjacent instance over a dedicated network interface to measure raw throughput under load:
docker run --rm --net=host redis:7-alpine redis-benchmark \n -h 127.0.0.1 -p 6379 \n -c 128 -n 1000000 -P 16 -q -t get,set
On an 8-core host, Redis capped out at 215,000 requests per second. Garnet pushed 980,000 requests per second under the same pipeline depth. Crucially, Garnet held p99 latency at 0.42 ms, whereas Redis degraded past 18 ms once its single execution core hit 100%.
5. Key DevOps Takeaways
Garnet eliminated our CPU bottleneck without requiring schema migrations or client library changes. You avoid the network complexity and operational headaches of multi-instance sharding. If Redis is pinning a single core in your infrastructure, deploying Garnet on Docker lets you reclaim idle compute across every core on the host.

