A blazing-fast KV store written in pure Golang without any dependencies with native pub-sub support, engineered for high-frequency, contention-heavy workloads.
β¨ The system starts from a single bucket and scales dynamically in real-time! When keys expire, they immediately stop being served and are removed during the next resizing.
- π Exponential Shard Scaling: Ensures capacity grows logarithmically, preventing premature resource exhaustion.
- π οΈ Zero Downtime Resizing: Live shard migration ensures uninterrupted operation. If one store is overloaded, the other takes its place seamlessly!
- True Elasticity: If load contention per shard increases, the engine scales up. If too many keys expire, it scales down.
- π Two-Engine Model: Writes shift to a larger engine when contention grows too high while the old engine continues serving reads.
- π Wait free Reads & Writes: Eliminates contention, enabling high-frequency write workloads.
- Just Run & Forget: Self-managing & self-healingβno babysitting required!
π‘ nubmq is polling-freeβnotifications are delivered instantly! π¨, polling is for suckers
- π― Event Scheduler: No CPU-wasting polling, just pure event-driven updates!
- π₯ Supported Notifications:
- Key Expiry: Get notified the moment a key expires.
- Key Updates: Real-time updates whenever a keyβs value changes.
- π‘ Subscription Model:
- Clients can subscribe to any key channel for updates.
- Listen to the
~Ex
channel for key expiries.
- Highly Available, Non-Blocking Priority Message Delivery:
- When contention rises, SET/GET operations are prioritized over event notifications. π¦
π‘ Every connection gets its own read and write buffers to enable non-blocking I/O across concurrent requests!
- π¦ Hierarchical Write Queues: Critical operations (
SET
,GET
) always get priority. - β‘ Ultra-fast Non-blocking I/O: Every client interaction is measured in microseconds!
π οΈ nubmq supports native pub-sub
- Automatic TTL-based eviction ensures memory efficiency without manual intervention.
- Event subscription notifications clients can subscribe for events/
- No-polling required! Uses SSE(server side events) for all notifications
- Garbage-Free Expiration Cleanup: Expired keys are soft deleted and permanently removed from engine during upscale/downscale operations.
- ποΈ Two-tier storage system:
- Each store consists of multiple shards.
- If a store gets congested, writes shift to a larger store.
- The old store keeps serving reads while data migrates.
- Zero downtime, no waiting! Clients never experience delays.
- Once migration is complete, the old store is removed from memory for garbage collection.
- β‘ Hyperfast SET/GET operations
- β³ Built-in Expiry with TTL
- π‘ Real-time Subscription Mechanism
- π Pure Golang, No Dependencies
- π₯ High-Performance Cache or NoSQL Mode (Just increase memory limits)
SET <key> <value>
SET <key> <value> EX <expiry_time_in_seconds>
GET <key>
SUBSCRIBE <key>
nubmq squeezes every drop of performance from modern CPUs!
- π Parallelized Goroutines: No single-threaded nonsenseβeverything runs concurrently.
- π Atomic Operations: Ensures rock-solid data integrity.
- π Benchmark Results: 900Β΅s write latency, 500Β΅s read latency under extreme load.
- π Peak Throughput: 115,809 ops/sec with 100 concurrent clients on an M2 MacBook Air.
Feature | nubmq | Redis | Memcached | Etcd |
---|---|---|---|---|
Architecture | Adaptive Sharding | Single-threaded | Static Buckets | Raft Consensus |
Scalability | Auto-Scales Up/Down | Vertical Scaling | Horizontal Only | Limited |
Write Latency | 900Β΅s | ~1.1ms | ~1.5ms | ~3ms |
Read Latency | 500Β΅s | ~700Β΅s | ~1ms | ~2ms |
Max Throughput | 115,809 ops/sec | ~85,000 ops/sec | ~60,000 ops/sec | ~20,000 ops/sec |
Pub/Sub Support | Yes, Instantaneous | Yes, Slow | No | No |
TTL Handling | Native, Optimized | Yes, but Heavy | No | No |
Lock-Free Reads | Yes | No | Yes | No |
Memory Efficiency | High, Dynamic GC | Medium | High | Low |
Dependencies | None (Pure Go) | Libevent, Lua | Libevent | Raft |
π Figures from testing on M2 Air or from official sources
Benchmarked on a 8 core fanless M2 air (all cores maxed out under load)
- Concurrent Clients: 100
- Peak Throughput: 115,809 ops/sec
- Average Throughput: 100,961.54 ops/sec
- Dataset Size: 1,000,000 unique keys
- Total Operations: 21,000,000 requests
- Total Time Tracked: 208 seconds
Would love it if someone can test on a better machine and post the results
first start the server with:
make build
run the benchmark with:
make test
or start the client with:
cd ./client
go run main.go
now just play around with commands like you do in redis-cli
- Parallelized Shard Store resizing: would make shard store resizing faster
- Clustering: currently only supports single nodes π€
nubmq is still a work in progress and is in no way perfect,there are still some data races here and there and a few unhandled errors feel free to report bugs and contributions in forms of issues and PRs are welcome