# Tarantool — In-Memory Database and Lua Application Server > A high-performance in-memory database with a built-in Lua application server that combines the speed of an in-memory cache with the persistence and ACID guarantees of a traditional database. ## Install Save as a script file and run: # Tarantool — In-Memory Database and Lua Application Server ## Quick Use ```bash # Install on Ubuntu/Debian curl -L https://tarantool.io/release/3/installer.sh | bash sudo apt install -y tarantool # Start interactive console tarantool # Create a space and insert data box.cfg{listen=3301} s = box.schema.space.create('users') s:format({{name='id', type='unsigned'}, {name='name', type='string'}}) s:create_index('primary', {parts={'id'}}) s:insert{1, 'Alice'} s:select{} ``` ## 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{}` with `listen`, `memtx_memory`, and `wal_dir` parameters - Set up replication with `box.cfg{replication={'uri1', 'uri2'}}` for master-master clusters - Use the `cartridge` framework for multi-instance cluster management - Monitor with the built-in `box.stat()` and `box.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. ## Sources - https://github.com/tarantool/tarantool - https://www.tarantool.io/en/doc/latest/ --- Source: https://tokrepo.com/en/workflows/5d66cf2e-3d5b-11f1-9bc6-00163e2b0d79 Author: Script Depot