Help Center> Document Database Service> FAQs> Installing a Client> Q&A About Switching Storage Engine to RocksDB for DDS 4.2 and Later Versions
Updated on 2024-05-20 GMT+08:00

Q&A About Switching Storage Engine to RocksDB for DDS 4.2 and Later Versions

What Are the Differences Between RocksDB and WiredTiger?

  • Data write method
    • Data is in the B+ tree structure in WiredTiger. A key in the flushed data corresponds to a version. Inserting, updating, or deleting a key directly operates the corresponding data node.
    • Data is in the LSM-tree structure in RocksDB. Data is written in the log appending mode with a key, a value, as well as a version. A key corresponds to multiple versions on a disk. Inserting, updating, or deleting data at the service layer is converted to writing data in RocksDB. When data of multiple versions is stacked to a certain threshold, the data is merged automatically. This is how compaction in RocksDB works.
  • Data organization
    • In WiredTiger, data of a collection or index corresponds to a disk file. The size of the collection is the same as that of the disk file.
    • In RocksDB, files of 64 MB each are distributed on a disk.

What Are the Advantages of RocksDB?

Table 1 lists the advantages of RocksDB over WiredTiger in the following aspects: open-source ecosystem, storage space, customizability, high memory pressure, frequent update and deletion, and multi-table scenario.

Table 1 Comparison between RocksDB and WiredTiger

Storage Engine

RocksDB

WiredTiger

Open-source ecosystem

Compared with WiredTiger, RocksDB has a better open-source ecosystem (GitHub Star). Some well-known databases, such as TiDB, CRDB, and YUGADB, use RocksDB as the storage engine.

The open-source community ecosystem is not as good as RocksDB.

Storage space

During RocksDB data writing, data of multiple versions is temporarily stored in some service scenarios. The data of multiple versions will be asynchronously merged into the final version. The storage space may temporarily increase.

WiredTiger flushes only the latest version of data to disks, consuming less storage space.

Customizability

In RocksDB, there are many performance tuning parameters. You can modify the parameters based on the read and write requirements of your services.

In WiredTiger, there are a few performance tuning parameters.

High memory pressure

The read and write performance of RocksDB is stable and does not change with the memory pressure.

WiredTiger needs to frequently flush dirty pages and swap memory and disk data. As a result, the read and write performance fluctuates greatly.

Frequent update and deletion

After a certain amount of new data is accumulated, the compact thread is automatically triggered to merge and aggregate data of multiple versions to release redundant disk space. Disk fragmentation does not occur.

After deleting data, WiredTiger merges and aggregates data of multiple versions, causing disk space fragments. However, WiredTiger does not return the disk space to the operating system. WiredTiger marks the disk space for subsequent writes of the current collection. Disk fragmentation is severe.

Multi-table scenario

RocksDB supports more than 10,000 tables and indexes.

If there are more than 1,000 tables or indexes in WiredTiger, the read and write performance is affected.

Why Does Huawei Cloud DDS 4.2 or Later Use RocksDB as the Storage Engine?

According to Table 1, RocksDB has many advantages over WiredTiger. Using the community-friendly RocksDB, Huawei Cloud DDS is compatible with APIs of multiple MongoDB versions, such as MongoDB 4.2, 4.4, and 5.0.

Will Services Be Affected If the Storage Engine of Huawei Cloud DDS 4.2 or Later Is Switched to RocksDB?

  • Function: A storage engine is a component of a database and manages the storage mode of data in the memory and disks. Although RocksDB and WiredTiger are different storage engines, DDS encapsulates its storage engine and is compatible with community APIs. Developers are unaware of the usage differences and services are not affected.
  • Performance: RocksDB has experienced a long-term community evolution. Based on custom development by the DDS team, RocksDB has no obvious difference in performance with WiredTiger. In some query scenarios, RocksDB has better performance, and its storage or compute resource usage is slightly different from WiredTiger.

Why Do Disk and CPU Usage Fluctuations Occur When Lots of Addition, Deletion, and Modification Operations Are Performed on Huawei Cloud DDS Using RocksDB?

  • In RocksDB, data is written in appending mode. Updating or deleting data will not modify the original data. Instead, the data is appended to the end. Therefore, the same key may have values of different versions on disks. This causes a piece of data may have multiple versions, increasing disk usage.
  • Values of different versions will be merged when the amount of newly written data reaches a certain threshold. This process calls compaction in RocksDB. Data is merged asynchronously. After a round of data merging completes, data of different versions is merged. After the data merging, a new single-version data file is generated and the old multiple-version data file is deleted. While a new file is being created and an old file is being deleted, both old and new files are stored and disk usage increases temporarily. After data merging completes, the disk usage decreases immediately.
  • Data merging occupies a small number of CPUs, and there may be a slight CPU usage fluctuation.

If the disk usage and CPU usage remain high, contact Huawei technical support.

Does DDS 4.2 or Later Support Customized Storage Engine Switchover?

No support plan is available. Please stay tuned for the service announcement.

Installing a Client FAQs

more