QuickSilver is an open-source high-performance, in-memory key-value store with sharding, persistence, and multi-threaded client handling.
Designed for speed, scalability, and flexibility, it supports multiple database backends (InMemoryDB, ShardedDB), and persists data to disk.
β
In-Memory Storage β Fast key-value operations
β
Sharding Support β Distributes data across multiple instances
β
LRU Eviction β Removes least-recently used entries when full
β
Persistence β Saves and loads data from disk
β
Multi-threaded β Uses a thread pool for efficient client handling
β
Command Pattern β Extensible command execution
β
Cluster Support β Distribute data across multiple nodes
β
Pub/Sub System β Publish and subscribe to topics for real-time messaging
β
Consistent Hashing β Efficiently distributes keys across cluster nodes
β
TTL Support β Automatic expiration of keys after a specified time
QuickSilver follows a modular, layered architecture designed for high performance and scalability:
-
Server Layer
- Main entry point (
Server.java) that initializes the database, cluster service, and client handling - Manages server lifecycle, including graceful shutdown with data persistence
- Handles client connections through a thread pool for concurrent request processing
- Main entry point (
-
Client Handling
ClientHandler.javamanages individual client connections- Implements command routing and cluster redirection logic
- Handles special commands (FLUSH, DUMP) and client lifecycle management
-
Command Processing
CommandRegistry.javaimplements the Command Pattern for extensible operations- Supports both database operations (SET, GET, DEL) and pub/sub operations (PUBLISH, SUBSCRIBE, UNSUBSCRIBE)
- Commands are stateless and can be easily extended
-
Database Layer
- InMemoryDB: LRU-eviction based in-memory store with TTL support
- ShardedDB: Distributes data across multiple InMemoryDB instances using consistent hashing
- Both implementations support persistence through serialization
-
Clustering System
ClusterService: Manages cluster-wide operations and data synchronizationConsistentHashing: Distributes keys across cluster nodes efficientlyClusterClient: Handles inter-node communication for distributed operations- Automatic data synchronization across cluster nodes during startup
-
Pub/Sub System
PubSubManager: Manages topic-based publish/subscribe messaging- Real-time message distribution to subscribed clients
- Thread-safe subscriber management using concurrent collections
-
Configuration & Utilities
Config.java: Singleton configuration manager with property file supportThreadPoolManager: Centralized thread pool management with graceful shutdown- Utility classes for cluster operations and common functionality
π¦ quicksilver
βββ π src
β βββ π main
β β βββ π io.github.udayhe.quicksilver
β β β βββ π client
β β β β βββ ClientHandler.java # Handles client connections
β β β βββ π cluster
β β β β βββ ClusterClient.java # Sends commands to cluster nodes
β β β β βββ ClusterManager.java # Manages Cluster nodes
β β β β βββ ClusterNode.java # Cluster node
β β β β βββ ClusterService.java # Serves the cluster
β β β β βββ ConsistentHashing.java # ConsistentHashing
β β β βββ π command
β β β β βββ π implementation
β β β β β βββ Del.java # DELETE command
β β β β β βββ Exit.java # EXIT command
β β β β β βββ Flush.java # FLUSH command
β β β β β βββ Get.java # GET command
β β β β β βββ Set.java # SET command
β β β β β βββ Subscribe.java # SUBSCRIBE command
β β β β β βββ Unsubscribe.java # UNSUBSCRIBE command
β β β β β βββ Publish.java # PUBLISH command
β β β β βββ Command.java # Command interface
β β β β βββ CommandRegistry.java # Manages command execution
β β β βββ π config
β β β β βββ Config.java # Reads and manages configuration
β β β βββ π constant
β β β β βββ Constants.java # Application-wide constants
β β β βββ π db
β β β β βββ π implementation
β β β β β βββ InMemoryDB.java # In-memory key-value store
β β β β β βββ ShardedDB.java # Sharded database implementation
β β β β βββ DatabaseFactory.java # Factory to create DB instances
β β β β βββ DB.java # Generic database interface
β β β βββ π enums
β β β β βββ Command.java # Enum for commands
β β β β βββ DBType.java # Enum for database types
β β β βββ π threads
β β β β βββ ThreadPoolManager.java # Centralized thread pool manager
β β β βββ π util
β β β β βββ ClusterUtil.java # Cluster related utility methods
β β β β βββ Util.java # Utility class
β β β βββ Server.java # Main server entry point
β β βββ π resources
β β β βββ config.properties # Configurations (port, shards, etc.)
βββ π test # Unit tests
βββ π .gitignore # Git ignore rules
βββ π build.gradle # Gradle build file
βββ π Dockerfile # Docker configuration
βββ π gradlew # Gradle wrapper
βββ π LICENSE # License file
βββ π README.md # Project documentation
βββ π settings.gradle # Gradle settings
π¦ 1. Clone the Repository
git clone https://github.com/UdayHE/Quicksilver.git
cd Quicksilverπ§ 2. Build the Project
./gradlew buildβ‘ 3. Run the Server
java -jar build/libs/Quicksilver-1.0-SNAPSHOT.jarπ 4. Default Port: 6379
Set custom port:
java -jar build/libs/Quicksilver-1.0-SNAPSHOT.jar 7000Modify config.properties in src/main/resources/:
server.port=7000
db.type=SHARDED
shard.count=4
shard.size=100
| Command | Description | Examle |
|---|---|---|
SET key value |
Stores a value | SET username uday |
GET key |
Retrieves a value | GET username |
DEL key |
Deletes a key | DEL username |
FLUSH |
Clears all data | FLUSH |
EXIT |
Closes the connection | EXIT |
SUBSCRIBE topic |
Subscribes to a topic | SUBSCRIBE news |
UNSUBSCRIBE topic |
Unsubscribes from a topic | UNSUBSCRIBE news |
PUBLISH topic message |
Publishes a message to a topic | PUBLISH news "Breaking: ..." |
QuickSilver supports distributed clustering for high availability and horizontal scaling:
# Node 1 (Port 6379)
java -jar build/libs/Quicksilver-1.0-SNAPSHOT.jar 6379
# Node 2 (Port 6380)
java -jar build/libs/Quicksilver-1.0-SNAPSHOT.jar 6380
# Node 3 (Port 6381)
java -jar build/libs/Quicksilver-1.0-SNAPSHOT.jar 6381- Automatic Discovery: Nodes automatically discover and register with each other
- Data Synchronization: Initial data sync across all cluster nodes on startup
- Consistent Hashing: Keys are distributed across nodes using consistent hashing
- Load Distribution: Client requests are automatically routed to the appropriate node
- Fault Tolerance: Cluster continues operating even if individual nodes fail
All standard database commands work in cluster mode:
# Connect to any node and commands will be routed appropriately
telnet localhost 6379
SET user:1001 "John Doe"
GET user:1001Configure sharding in config.properties:
db.type=SHARDED
db.shard.total=4
db.shard.size=100
- Horizontal Scaling: Distribute data across multiple shards
- Memory Efficiency: Each shard has its own LRU cache
- Parallel Processing: Operations can be performed in parallel across shards
- Consistent Performance: Even distribution prevents hotspots
- Sub-millisecond latency for GET/SET operations
- High throughput with thread pool optimization
- LRU eviction prevents memory exhaustion
- TTL support for automatic data expiration
- Linear scaling with additional nodes
- Consistent hashing minimizes data movement during scaling
- Network optimization with efficient inter-node communication
- Load balancing across cluster nodes
Run the test suite:
./gradlew testBuild and run with Docker:
# Build the image
docker build -t quicksilver .
# Run a single instance
docker run -p 6379:6379 quicksilver
# Run multiple instances for clustering
docker run -p 6379:6379 --name quicksilver-1 quicksilver
docker run -p 6380:6379 --name quicksilver-2 quicksilverApache License Version 2.0
https://github.com/UdayHE/Quicksilver/blob/master/LICENSE