A Redis-inspired in-memory datastore built in pure Python to explore storage engines, networking, persistence, caching, and systems architecture.
Built to understand systems, not just use them.
Kedis-Python is a Redis-inspired in-memory datastore implemented from scratch in Python.
The project was created to explore how modern in-memory databases work internally by implementing core components such as:
- storage engines
- command routing
- networking
- persistence
- memory management
- transactions
- data structures
Rather than focusing on Redis compatibility, Kedis focuses on understanding the architectural and engineering principles behind high-performance backend systems.
- SET
- GET
- DEL
- EXISTS
SET user karthik
GET userLPUSH tasks coding
RPUSH tasks testing
LPOP tasksSADD skills python
SADD skills systems
SMEMBERS skillsHSET user name karthik
HGET user nameZADD leaderboard 100 karthik
ZRANGE leaderboardImplemented using a custom Skip List inspired by Redis sorted set internals.
EXPIRE session 60
TTL sessionSupports automatic key expiration.
Append-Only File (AOF) persistence:
- durable write logging
- automatic recovery on startup
- AOF compaction support
LRU-based eviction support:
- tracks key usage
- evicts least recently used entries when limits are reached
Supports transactional execution:
MULTI
SET a 1
SET b 2
EXECTCP server implementation supporting:
- multiple client connections
- command execution over sockets
- standalone local mode fallback
Built-in INFO command exposing:
- key counts
- data type statistics
- persistence information
- expiration information
- runtime metadata
When the server becomes unavailable:
- users can switch to standalone mode
- local operations continue
- users are warned about possible state divergence
- reconnection remains user-controlled
This feature was added to explore failure handling and graceful degradation.
Client
β
βΌ
TCP Server
β
βΌ
Command Parser
β
βΌ
Command Router
β
βΌ
Storage Engine
βββ Strings
βββ Lists
βββ Sets
βββ Hashes
βββ Sorted Sets (Skip Lists)
β
βΌ
Persistence Layer (AOF)
The architecture is intentionally modular to make experimentation and future rewrites easier.
Current benchmark results:
~5300 requests/sec
Environment:
- Python 3.x
- TCP networking enabled
- Concurrent client workload
- Mixed GET / SET operations
- AOF persistence enabled
Benchmarking is ongoing as persistence and networking layers continue to evolve.
The project includes automated tests covering:
- command execution
- data structures
- persistence recovery
- expiration behavior
Additional coverage is actively being expanded as the project evolves.
Kedis was created to explore:
- storage engine design
- command-driven architectures
- networking fundamentals
- persistence strategies
- memory management
- data structure implementation
- systems engineering tradeoffs
Sorted Sets are implemented using Skip Lists.
Reasons:
- expected O(log N) insertion
- expected O(log N) lookup
- natural ordered traversal
- simpler implementation than self-balancing trees
This mirrors the design approach used by Redis for sorted sets.
Kedis is an educational systems project and is not intended for production use.
Current limitations include:
- custom text protocol (RESP not implemented)
- thread-based concurrency model
- simplified memory accounting
- limited fault tolerance compared to production databases
These limitations are intentional learning opportunities and areas of active development.
Planned improvements:
- Buffered AOF persistence
- RESP protocol support
- Async networking
- Improved observability
- Memory-based eviction
- Enhanced benchmark tooling
- Additional persistence optimizations
This project explores concepts commonly found in modern backend systems:
- Redis-style architecture
- command dispatch systems
- persistence mechanisms
- cache eviction policies
- TCP networking
- transaction processing
- skip lists
- systems performance analysis
Kedis serves as an architecture and systems-design exploration platform before moving toward lower-level implementations and more advanced storage engine designs.
The long-term goal is to understand how production systems are engineered, optimized, and maintained.
Suggestions, issues, and discussions are welcome.
This project is primarily a learning and exploration platform, but contributions are appreciated.
V SS Karthik
AI/ML Student β’ Systems Enthusiast β’ Builder of developer tools and infrastructure projects
"Built to understand systems, not just use them."