Introduction
Tarantool is an in-memory database that doubles as a Lua application server. Data lives in memory for microsecond-level access while WAL and snapshots provide disk persistence. The embedded LuaJIT engine lets developers write stored procedures, triggers, and full application logic alongside their data, eliminating the network hop between app server and database. Tarantool powers high-throughput systems at Mail.ru, Avito, and other large-scale services.
What Tarantool Does
- Stores data in-memory with WAL and snapshot persistence for crash recovery
- Runs Lua application code directly inside the database via the built-in LuaJIT engine
- Supports multiple data models: key-value, document, and relational (SQL) access
- Provides master-master replication with automatic conflict resolution
- Handles hundreds of thousands of transactions per second on a single core
Architecture Overview
Tarantool uses a single-threaded cooperative multitasking model powered by fibers (coroutines). All data resides in memory, organized into spaces (tables) with primary and secondary indexes backed by a PATRICIA trie or B-tree. Write operations are logged to a WAL for durability, and periodic snapshots create consistent disk images. The embedded LuaJIT VM executes application code in the same process, sharing memory with the database for zero-copy data access.
Self-Hosting & Configuration
- Install from the official repository for Ubuntu, CentOS, or macOS
- Configure
box.cfg{}withlisten,memtx_memory, andwal_dirparameters - Set up replication with
box.cfg{replication={'uri1', 'uri2'}}for master-master clusters - Use the
cartridgeframework for multi-instance cluster management - Monitor with the built-in
box.stat()andbox.info()introspection functions
Key Features
- Cooperative multitasking with fibers eliminates lock contention within a single thread
- LuaJIT application server enables stored procedures with near-C performance
- MVCC engine supports interactive transactions with serializable isolation
- Vinyl disk-based engine extends storage beyond available RAM for cold data
- Built-in HTTP server and connectors for Python, Go, Java, and PHP
Comparison with Similar Tools
- Redis — in-memory key-value store; Tarantool adds secondary indexes, SQL, and embedded application logic
- Memcached — pure cache with no persistence; Tarantool provides WAL, snapshots, and replication
- Apache Ignite — Java-centric distributed computing; Tarantool is C/Lua-based with lower latency per node
- Aerospike — distributed flash-optimized store; Tarantool keeps all hot data in memory with Lua scripting
- KeyDB — multi-threaded Redis fork; Tarantool offers richer data modeling and co-located compute
FAQ
Q: Why single-threaded? A: Tarantool's cooperative multitasking eliminates lock overhead. For multi-core scaling, deploy multiple instances with sharding via the vshard module.
Q: Can Tarantool handle data larger than RAM? A: Yes. The Vinyl engine provides LSM-tree disk storage for cold data while memtx handles hot data in memory.
Q: Does it support SQL? A: Yes. Tarantool supports a subset of ANSI SQL for querying spaces, alongside the native Lua and IPROTO APIs.
Q: How does replication work? A: Tarantool supports asynchronous master-master replication. Each instance applies remote WAL entries and resolves conflicts by last-write-wins or custom Lua handlers.