WiredTiger and MMAPv1 are both storage engines supported by MongoDB. However, they differ in terms of their architecture, data compression, concurrency control, and journaling approach.
MMAPv1 stores data on disk as memory-mapped files, which means that the data is mapped into virtual memory and accessed directly from disk by the process. This approach provides high performance but can be limited in terms of scalability and concurrency. On the other hand, WiredTiger uses a document-level locking approach that allows for more fine-grained concurrency control, making it more scalable in multi-threaded environments.
One of the main advantages of WiredTiger is its support for compression. WiredTiger allows for data to be compressed when written to disk, which reduces the amount of disk space needed for storing data. WiredTiger uses compression algorithms such as Snappy, zlib, and bzip2, and can compress data up to 80
Another advantage of WiredTiger is its support for multi-document transactions. WiredTiger allows multiple operations to be grouped into transactions, making it easier to ensure data consistency across a distributed system. This feature can be helpful when implementing complex business logic that spans multiple documents.
WiredTiger also provides a more efficient journaling approach than MMAPv1. In MMAPv1, the journal simply logs changes to the database, while WiredTiger maintains a separate file for its journal that is compressed and rotated periodically. This approach provides better durability and reduces I/O latency for write operations.
Finally, WiredTiger provides better compression and encryption capabilities than MMAPv1. WiredTiger’s encryption approach is pluggable, meaning that users can choose their own encryption algorithm and key management system.
In summary, WiredTiger provides a more scalable, efficient, and secure approach to data storage than MMAPv1, with support for compression, multi-document transactions, and pluggable encryption.