Never Ending Security

It starts all here

LMDB – Symas Lightning Memory-Mapped Database

Symas Lightning Memory-Mapped Database (LMDB)

This page contains technical information about Symas’s LMDB database library. LMDB is an ultra-fast, ultra-compact key-value embedded data store developed by Symas for the OpenLDAP Project. It uses memory-mapped files, so it has the read performance of a pure in-memory database while still offering the persistence of standard disk-based databases, and is only limited to the size of the virtual address space, (it is not limited to the size of physical RAM). Note: LMDB was originally called MDB, but was renamed to avoid confusion with other software associated with the name MDB

Quick Overview

LMDB is a tiny database with some great capabilities:

  • Ordered-map interface (keys are always sorted, supports range lookups)
  • Fully transactional, full 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

It is a read-optimized design and performs reads several times faster than other DB engines, several orders of magnitude faster in many cases. It is not a write-optimized design; for heavy random write workloads other DB designs may be more suitable.

Feature Comparison

A quick comparison of popular embedded key/value stores.

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


The full docs (generated by doxygen) are here.


Development occurs in the OpenLDAP Project‘s git repo in the mdb.master branch. A clone of just the LMDB code is also available on Gitorious.


Commercial Support

While not required, Symas offers fixed-price commercial support to those using LMDB in mission-critical applications. Send email inquiries to or call us at (650) 963-7601.

Porting and Professional Services

Thinking about switching your application to LMDB? Call us. We will be happy to provide developer support or porting services to help you transition your application to LMDB.


Questions and discussions of LMDB should be directed to the OpenLDAP mailing lists.

Published Reports on LMDB


Some microbenchmarks comparing it to other embedded databases are here. The tests compare OpenLDAP LMDB against Google LevelDB, SQLite 3, Kyoto Cabinet, and BerkeleyDB. The tests were conducted against multiple filesystems, including btrfs, ext2, ext3, ext4, jfs, ntfs, xfs, and zfs. LMDB is several orders of magnitude faster than everything else for reads, while also being several times smaller. Surprisingly, while LMDB’s focus is read speed, it is also decently fast for writes, and unmatched for bulk load speed.
Further testing using Memcached can be seen here. The tests compare LMDB against BerkeleyDB, MySQL 5.6 InnoDB, and pure-memory Memcached. Again, LMDB is multiple orders of magnitude faster than other disk-based storage engines, and is even faster than the pure-memory Memcached in multi-threaded workloads.
Tests comparing the read performance of LMDB to BerkeleyDB in OpenLDAP here.
A benchmark with HyperDex, using both its original LevelDB-based backend, and with LMDB, is now available here.
Additional tests with HyperDex are available here. These tests are longer duration and with smaller records, showing some areas where LMDB is weaker.
LDAP server benchmarks showing OpenLDAP using LMDB and BDB, as well as most of the major open source and proprietary directory servers were presented at LDAPCon 2013. Products tested included OpenDJ, 389DS, ApacheDS, and servers from Microsoft, CA, Oracle, and Novell. None of the others are anywhere near as efficient as OpenLDAP on LMDB. The slides are available on Lanyrd.
A benchmark with RocksDB and other LevelDB-based engines on In-Memory workloads is available here.
Scalability testing for In-Memory workloads, building on the previous tests here.
Scalability testing for On-Disk workloads, across a varying range of data sizes here.
In-memory testing using different malloc libraries here.
In-memory testing using different compression libraries here.

Many other databases claim to be lightweight, but none of them can beat LMDB’s compact 32K of object code. Many other databases also claim to be world’s fastest, but none of them are in LMDB’s league…

LMDB In Other Projects

Besides the LMDB backend for OpenLDAP slapd (back-mdb), support for LMDB is also available in these open source projects:

Cyrus SASL
Patches posted to the SASL mailing list
Heimdal Kerberos
Support is available in the development branch
Source code available on Gitorious
Domain Keys Identified Mail, integrated since version 2.6.0
Memcached with persistent storage using LMDB, on Gitorious. Tests with memcachetest shows that LMDB is several times faster than BerkeleyDB, and faster even than the pure-memory memcached.
Thrift-based storage server. Test results are available using the Yahoo! Cloud Serving Benchmark (YCSB).
A replicated state machine manager for HyperDex. Source code available on Github
A reliable and fast NoSQL server (distributed key/value store). Source code available on Github
(Coming soon)
Fast and secure email server. Support integrated since 2.11
IT infrastructure automation framework. Default backend as of 3.6.0
Near-realtime disk persistence Second strike with Lightning, code on Github
A redis-protocol compatible persistent storage server. On Github
High performance analysis of behavioral data. Formerly used LevelDB but switched to LMDB due to concurrency and performance issues in LevelDB.
A new high-performance noSQL database built on LMDB.
An Authoritative DNS server written in C++; delivering Very High Performance using LMDB.
A column oriented, embarrassingly distributed relational NoSQL database.
A client/server file backup system.
Distributed service discovery and configuration.
Backup Archiving REcovery Open Sourced. Integrated in 14.2
Deep learning / computer vision / neural network
Crypto currency
Cache driver for perl
Another redis clone, written in go
Distributed, versioned, image-oriented datastore
guile graph database
Building block for distributed storage systems
A distributed time series database
Another graph DB on LMDB
A Bitcoin client on LMDB
Another Bitcoin blockchain implementation built on LMDB
An Apache authentication module
Another time series database built on LMDB
Fast persistent queues for .Net
Another graph database on LMDB
Full text indexer in python, using LMDB
A fast and lightweight graph database in python
Persistence for the ngraph graphing library
Slumber DB
Key value store for JSON / REST
A key value store abstraction layer for node.js
Scala library implementing an item-based recommandation engine
A tutorial/demo NoSQL database on LMDB
A redis clone written in perl
An LMDB backend for the Raft consensus protocol
The core of the Paxos consensus protocol
privacy aware cloud-mobile database
a fast and flexible system for deep learning
High-performance authoritative-only DNS server
Haskell VCache
large, persistent, memcached values and structure sharing for Haskell
Raft-based consensus, embedded and programmable database for building distributed databases

Wrappers for Other Languages

The compact LMDB code can easily be called from other languages using their respective wrappers. All of these wrappers were developed by 3rd parties. If you need assistance with them, we can work with you and the wrapper authors as needed.

Erlang wrapper
Source code available on Github, developed for use with Riak but suitable for other Erlang apps as well.
C++ wrapper
Source code available here
Python wrapper
Source code available on Github
Python wrapper
(Another one) available on Github
Lua wrapper
Source code available on Github
Ruby wrapper
Source code available on Github
Go wrapper
Source code available on Github
Objective C wrapper
Source code available on Github
Node.js wrapper
Source code available on Github
Java wrapper
Using JNI, available on Github
.NET wrapper
Source code and binaries available on Github
Perl wrapper
Source code available on CPAN
Bindings and simplified wrappers in the main Crack source tree.
Rust wrapper
Source code available on
OCaml wrapper
Source code available on Github
PHP wrapper
Source code available on Github
PHP wrapper
Newer more extensive version available on Github
Haskell wrapper
Project page here
Julia driver
Source code available on Github
Matlab wrapper
Source code available on Github

Since the LMDB API is similar to BerkeleyDB, porting existing BDB-based code to LMDB is usually quite simple and fast. More projects will be adapted as they come to our attention.

More information can be found on:


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s