Q&A About Switching Storage Engine to RocksDB for DDS 4.2 and Later Versions
What Are the Differences Between RocksDB and WiredTiger?
| Storage Engine | Rocksdb | WiredTiger |
|---|---|---|
| Write Path Differences | RocksDB uses an LSM-tree data structure. Writes are append-only, similar to writing logs. Each on-disk record contains a key, a value, and a version. Each key has multiple versions. Application-layer inserts, updates, and deletions are all processed as write operations on RocksDB. When accumulated multi-version data reaches a certain threshold, RocksDB triggers background compaction to merge these versions. | WiredTiger uses a B+ tree structure, where each key corresponds to a single version. Inserts, updates, and deletions directly modify the corresponding data node. |
| Data Organization Differences | RocksDB does not have a collection-level storage structure. Instead, data is organized into files of about 64 MB each, distributed across the disk. | In WiredTiger, the data of a single collection or a single index corresponds to one file on disk, and the file size grows proportionally with the size of the collection. |
What Are the Advantages of RocksDB?
Table 2 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.
| 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 YugabyteDB, use RocksDB as the storage engine. | The open-source community ecosystem is not as good as RocksDB. |
| 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 2, 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.
What Are the Performance Differences and Optimization Suggestions for the RocksDB Storage Engine in Typical Scenarios?
Table 3 describes the performance differences between RocksDB and WiredTiger and optimization suggestions in some typical service scenarios.
| Scenario | RocksDB Performance Differences | Optimization Suggestions | Example |
|---|---|---|---|
| Multi-document scanning | RocksDB consumes more CPU and I/O resources than WiredTiger in scenarios where many documents need to be scanned. | Add appropriate indexes for optimization to improve the scanning efficiency and reduce the consumption of resources such as CPU and I/O. | For example, if no index is added to field A in the coll table, run db.coll.find({A: 1}) to query based on the field. |
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, all writes are append-only. Updating or deleting data will not directly modify the original data. Instead, the engine appends the new record to the end. As a result, multiple versions of the same key may exist on disk simultaneously. During this append-only process, multiple versions of the same data coexist, causing disk usage to increase.
- 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, submit a service ticket.
Does DDS 4.2 or Later Support Customized Storage Engine Switchover?
No support plan is available. Please stay tuned for the service announcement.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot