LedisDB

LedisDB is a NoSQL database written in Go. It is similar to Redis and implements redis protocol. It can be used as a replacement of Redis. However, it uses RocksDB, LevelDB or goleveldb as storage engine. Therefore, unlike Redis, the storage is not limited by memory. The name LedisDB comes from Level-Redis-DB.

History

In 2014, Chinese programmer Siddon Tang was developing an application which depended on Redis heavily. He noticed that as the number of users of the application increases, the memory size is not enough for Redis. He found that SSDB could solve the problem. However, because of the three reasons below, he wanted to develop a database similar to SSDB using Go:

  1. Go development is quite rapid. Although the performance of Go is not as good as C++, it is great for rapid software development.
  2. He wanted to use LevelDB in his project and get some experience about LevelDB usage.
  3. He wanted to be more familiar with Redis.

Now, Siddon Tang is the Chief Engineer of PingCAP. He works on TiDB and TiKV. But LedisDB is still under his maintenance.

Query Execution

Tuple-at-a-Time Model

LedisDB uses iterators in query processing.

Logging

Logical Logging

LedisDB uses RocksDB, LevelDB or goleveldb as storage engine and thus inherits their logging mechanisms. They log all Put operations.

Compression

Dictionary Encoding Naïve (Page-Level)

Compression is disabled by default. The compression feature of the storage engine can be enabled via configuration. Data and index blocks are compressed individually. User can choose from a list of supported compression algorithms, like LZ4 and Snappy. User can choose to use Dictionary Compression, too. Data are decompressed when LedisDB retrieves them from the underlying storage engine.

Storage Model

N-ary Storage Model (Row/Record)

LedisDB uses RocksDB, LevelDB or goleveldb as storage engine and thus inherits their storage model. Data are stored in the form of ordered key-value pairs.

Stored Procedures

Not Supported

LedisDB does not support stored procedures, but like Redis, it provides the capability to evaluate scripts using the bulit-in Lua interpreter. Scripts will be cached by LedisDB and can be invoked from the cache later. However, they are just cached rather than stored.

Data Model

Key/Value

LedisDB is a key/value store but has rich data structures. In addition to simple key/value pair, it provides Hash, List, Set, ZSet. ZSets are sorted sets in Redis, every element in a sorted set is also associated with a floating point value, called the score. They are ordered by score and use their own value to break the tie.

Checkpoints

Non-Blocking Consistent Blocking

LedisDB provides two command line tool: ledis-dump and ledis-load, for taking a checkpoint and restoring from a checkpoint, which depends on storage engine's mechanism. LedisDB also uses that internally for synchronization between master and replica. No other ways to access the checkpoint mechanism found.

System Architecture

Shared-Nothing Embedded

LedisDB can be embedded in Go programs. It can also be used as an independent server. Multiple LedisDB nodes and coordinator nodes can form a cluster with partition and Master-Replica replication. Each server does not share anything with others and only communicates with each other through the network connection. LedisDB provides a SLAVEOF command thus a LedisDB server can be configured as a master node or a replica of some master node on the fly. It also provides a PING command for checking whether a server is alive. LedisDB cluster needs a group of dedicated coordinators (redis-failover) that use this two commands to monitor and manage the Master-Replica groups. To support partition, another group of coordinators (xcodis) is needed, which serve as proxies that dispatch requests to different Master-Replica groups based on partition. Unfortunately, in GitHub issue, the developer states that he will not maintain this part anymore, because he does not have enough time. For more detail, you can see this article about LedisDB cluster written by the developer.

Storage Organization

Log-structured

LedisDB uses RocksDB, LevelDB or goleveldb as storage engine. Therefore, it inherits their Log-structured storage organization.

Query Interface

Custom API HTTP / REST Command-line / Shell

LedisDB can be embedded in Go programs and programs can use its API to perform queries. LedisDB also provides a query interface in redis protocol called RESP(REdis Serialization Protocol), and can be queried via redis-cli. LedisDB has HTTP API support, too.

Joins

Not Supported

As a key/value store, no join feature is provided in LedisDB.

Indexes

Skip List Log-Structured Merge Tree

LedisDB does not make its own indexes, it just uses underlying storage engines' index data structure, which is the Log-Structured Merge Tree. They also use Skip List in the MemTable part.

Storage Architecture

Disk-oriented In-Memory Hybrid

LedisDB uses RocksDB, LevelDB or goleveldb as storage engine and thus inherits their storage architecture. It also provides an option to use memory-backed storage (via goleveldb).

Concurrency Control

Not Supported

There is no concurrency control protocol in LedisDB because it does not support transactions. Like Redis, LedisDB processes requests as command sequences. Each command is treated as a single atomic operation. However, LedisDB does not provide any mechanism to combine commands into transactions.

LedisDB Logo
Website

http://ledisdb.com/

Source Code

https://github.com/siddontang/ledisdb

Tech Docs

https://github.com/siddontang/ledisdb/wiki

Developer

Siddon Tang

Country of Origin

CN

Start Year

2014

Project Type

Open Source

Written in

Go

Supported languages

C, Go, JavaScript, Lua, Python

Derived From

LevelDB, RocksDB

Inspired By

SSDB

Compatible With

Redis

Operating Systems

Linux, OS X

Licenses

MIT