Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Google Has Open Sourced LevelDB, A Key-Value Datastore

Google Has Open Sourced LevelDB, A Key-Value Datastore

Leia em Português

This item in japanese

Google has open sourced LevelDB under the New BSD license. LevelDB is an embedded key-value datastore whose keys and associated values are arbitrary byte arrays sorted by key, a sorting mechanism that can be overridden. The datastore is pretty simple, accepting Put, Get, and Delete commands along with forward and backward iterations.

Data is automatically compressed using Snappy, a compression library used by Google for BigTable, MapReduce, and RPC and open sourced in April. LevelDB has some limitations: no support for SQL queries or indexes, supports multi-threaded single process access and is embedded, which is an advantage for some projects and a problem for others.

LevelDB is optimized for batch write operations. Multiple changes are accumulated and sorted in memory then written to disk when a certain configurable file size threshold is reached. The result is good performance for sequential and random writes, and sequential reads, beating SQLite by two orders of magnitude in some tests, according to a Google performance benchmark. SQLite remains a bit faster than LevelDB for random reads and at least twice as fast in writing large values. LevelDB also performed better than Kyoto Cabinet, a similar key-value store, but not as well as compared to SQLite. Also, some tests were performed by Riak comparing LevelDB with InnoDB, Google’s DB outperforming InnoDB in some tests or had similar performance.

LevelDB has been written in C++, and has few external dependencies being ported successfully to Windows, Mac OS X, Android, and various UNIXs. LevelDB is used by experimental versions of Chrome as the implementation for IndexDB API, by Riak for storage at node level, and by UpNext, a company doing 3D mapping software.

Rate this Article