DEV Community

Alex Spinov
Alex Spinov

Posted on

Garnet Has a Free API: Microsoft's Redis-Compatible Cache Built on .NET

Microsoft built their own Redis. It's called Garnet, it's open source, and it's faster than Redis on their benchmarks.

What Is Garnet?

Garnet is a remote cache-store from Microsoft Research, compatible with the Redis API (RESP protocol). Built on .NET, it focuses on extreme throughput, low latency, and efficient memory usage.

docker run -p 6379:6379 ghcr.io/microsoft/garnet
redis-cli ping  # PONG — Redis compatible
Enter fullscreen mode Exit fullscreen mode

Performance Claims

Microsoft's benchmarks show:

  • Throughput: Up to 10x higher than Redis on multi-core machines
  • Latency: Sub-millisecond P99 at high throughput
  • Memory: Better memory efficiency through tiered storage

Key Features

# Standard Redis commands work
redis-cli SET mykey "hello"
redis-cli GET mykey
redis-cli LPUSH mylist "a" "b" "c"
redis-cli HSET myhash field1 "val1" field2 "val2"
redis-cli SUBSCRIBE mychannel
Enter fullscreen mode Exit fullscreen mode

1. Thread-scalable — Garnet scales with CPU cores. More cores = more throughput.

2. Tiered storage — Hot data in memory, warm data on SSD. Handle datasets larger than RAM.

3. Cluster mode — Redis Cluster protocol compatible for horizontal scaling.

4. Transactions — MULTI/EXEC with server-side stored procedures for complex operations.

5. TLS — Built-in TLS support for encrypted connections.

Use Cases

  • .NET shops — natural fit if your stack is already .NET
  • Cost optimization — handle more load per server = fewer servers
  • Large datasets — tiered storage means you don't need everything in RAM
  • Bing, Xbox, Azure — Microsoft uses Garnet internally

Redis Client Compatibility

# Python — same redis-py library
import redis
r = redis.Redis(host='localhost', port=6379)
r.set('key', 'value')
print(r.get('key'))  # b'value'
Enter fullscreen mode Exit fullscreen mode
// Node.js — same ioredis library
import Redis from 'ioredis'
const redis = new Redis(6379)
await redis.set('key', 'value')
console.log(await redis.get('key'))
Enter fullscreen mode Exit fullscreen mode

Any Redis client works. Same protocol, same commands.


Building caching infrastructure? Check out my developer tools or email spinov001@gmail.com.

Top comments (0)