K/V存储数据库:Lightning MDB

jopen 11年前

LMDB是一个超快速,超紧凑的键 - 值存储数据库由Symas为OpenLDAP项目开发。它使用内存映射文件,所以它拥有一个纯内存数据库的读取性能,同时还提供标准的基于磁盘的数据库持久性,并且只限于虚拟地址空间的大小(但不限于物理RAM的大小)。
new-symas-logo.png
LMDB是一个微小的数据库,但有一些强大的功能:

  • 有序Map接口 (键总是排序,支持范围查询)
  • 完整的事务支持,支持完整的 ACID semantics with MVCC.
  • Reader/writer transactions: readers don't block writers and writers don't block readers. Writers are fully serialized, so writes are always deadlock-free.
  • Read transactions are extremely cheap, and can be performed using no mallocs or any other blocking calls.
  • Supports multi-thread and multi-process concurrency, environments may be opened by multiple processes on the same host.
  • Multiple sub-databases may be created with transactions covering all sub-databases.
  • Memory-mapped, allowing for zero-copy lookup and iteration.
  • Maintenance-free, no external process or background cleanup/compaction required.
  • No application-level caching. LMDB fully exploits the operating system's buffer cache.
  • 32KB of object code and 6KLOC of C.
  • Licensed under the OpenLDAP Public License

这是一个只读优化设计和执行读取比其他数据库引擎快好几倍,几个数量级,在很多情况下更快。这不是一个写优化设计;注重随机写入工作负载的其他数据库的设计可能更适合。

特性比较

一些流行的嵌入式键/值存储比较

LMDB BDB LevelDB Kyoto TreeDB
ACID Transactions x x

Nested Transactions x x

Multiple Namespaces x x

Sorted Keys x x x x
Sorted Duplicate Keys x x

Multi-thread concurrency x x x x
Multi-process concurrency x x

No cache tuning: zero-config x


Instantaneous crash recovery x


Zero-copy reads x


Zero-copy writes x


Atomic hot backup x

项目主页:http://www.open-open.com/lib/view/home/1389838839258