Introducing HPKV: High-Performance KV Store

5 min readBy HPKV Team

We're excited to announce HPKV, a high-performance KV Store designed for modern applications. In this post, we'll explore what makes HPKV unique and how it achieves consistent nanosecond-level performance.

The Architecture Behind Nanosecond Performance

HPKV's exceptional performance comes from its carefully crafted architecture that combines several innovative techniques:

Data Structure

Storage Layer

Concurrency Engine

Memory Architecture

Optimize

Fast Access

Batch Write

Smart Alloc

Coordinate

Zero Contention

Process

Optimize

Manage

Optimize

Zero-Frag

Ordered Access

Real-Time Track

Fast Lookup

Prefetch

Optimized Write

Update Index

Smart Alloc

Cache Hit

Fast Lookup

Cache Miss

Process

Hint

Optimize

Clock-Based Cache

Record Cache

Write Buffer

Memory Pool

Predictive Allocator

Parallel Control

Lock-Free Ops

Work Queue

Adaptive Scheduler

Metadata Engine

Space Allocator

Storage Engine

Free Space Merger

Tree Index

Space Manager

Hash Index

Predictive Fetch

1. Lock-Free Architecture

At the heart of HPKV is a sophisticated lock-free design that minimizes contention and enables true parallel processing:

  • Per-CPU write buffers eliminate cross-CPU synchronization
  • Lock-free connection pools maximize throughput
  • Zero-copy operations reduce memory overhead
  • Advanced parallel control mechanisms for concurrent readers and writers
  • Wait-free read operations with snapshot consistency
  • Efficient memory reclamation with zero reader-writer contention
  • Adaptive scheduling for optimal resource utilization

2. Smart Caching

Our intelligent caching system ensures frequently accessed data is always at your fingertips:

  • Multi-tiered cache hierarchy with sub-microsecond hit times
  • Clock-based cache eviction with adaptive sizing
  • Zero-copy cache coherency protocol
  • Intelligent data prefetching with access pattern analysis
  • Per-CPU cache sharding for maximum throughput

3. Optimized Storage

The storage layer is designed for maximum efficiency:

  • Zero-fragmentation space management with real-time defragmentation
  • Adaptive block sizing with workload-aware optimization
  • Lock-free B-tree index with zero-contention range queries
  • Hybrid storage engine with optimized I/O patterns
  • Concurrent compaction with zero impact on read performance

4. HPKV Core: The Speed Engine

The core of HPKV is where the magic happens. Here's how we achieve nanosecond-level performance:

Zero-Overhead Architecture:

  • Direct data path optimization with zero-copy I/O
  • NUMA-aware data placement and thread scheduling
  • Optimized instruction paths for key operations
  • Advanced conflict detection and resolution

Memory Management:

  • Zero-contention memory pooling with thread-local caches
  • Adaptive memory allocation with usage pattern analysis
  • Intelligent NUMA-aware memory placement
  • Advanced memory reclamation with RCU

Advanced Concurrency:

  • Hybrid MVCC with optimistic timestamp allocation
  • Wait-free reader synchronization
  • Adaptive contention management with backoff strategies
  • Per-region consistency with timestamp-based ordering

I/O Optimization:

  • Intelligent I/O scheduling with priority-based queuing
  • Zero-copy direct I/O paths
  • Adaptive batch sizing based on load patterns
  • Optimized storage layout for sequential access

These innovations work together to deliver consistent nanosecond-level latencies while maintaining strong durability guarantees. Our approach focuses on eliminating traditional bottlenecks that plague other key-value storess, resulting in performance that was previously thought impossible.

Simple Yet Powerful REST API

HPKV provides a clean, intuitive REST API that makes integration a breeze. Here are some examples:

Storing Data

// Store a value await fetch('https://api.hpkv.io/record', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': 'your-api-key' }, body: JSON.stringify({ key: 'user:123', value: { name: 'John Doe', age: 30 } }) });

Retrieving Data

// Get a value const response = await fetch('https://api.hpkv.io/record/user:123', { headers: { 'X-API-Key': 'your-api-key' } }); const user = await response.json();

Deleting Data

// Delete a value await fetch('https://api.hpkv.io/record/user:123', { method: 'DELETE', headers: { 'X-API-Key': 'your-api-key' } });

Performance That Speaks for Itself

Our benchmarks show impressive numbers across different interfaces (tested with 1 million operations):

Core Performance (Local vectored call interface)

The following numbers were achieved on a modest 4 CPU cores (ARM - 3GHz) and 4GB RAM:

OperationP50P99Throughput
Read250ns920ns2.9M ops/s
Write460ns3210ns1.6M ops/s
Delete380ns1460ns2.1M ops/s

NOTE

HPKV can achieve up to 8x more throughput if tested with multiple threads and/or multiple nodes. This setup was chosed to show whhat HPKV is capabale of, even on a single node, while operations are performed sequentially.

REST API Performance (Same Region)

OperationP50P99Throughput
GET0.05ms0.55ms131K ops/s
POST0.15ms1.75ms59K ops/s
DELETE0.25ms3.75ms34K ops/s

NOTE

HPKV Provides other interfaces like WebSocket and RIOC API that provide superior performance for latency-critical applications which is not discussed in this blog post.

What's Next?

We're working on several exciting features which will be released in the coming 10 weeks:

  1. Multi-region replication with strong consistency
  2. Advanced monitoring and observability
  3. Enhanced backup and restore capabilities
  4. Extended API capabilities

Stay tuned for more updates as we continue to push the boundaries of what's possible with KV stores!