Skip to content

Latest commit

Β 

History

515 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

⚑ Synap

License Rust Edition Tests Version

High-Performance In-Memory Key-Value Store & Message Broker

Synap is a modern, high-performance data infrastructure system built in Rust, combining the best features of Redis, RabbitMQ, and Kafka into a unified platform for real-time applications.

🎯 Overview

Synap provides multiple core capabilities in a single, cohesive system:

  • πŸ’Ύ Key-Value Store - Sharded in-memory storage with TTL, LRU/LFU eviction, and atomic operations
  • 🧱 Redis-compatible data structures - Hashes, Lists, Sets, Sorted Sets, Bitmaps, HyperLogLog, Geospatial indexes, and string extensions (APPEND, GETRANGE, SETRANGE, …)
  • πŸ“œ Lua Scripting - Server-side scripting with EVAL/EVALSHA and a redis.call() bridge
  • πŸ”„ Transactions - MULTI/EXEC/WATCH/DISCARD β€” atomic, durable (single WAL group-commit), replicated, and isolated from concurrent writers
  • ⏸️ Blocking operations - BLPOP/BRPOP/BRPOPLPUSH and BZPOPMIN/BZPOPMAX with Redis timeout semantics
  • πŸ” Cursor scans - SCAN plus HSCAN/SSCAN/ZSCAN with MATCH glob and COUNT
  • πŸ”” Keyspace notifications - Redis-style notify-keyspace-events (__keyspace@0__:* / __keyevent@0__:*) via Pub/Sub
  • πŸ‘€ KV Watch - KV.WATCH <pattern> streams value-carrying change events ({ key, event, version, value? }) over SynapRPC push or the /kv/ws WebSocket β€” a watcher never has to re-GET; available in all six SDKs
  • πŸ“¨ Acknowledgment Queues - RabbitMQ-style message queues with delivery guarantees, DLQ, priorities, and per-consumer prefetch/QoS
  • πŸ“‘ Event Streams - Kafka-style partitioned topics with consumer groups, retention policies, and consumer-offset-aware buffering
  • πŸ”” Pub/Sub Messaging - Topic-based publish/subscribe with wildcard support

✨ Key Features

⚑ Performance

  • 🏁 Redis 7 parity, measured: driven by the same redis-benchmark binary, Synap matches Redis at -P 1 on every command and sits at 0.85–0.95 pipelined on a single hot key β€” see Performance
  • πŸ“ˆ Wins on realistic workloads: with a randomized keyspace, Synap beats Redis 7 on SET/INCR/LPUSH by 14–25%, and at 200 connections wins SET at 1.19Γ—
  • πŸš€ Native SynapRPC protocol: ~3Γ— faster than the RESP3 compatibility path per operation (166k vs 56k rps at -P 1)
  • 🧡 Zero-copy hot paths: values live behind shared Arc<[u8]> buffers β€” parsed once, stored, replied, and replicated by refcount bump, no payload memcpy
  • πŸ’Ύ Efficient Memory: 92MB for 1M keys (vs ~200MB in Redis)
  • πŸ”„ 64-Way Sharding: multi-core scalability with lock-free atomic stats
  • βš™οΈ Async I/O: Built on Tokio for non-blocking operations
  • πŸ—œοΈ Smart Compression: LZ4/Zstd compression with minimal CPU overhead
  • ⚑ SIMD Acceleration: Runtime-dispatched AVX2/NEON/SIMD128 for BITCOUNT, BITOP, PFMERGE β€” up to 9.5Γ— faster than scalar on HyperLogLog merge

πŸ” Security & Authentication

  • πŸ”’ Authentication on every transport - HTTP, RESP3, SynapRPC, and MCP all gate commands behind auth; destructive/admin commands (FLUSHALL, CONFIG, SHUTDOWN, …) additionally require admin
  • πŸ”‘ bcrypt password hashing - Constant-time comparison; legacy SHA-512 hashes transparently rehash on next login
  • πŸ›‘οΈ Fine-grained Permissions - Users, API keys (expiration, IP filtering), resource-based ACLs
  • πŸ“ Audit Logging - Track all authentication events (login, API key usage, permission denials)
  • 🧯 DoS hardening - Parsers cap client-controlled allocations, bounded pub/sub channels, connection limits + idle timeouts on the binary listeners, no reachable panics
  • πŸ” Safe defaults - Binary listeners (RESP3/SynapRPC) bind to loopback by default

πŸ’ͺ Durability

  • πŸ’Ύ Full Persistence: WAL + Snapshots covering all datatypes β€” KV, Hash, List, Set, Sorted Set, Queue, and Stream
  • πŸ”„ Async WAL with group commit: Redis-style batching (10K ops/batch, 100Β΅s window); transactions commit as one atomic fsync
  • 🧾 Verified snapshots: CRC64 recomputed on load β€” corrupt/torn snapshots are rejected, never silently loaded
  • 🧠 True maxmemory: a shared budget sums every datatype (not just KV), with per-datatype accounting exposed as metrics
  • βš–οΈ PACELC Model: PC/EL (Consistency during partition, Latency in normal operation)
  • ⏱️ Recovery Time: 1-10 seconds from snapshots + WAL replay

πŸ›‘οΈ Reliability & High Availability

  • πŸ”„ Master-Slave Replication: 1 write master + N read replicas, wired directly from config
    • Every datatype converges β€” KV, hash, list, set, sorted set, queue, stream β€” via the same applier the WAL recovery path uses
    • Full sync via snapshot transfer (CRC verified) + partial sync via replication log; replicas joining mid-write-stream lose nothing
    • Works with persistence disabled (replication is decoupled from the WAL)
    • Auto-reconnect with intelligent resync; INFO replication reports live role, replica count, offset, and lag
  • βœ… Message Acknowledgment: Guaranteed message delivery with ACK/NACK
  • πŸ” Event Replay: Stream history and replay; retention protects events the slowest consumer hasn't read
  • πŸ”€ Manual Failover: Promote replica to master capability
  • 🧩 Cluster mode (preview): hash-slot topology (16384 slots), slot migration with rollback, and inter-node quota RPC β€” initialized from config, disabled by default

πŸ“Š Monitoring & Observability

  • πŸ“ˆ INFO Command - Redis-style server introspection (server, memory, stats, replication, keyspace)
  • 🐌 SLOWLOG - Slow query logging with configurable threshold (default 10ms)
  • πŸ’Ύ MEMORY USAGE - Per-key memory tracking across all data types
  • πŸ‘₯ CLIENT LIST - Active connection tracking and management
  • πŸ“Š Prometheus Metrics - process-scoped CPU/memory plus broker-level gauges (per-stream length, consumer-group lag, queue depth) at GET /metrics β€” see Observability

πŸ‘¨β€πŸ’» Developer Experience

  • πŸ€– AI Integration: MCP support for Cursor, Claude Desktop, and AI assistants
  • 🌊 StreamableHTTP Protocol: Simple HTTP-based streaming protocol
  • πŸ”Œ WebSocket Support: Persistent connections for real-time updates
  • πŸ“š Multi-language SDKs: TypeScript, Python, Rust (with reactive PubSub), Go, PHP, and C# clients with full authentication support
  • πŸ“– Rich Examples: Chat, event broadcasting, task queues, authentication examples, and more

πŸ”— Protocol Support

Synap supports three wire transports. All SDKs (Rust, TypeScript, Python, Go, PHP, C#) select the transport via URL scheme β€” no separate builder options required.

URL scheme Port Framing When to use
synap:// 15501 MessagePack over TCP βœ… Recommended default β€” lowest latency, binary, persistent connection, native type fidelity
resp3:// 6379 Redis text protocol over TCP Redis-compatible tooling, redis-cli, existing Redis client libraries
http:// / https:// 15500 JSON over HTTP Ad-hoc curl, webhooks, browsers

πŸ’‘ Recommendation β€” use synap://. SynapRPC is the preferred transport for production workloads: it keeps a persistent multiplexed TCP connection, avoids HTTP framing overhead, and preserves integer/float/bool/bytes types on the wire (no stringification). All data commands β€” KV, hashes, lists, sets, sorted sets, queues, streams, pub/sub, transactions, scripts, geospatial, HyperLogLog β€” are supported on every transport (streams and transactional write-queuing landed on the native wires in 1.3.0; queued writes travel as TXQUEUE, see Transports).

Since 1.2.0 the synap:// wire is Thunder β€” the HiveLLM family's shared binary RPC β€” on both ends: the server listener and the Rust, TypeScript, Python and C# SDKs run the same protocol implementation, so the two halves of a connection cannot drift. Wire v1 is frozen; a pre-1.2.0 client still interoperates. Every SDK β€” Rust, TypeScript, Python, C#, Go and PHP β€” runs the same protocol implementation, verified against one server build by the interop matrix, see docs/thunder-interop-matrix.md.

// TypeScript
const synap = new SynapClient("synap://127.0.0.1:15501");
# Python
client = SynapClient(SynapConfig("synap://127.0.0.1:15501"))
// Rust
let cfg = SynapConfig::new("synap://127.0.0.1:15501");
// PHP
$client = new SynapClient(new SynapConfig("synap://127.0.0.1:15501"));
// C#
var client = new SynapClient(SynapConfig.Create("synap://127.0.0.1:15501"));

⚠️ No silent HTTP fallback. Native transports (synap://, resp3://) raise UnsupportedCommandError for any command not mapped on that transport instead of silently falling back to HTTP. Use http:// if you need full REST access for commands outside the parity matrix.

Additional integration protocols:

  • πŸ€– MCP (Model Context Protocol): Configurable tools (KV, Hash, List, Set, Queue, Sorted Set) at /mcp endpoint with authentication support
  • 🌐 UMICP (Universal Matrix Inter-Communication Protocol): 13 operations via MCP bridge with TLS support

πŸ“Š Scalability

  • πŸ“– Read Scaling: Multiple replica nodes for distributed reads
  • 🏠 Event Rooms: Isolated event streams per room/channel
  • 🎯 Partitioned Topics: Kafka-style horizontal scaling with multiple partitions
  • πŸ‘₯ Consumer Groups: Coordinated consumption with automatic rebalancing
  • πŸ”€ Topic Routing: Efficient pub/sub with wildcard matching
  • πŸ”— Connection Pooling: Client-side connection management

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          Synap Server                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  HTTP/REST       β”‚  SynapRPC (TCP)      β”‚  RESP3 (TCP)              β”‚
β”‚  :15500          β”‚  :15501 (msgpack)    β”‚  :6379 (Redis text)       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  server/handlers/  (17 modules)                                     β”‚
β”‚  kv Β· hash Β· list Β· set Β· sorted_set Β· hll Β· bitmap Β· geospatial    β”‚
β”‚  queue Β· stream Β· pubsub Β· script Β· websocket Β· partition Β· cluster β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  protocol/resp3/command/        protocol/synap_rpc/dispatch/        β”‚
β”‚  kv Β· collections Β· advanced   kv Β· collections Β· advanced          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  core/  (data stores)                                               β”‚
β”‚  kv_store/  bitmap/  hash  list  set  sorted_set  hll  geospatial   β”‚
β”‚  queue  stream  pubsub  transactions  scripting                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Replication Log (Append-Only)  Β·  WAL + Snapshots persistence      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Master Node                    Replica Nodes (Read-Only)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Source layout

Since v1.0.0 the workspace is split into focused crates under crates/ (Vectorizer/Nexus layout). Layers go Foundation β†’ Core β†’ Features β†’ Presentation; higher layers depend on lower, never the reverse.

crates/
β”œβ”€β”€ synap-core/src/core/     # In-memory data engine (leaf crate β€” no server deps)
β”‚   β”œβ”€β”€ kv_store/            # Sharded KV store (TTL, eviction, atomic LRU)
β”‚   β”œβ”€β”€ hash Β· list Β· set Β· sorted_set Β· bitmap Β· hyperloglog Β· geospatial
β”‚   └── queue Β· stream Β· pubsub Β· partition Β· transaction Β· consumer_group
β”œβ”€β”€ synap-server/src/        # HTTP/WS/MCP/UMICP + protocol dispatch
β”‚   β”œβ”€β”€ server/handlers/     # REST handlers (kv, hash, list, set, queue, stream, pubsub, …)
β”‚   β”œβ”€β”€ protocol/resp3/      # RESP3 parser/writer + listener + command dispatcher
β”‚   β”œβ”€β”€ protocol/synap_rpc/  # SynapRPC command catalog + config + listener (wire: thunder)
β”‚   β”œβ”€β”€ persistence/         # WAL (async group-commit) + snapshots
β”‚   β”œβ”€β”€ replication/         # master / replica
β”‚   └── auth/ Β· hub/         # users/api-keys/ACL + HiveHub.Cloud multi-tenant
β”œβ”€β”€ synap-cli/               # Command-line client
└── synap-migrate/           # Migration utilities

sdks/rust/src/               # Rust SDK β€” Thunder's client under the hood
└── transport/               # SynapRPC / RESP3 / HTTP transports + command mappers

The binary RPC wire layer is not in this repository. It is Thunder (thunder-rpc), the HiveLLM family's shared implementation, which both the server and the Rust SDK depend on β€” so the two ends of the wire cannot drift.

Rust library consumers: synap_server::core::* is now synap_core::* (umbrella re-exports kept on synap_server for transition), and the former synap-protocol crate is gone β€” see the CHANGELOG for the type-by-type migration to thunder-rpc.

πŸš€ Quick Start

πŸ“¦ Installation

From GitHub Releases (Recommended):

Pre-built binaries for Linux (x86_64), macOS (Intel and Apple Silicon), and Windows (x86_64) are published on the GitHub Releases page.

# Example (Linux x86_64) β€” replace <version> with the latest release
wget https://github.com/hivellm/synap/releases/download/v<version>/synap-linux-x86_64.tar.gz
tar -xzf synap-linux-x86_64.tar.gz
cd synap-linux-x86_64
./synap-server --config config/config.yml

🐳 Docker:

Quick Start (Docker Hub):

# Pull and run latest image
docker pull hivehub/synap:latest
docker run -d \
  --name synap \
  -p 15500:15500 \
  -p 15501:15501 \
  -v synap-data:/data \
  hivehub/synap:latest

# Check health
curl http://localhost:15500/health

Build Locally:

# Clone and build
git clone https://github.com/hivellm/synap.git
cd synap
docker build -t hivehub/synap:latest .

# Run container
docker run -d \
  --name synap-server \
  -p 15500:15500 \
  -p 15501:15501 \
  -v synap-data:/data \
  hivehub/synap:latest

With Authentication:

docker run -d \
  --name synap-server \
  -p 15500:15500 \
  -p 15501:15501 \
  -v synap-data:/data \
  -e SYNAP_AUTH_ENABLED=true \
  -e SYNAP_AUTH_REQUIRE_AUTH=true \
  -e SYNAP_AUTH_ROOT_USERNAME=admin \
  -e SYNAP_AUTH_ROOT_PASSWORD=SecurePassword123! \
  -e SYNAP_AUTH_ROOT_ENABLED=true \
  hivehub/synap:latest

Multi-Architecture Build:

# Build and push multi-arch images (AMD64 + ARM64)
./scripts/docker/docker-publish.sh 1.3.1

# Or using PowerShell
.\scripts\docker\docker-publish.ps1 1.3.1

Docker Compose:

# Use docker-compose for replication setup
docker-compose up -d

# With authentication (set environment variables)
export SYNAP_AUTH_ENABLED=true
export SYNAP_AUTH_REQUIRE_AUTH=true
export SYNAP_AUTH_ROOT_USERNAME=admin
export SYNAP_AUTH_ROOT_PASSWORD=SecurePassword123!
docker-compose up -d

Available Images:

  • hivehub/synap:latest - Latest stable release
  • hivehub/synap:<version> - Specific version (e.g. hivehub/synap:1.3.1)
  • Supports linux/amd64 and linux/arm64 architectures

πŸ“– For detailed Docker documentation, see DOCKER_README.md

πŸ› οΈ From Source:

# Clone repository
git clone https://github.com/hivellm/synap.git
cd synap

# Build from source (requires Rust nightly 1.92+)
cargo build --release

# Run server
./target/release/synap-server --config config/config.yml

See Development Guide for detailed build instructions.

πŸ’» Basic Usage

# Start server (default port 15500)
synap-server

# Key-Value Operations
curl -X POST http://localhost:15500/kv/set \
  -H "Content-Type: application/json" \
  -d '{"key": "user:1", "value": "John Doe", "ttl": 3600}'

curl http://localhost:15500/kv/get/user:1

# Queue Operations
curl -X POST http://localhost:15500/queue/publish \
  -d '{"queue": "tasks", "message": "process-video", "priority": 1}'

curl http://localhost:15500/queue/consume/tasks

# Event Stream
curl -X POST http://localhost:15500/stream/publish \
  -d '{"room": "chat-room-1", "event": "message", "data": "Hello!"}'

# Pub/Sub
curl -X POST http://localhost:15500/pubsub/publish \
  -d '{"topic": "notifications.email", "message": "New order"}'

# With Authentication (if enabled)
curl -X POST http://localhost:15500/kv/set \
  -H "Authorization: Basic $(echo -n 'admin:password' | base64)" \
  -H "Content-Type: application/json" \
  -d '{"key": "user:1", "value": "John Doe"}'

# Or with API Key
curl -X POST http://localhost:15500/kv/set \
  -H "Authorization: Bearer sk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"key": "user:1", "value": "John Doe"}'

πŸ”’ Authentication & Security

Authentication is disabled by default for development. Enable it for production:

Features:

  • βœ… Root User Management - Configurable root user with full permissions
  • βœ… User Management - Create, delete, enable/disable users
  • βœ… API Key Management - Generate, revoke, and manage API keys with expiration
  • βœ… Fine-grained Permissions - Resource-based permissions (RabbitMQ-style)
  • βœ… Basic Auth & Bearer Token - Support for both authentication methods
  • βœ… Audit Logging - Track all authentication events (login, API key usage, permission denials)
  • βœ… Password Validation - Configurable password requirements (length, complexity)
  • βœ… IP Filtering - Restrict API keys to specific IP addresses

Via Config File (config/config.yml):

auth:
  enabled: true
  require_auth: true
  root:
    username: "root"
    password: "your_secure_password"
    enabled: true

Via Docker Environment Variables:

docker run -d -p 15500:15500 \
  -e SYNAP_AUTH_ENABLED=true \
  -e SYNAP_AUTH_REQUIRE_AUTH=true \
  -e SYNAP_AUTH_ROOT_USERNAME=root \
  -e SYNAP_AUTH_ROOT_PASSWORD=your_secure_password \
  synap:latest

Using Authentication:

# Basic Auth
curl -u root:password http://localhost:15500/kv/get/user:1

# Bearer Token (API Key)
curl -H "Authorization: Bearer sk_XXXXX..." http://localhost:15500/kv/get/user:1

# Query Parameter
curl "http://localhost:15500/kv/get/user:1?api_key=sk_XXXXX..."

See Authentication Guide for complete details.

πŸ”„ Replication Setup

Synap supports master-slave replication for high availability and read scaling.

Quick Start with Docker

# Start 1 master + 3 replicas
docker-compose up -d

# Master available at: localhost:15500
# Replica 1 at: localhost:15510
# Replica 2 at: localhost:15520
# Replica 3 at: localhost:15530

Manual Setup

Master Node Configuration (config/config-master.yml):

server:
  host: "0.0.0.0"
  port: 15500

replication:
  enabled: true
  role: "master"
  replica_listen_address: "0.0.0.0:15600"  # 15600 = replication (SynapRPC uses 15501)
  heartbeat_interval_ms: 1000
  max_lag_ms: 10000
  buffer_size_kb: 256
  replica_timeout_secs: 30

persistence:
  enabled: true
  wal:
    enabled: true
    path: "./data/wal/synap.wal"
  snapshot:
    enabled: true
    directory: "./data/snapshots"

Replica Node Configuration (config/config-replica.yml):

server:
  host: "0.0.0.0"
  port: 15500

replication:
  enabled: true
  role: "replica"
  master_address: "master:15600"  # Master's replication port
  heartbeat_interval_ms: 1000
  max_lag_ms: 10000
  buffer_size_kb: 256
  auto_reconnect: true
  reconnect_delay_ms: 5000

persistence:
  enabled: true
  wal:
    enabled: true
    path: "./data/wal/synap.wal"
  snapshot:
    enabled: true
    directory: "./data/snapshots"

Start Nodes:

# Terminal 1: Start master
synap-server --config config/config-master.yml

# Terminal 2: Start replica 1
synap-server --config config/config-replica.yml

# Terminal 3: Start replica 2
synap-server --config config/config-replica.yml

Usage Patterns

Write to Master:

# All writes go to master
curl -X POST http://localhost:15500/kv/set \
  -H "Content-Type: application/json" \
  -d '{"key": "user:100", "value": "Alice", "ttl": 3600}'

Read from Replicas (Load Balancing):

# Read from replica 1 (eventually consistent, ~5ms lag)
curl http://localhost:15510/kv/get/user:100

# Read from replica 2
curl http://localhost:15520/kv/get/user:100

# Read from replica 3
curl http://localhost:15530/kv/get/user:100

Monitor Replication Status:

# Check replication health on master
curl http://localhost:15500/health/replication

# Check replication status on replica
curl http://localhost:15501/health/replication

Consistency Guarantees

  • Master Reads: Strongly consistent (immediate)
  • Replica Reads: Eventually consistent (~5-10ms lag typical)
  • Write Durability: Writes confirmed after master commit
  • Replication: Asynchronous to replicas
  • Lag Monitoring: Real-time offset tracking

See docs/specs/REPLICATION.md for complete replication documentation.

For detailed Docker deployment guide, see:

🎯 Use Cases

πŸ’¬ Real-Time Chat

Use event streams for room-based messaging with message history and guaranteed delivery.

πŸ“‹ Task Distribution

Leverage acknowledgment queues for distributed task processing with retry logic.

⚑ Cache Layer

Utilize key-value store as a high-speed cache with TTL support.

πŸ“‘ Event Broadcasting

Implement pub/sub for system-wide notifications and event distribution.

πŸ”„ Microservices Communication

Use queues for reliable inter-service messaging with delivery guarantees.

πŸ› οΈ Technology Stack

  • Language: Rust (Edition 2024, workspace of focused crates: synap-core, synap-server, synap-cli, synap-migrate)
  • Runtime: Tokio (async/await)
  • Web Framework: Axum
  • Storage: 64-way sharded stores (ahash) with Arc<[u8]> shared values; radix trie for pub/sub topic routing
  • Serialization: serde (JSON, MessagePack)
  • Protocols: SynapRPC + RESP3 + HTTP/StreamableHTTP + WebSocket + MCP + UMICP

πŸ“š Documentation

πŸ“– Getting Started

  • User Guide - Complete getting started guide (Installation, Quick Start, Operations)
  • Admin Guide - Operations handbook (Deployment, Monitoring, HA, Security)
  • Tutorials - 8 practical tutorials (Chat, Queues, Caching, Pub/Sub)

πŸ”§ Core Documentation

πŸ”’ Security & Authentication

🌐 API & Protocols

πŸ“Š Performance & Testing

πŸ”§ Development & Planning

🧩 Component Specifications

πŸ“¦ SDKs

  • SDK Index - All six SDKs: transports, module coverage, quick start
  • TypeScript SDK - Node.js and browser support
  • Python SDK - Async/sync Python client
  • Rust SDK - Native Rust client library
  • Go SDK - Standalone repository, vendored here as a submodule
  • PHP SDK - Standalone repository, vendored here as a submodule
  • C# SDK - .NET 8+ client library

πŸ’‘ Examples

πŸ“Š Performance

βœ… Head-to-Head vs Redis 7 β€” live redis-benchmark (July 2026) ⚑

Both servers driven by the same redis-benchmark binary over RESP (release build, containers on one Docker network, persistence and auth off on both sides). Full methodology and history: docs/benchmarks/redis-vs-synap.md

Single hot key (Redis's best case β€” sharding buys Synap nothing):

Shape Result
-P 1 (per-op latency) Parity β€” within ~5% of Redis on every command; Synap ahead on GET, RPUSH, LRANGE
-P 16 (pipelined) 0.85–0.95 of Redis on GET/SET/SADD/INCR (~750–815k rps); Synap wins LPUSH at 1.51Γ—, ties LRANGE

Randomized 1M keyspace (the realistic shape β€” Synap's shards parallelize, Redis stays serial):

Op Synap rps Redis rps Synap/Redis
SET (c=50) 797,872 700,935 βœ… 1.14
INCR (c=50) 761,421 607,287 βœ… 1.25
LPUSH (c=50) 641,026 513,699 βœ… 1.25
GET (c=50) 742,574 789,474 0.94
SET (c=200) 742,000 β€” βœ… 1.19
INCR (c=200) 675,000 β€” βœ… 1.03

Native SynapRPC (Synap's own protocol; RESP3 exists for compatibility) is ~3Γ— faster per operation than the RESP3 path β€” 166–170k rps vs ~56k at -P 1 β€” and ~2.8Γ— faster than HTTP/JSON on a SET+GET round-trip.

Memory: 92 MB for 1M keys vs ~200 MB in Redis (54% less).

πŸ“ˆ What the v1.0 optimization rounds delivered

Optimization Effect
TCP_NODELAY + buffered writes Non-pipelined GET 1.1k β†’ 56k rps (52Γ—); pipelined 17k β†’ 833k (48Γ—)
Per-key write lock: mutex β†’ sharded RwLock + try_read fast path Pipelined SET 130k β†’ 785k; c=200 writes went from 0.24Γ— to 1.19Γ— Redis
Zero-copy values (Arc<[u8]> end-to-end) SET stores the parser's buffer by refcount bump; GET/MGET reach the socket without copying
Hot-path allocations removed (dispatch, replies, metrics, INCR in-place) INCR 480k β†’ ~800k rps; SADD 630k β†’ ~800k
SIMD (AVX2/NEON) BITCOUNT/BITOP/PFMERGE Up to 64 GiB/s popcount, 9.5Γ— faster HLL merge
O(1) stream consume seek + per-queue deadline min-heap Consume/ACK sweeps no longer scan whole buffers

Tests: 1,800+ across the workspace β€’ Benchmarks: 13 criterion suites + synap-bench load generator

βš–οΈ Comparison

Feature Synap Redis RabbitMQ Kafka
Key-Value βœ… βœ… ❌ ❌
Hashes / Lists / Sets / Sorted Sets βœ… βœ… ❌ ❌
Geospatial / Bitmaps / HyperLogLog βœ… βœ… ❌ ❌
Lua Scripting βœ… βœ… ❌ ❌
Transactions (MULTI/EXEC/WATCH) βœ… (durable + replicated) βœ… ❌ ❌
Blocking Pops (BLPOP/BZPOPMIN…) βœ… βœ… ❌ ❌
Keyspace Notifications βœ… βœ… ❌ ❌
KV Watch (value-carrying) βœ… (KV.WATCH + /kv/ws) ❌ (notify-only) ❌ ❌
Queues (ACK) βœ… ❌ βœ… ❌
Consumer Prefetch/QoS βœ… ❌ βœ… ❌
Priority Queues βœ… (0-9) ❌ βœ… ❌
Dead Letter Queue βœ… ❌ βœ… ❌
Event Streams βœ… βœ… (Limited) ❌ βœ…
Partitioned Topics βœ… ❌ ❌ βœ…
Consumer Groups βœ… ❌ ❌ βœ…
Retention Policies βœ… (5 types) βœ… (2 types) βœ… (1 type) βœ… (2 types)
Pub/Sub βœ… βœ… βœ… βœ…
Authentication βœ… (Users+API Keys) βœ… (ACL) βœ… (Users) βœ… (SASL)
RBAC βœ… βœ… (Limited) βœ… βœ…
API Key Expiration βœ… ❌ ❌ ❌
IP Filtering βœ… βœ… ❌ ❌
Replication βœ… (Master-Slave, all datatypes) βœ… βœ… βœ…
Persistence βœ… (WAL+Snapshot, CRC-verified) βœ… (AOF/RDB) βœ… (Disk) βœ… (Log)
PACELC Model PC/EL PC/EL PC/EC PA/EL
Native Compression βœ… (LZ4/Zstd) ❌ ❌ βœ… (Snappy)
StreamableHTTP βœ… ❌ ❌ ❌
MCP Support βœ… (Configurable, Auth) ❌ ❌ ❌
UMICP Support βœ… (13 ops, TLS) ❌ ❌ ❌
Enhanced Monitoring βœ… (INFO, SLOWLOG, MEMORY, Prometheus) βœ… (INFO) ❌ ❌
Password Hashing βœ… (bcrypt) βœ… (SHA256) βœ… (bcrypt) βœ… (SASL)
AI Integration βœ… (MCP+UMICP) ❌ ❌ ❌
Matrix Operations βœ… (via UMICP) ❌ ❌ ❌
Single Binary βœ… βœ… ❌ ❌
Zero-Duplicate Guarantee βœ… (Tested) N/A βœ… βœ…

Legend: βœ… Implemented | πŸ”„ In Progress | ❌ Not Available

πŸ“„ License

Apache License 2.0 - See LICENSE for details.

🀝 Contributing

See DEVELOPMENT.md for development setup and contribution guidelines.

About

Synap is a modern, high-performance data infrastructure system built in Rust, combining the best features of Redis, RabbitMQ, and Kafka into a unified platform for real-time applications.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages