A lightweight Redis clone implemented in Go. This project serves as a learning platform to understand the internals of an in-memory key–value store, similar to Redis, and to experiment with core database concepts.
-
In-Memory Data Store:
Store keys and values in memory for extremely fast access and operations. -
Basic Command Interface:
Implement a simple REPL (read–eval–print loop) that supports fundamental commands such as:- SET: Store a key–value pair.
- GET: Retrieve the value associated with a key.
- DEL: Remove a key from the store.
(Additional commands may be added as the project evolves.)
-
Master-Slave Replication for Better Reads:
- The system follows a Master-Slave architecture to improve scalability and ensure high availability.
- The Master node handles all write operations (
SET,DEL). - Slave nodes replicate data from the Master and serve read requests (
GET), reducing load on the Master. - A synchronization mechanism ensures that slaves stay updated with the Master’s state.
-
Centralized Load Balancer with Automatic Failover:
- A dedicated Load Balancer efficiently distributes requests across Master and Slave nodes.
- Write operations are directed to the Master, while read operations (
GET) are distributed among the available Slaves for optimized performance and fault tolerance. - Master Failure Detection & Automatic Leader Election:
- The Load Balancer continuously monitors the Master’s health.
- If the Master goes down, the Load Balancer automatically elects a new Master from the available Slaves.
- All slaves update their configuration to recognize the new Master.
- This ensures high availability and minimizes downtime.
- Go:
Ensure you have Go (version 1.XX or later) installed. Download it from golang.org.
-
Redis: make build_main
-
Client: make build_client
-
Monitor: make build_monitor
-
Redis: ./bin/redis -port {port_num} -dir {dir name} -dbfile {filename}
-
Client: ./bin/client
-
Monitor: ./bin/monitor
-
SET KEY VALUE
-
SET KEY VALUE PX TIMEOUT_IN_MILISECONDS
-
GET KEY
-
DEL KEY