- Storage engine is responsible for managing how data is stored, both in memory and on disk. It is the component of the database.
- MongoDB supports multiple storage engines, as different engines perform better for specific workloads.
- Choosing the excellent storage engine for your use case can extensively have an impact on the overall performance of your applications.
- Here, there are four types of storage engines used by MongoDB :
- MMAPv1
- WiredTiger
- Encrypted
- In-memory
MMAPv1 :
- This type of storage engine uses memory-mapped files to store its data.
- A segment of virtual memory that has been assigned a direct byte-for-byte correlation with some portion of a file.
- This storage engine allows a great deal of performance for heavy read applications.
- Indexes and Data are mapped into virtual space.
- Data access is placed into RAM.
- It will swap out memory to disk to make space for the newly requested data if the OS runs out of RAM and an application requests for memory.
- MongoDB’s memory was managed by operating system’s virtual memory subsystem.
WiredTiger :
- From Mongo 3.0 WiredTiger is the default storage engine.
- This type storage engine uses document-level concurrency control for write operations. At the same time multiple clients can modify different documents of a collection.
- It uses only intent locks at the global, database and collection levels when the storage engine detects conflicts between two operations, one will incur a write conflict causing MongoDB to transparently retry that operation.
- MongoDB utilizes both the filesystem cache and WiredTiger internal cache. the wired tiger cache will use 50% of RAM minus 1 GB or 256 MB by default.
- It is efficient use of CPU cores and RAM.
- It allows more tuning storage engines than MMVPv1. 7 to 10X better write performance. 80% less storage with compression.
- In WiredTiger internal cache collection level data is uncompressed and uses a different representation from the on-disk format.
Encrypted :
- It is available in MongoDB enterprise only.
- During encryption master keys and database keys are used.
- Master key encrypts the database keys, data is encrypted with the database keys.
- Application-Level Encryption provides encryption on a per-field or per-document basis within the application layer.
In-memory :
- Available in the enterprise editions starting from version 3.2.6.
- It Handles ultra-high throughput with high availability and low latency.
- Low latency on less in-memory infrastructure and more predictable.
- Supports high level infrastructure based on zonal sharding.
- Indexing support and MongodB rich query capability.