OrionDB is a lightweight, high-performance in-memory key-value database server with persistence capabilities, written in C. This project is currently in early development (v0.1.0) with a modular architecture and a CMake-based build system.
- In-memory key-value storage with optional persistence
- Multi-threaded architecture with fine-grained locking (16 independent shards)
- Support for string and binary data types
- Key expiration (TTL support)
- CLOCK algorithm for efficient memory management
- Configurable durability levels (none, every second, or always)
- Memory-efficient storage with size-class aware arena allocation
- Robin Hood hashing with bloom filters for high-performance lookups
- Thread-local allocation buffers for reduced contention
- Efficient binary protocol
- Background worker threads for maintenance tasks
OrionDB uses CMake as its build system. Here's how to build the project:
# Clone the repository
git clone https://github.com/RuggeroRebellato/oriondb.git
cd oriondb
# Create a build directory
mkdir -p build
cd build
# Configure and build (Debug mode)
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
# Or for optimized release build
cmake -DCMAKE_BUILD_TYPE=Release ..
makeFor more detailed build instructions, see docs/BUILDING.md.
The following CMake options can be specified when configuring the build:
ORIONDB_BUILD_TESTS=ON/OFF: Build the test suite (default: ON)ORIONDB_BUILD_BENCHMARKS=ON/OFF: Build the benchmarks (default: ON)ORIONDB_BUILD_CLIENTS=ON/OFF: Build the client tools (default: ON)ORIONDB_USE_JEMALLOC=ON/OFF: Use jemalloc for memory allocation (default: OFF)
Example:
cmake -DCMAKE_BUILD_TYPE=Release -DORIONDB_USE_JEMALLOC=ON ..After building, you can run the server with:
# From the build directory
./bin/oriondb_server
# With custom options
./bin/oriondb_server -p 6380 -d 1Usage: ./bin/oriondb_server [-p port] [-d durability]
-p PORT Port to listen on (default: 6380)
-d LEVEL Durability level:
0 = None (never fsync)
1 = Every second (default)
2 = Always (fsync after every write)
-h Show this help message
OrionDB includes a command-line client for interacting with the server:
# Connect to local server (default: 127.0.0.1:6380)
./bin/orion_cli| Command | Description |
|---|---|
SET key value [EX sec] |
Set key to value, optionally with expiration |
GET key |
Get value for key |
DEL key |
Delete key |
QUIT or EXIT |
Close connection |
cli> SET mykey "Hello, World!"
OK
cli> GET mykey
Hello, World!
cli> SET counter 42 EX 60
OK
cli> GET counter
42
cli> DEL mykey
OK
cli> GET mykey
(nil)
cli> QUIT
Exiting.
OrionDB can be run in a Docker container:
# Build the Docker image
docker build -t oriondb .
# Run the container (exposing port 6380)
docker run -p 6380:6380 oriondb
# Run with custom port
docker run -p 7654:7654 oriondb ./oriondb_server -p 7654
# Run with custom durability level
docker run -p 6380:6380 oriondb ./oriondb_server -d 2OrionDB includes a stress testing tool:
# Run the stress test with default settings (8 threads, 30 seconds)
./bin/stress_test
# Connect to a specific server
./bin/stress_test 127.0.0.1 6380OrionDB uses a sharded architecture with the following key components:
- Arena Allocator: Efficient memory management with size classes and thread-local buffers
- Hash Table: High-performance Robin Hood hashing with bloom filters
- Database: Sharded data storage with fine-grained locking
- Server: Event-based networking with epoll and worker threads
- Configurable write-ahead logging
- Snapshot capability for persistence
- Option to disable fsync for maximum performance
As this is a v0.1.0 early release, there are some limitations:
- Limited command set compared to mature databases
- Basic client library functionality
- Limited configuration options
- Performance optimizations still in progress
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.