×
Community Blog Exploration of Disk Space Issues in ApsaraDB for MongoDB

Exploration of Disk Space Issues in ApsaraDB for MongoDB

This article explores disk space issues in ApsaraDB for MongoDB, focusing on data deletion and disk space optimization to address storage fragmentation and scalability challenges.

By Decai Xu

1. Resource

Replica set instance that runs MongoDB 7.0.

1

2. Exploration of disk space Issues

(1) Can I reuse the instance storage space after data is deleted from collections?

1. Data status

2

The instance contains 10 collections that each has about 71 GB of data.

2. Delete a specific amount of data from collection_0

 db.collection_0.deleteMany({ time: { $lt: "2024-11-07 00:00:00" } });

3

3. Data status after data deletion

In collection_0, the data volume is 35.97 GB, the fragmentation rate is 21.56%, and the recyclable space is 3.91GB.

4

4. Continue to insert data to collection_0 and observe the data changes

5

In collection_0, the data volume is 36.07 GB, the fragmentation rate is 60.57%, and the recyclable space is 10.69 GB.

6

In collection_0, the data volume is 43.52 GB, the fragmentation rate is 52.40%, and the recyclable space is 9.48 GB.

7

In collection_0, the data volume is 46.05 GB, the fragmentation rate is 49.61%, and the recyclable space is 8.98 GB.

8

In collection_0, the data volume is 48.10 GB, the fragmentation rate is 47.35%, and the recyclable space is 8.57 GB.

9

In collection_0, the data volume is 55.45 GB, the fragmentation rate is 39.24%, and the recyclable space is 7.10 GB.

10

In collection_0, the data volume is 59.70 GB, the fragmentation rate is 34.56%, and the recyclable space is 6.26 GB.

11

In collection_0, the data volume is 114.57 GB, the fragmentation rate is 0.04%, and the recyclable space is 9.44 GB. Inserted data reuses the existing storage space, which reduces the fragmentation rate and the recyclable space.

(2) Test disk scale-down

1. Disk usage

12
13
14

The total disk space is 1,000 GB, among which 797.67GB has been used. The disk utilization is 79.77%. No disk fragments can be recycled.

2. Delete data

db.collection_0.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_1.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_2.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_3.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_4.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_5.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_6.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_7.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_8.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });
db.collection_9.deleteMany({ time: { $lt: "2024-11-11 00:00:00" } });

15

3. Storage usage after data deletion

16
17

The data volume is 320 GB and used storage space is 790 GB with a high fragmentation rate. In addition, a large amount of space can be recycled.

4. Scale down the disk space

18
19

Disk space is scaled down from 1,000 GB to 500 GB.

5. Storage after disk scale-down

20
21

The data volume is 320 GB, which occupies only 62 GB of storage space. The fragmentation rate is very low, and the disk fragments are recycled. The scale-down time takes about 35 minutes and the scale-down rate is about 9 GB/min.

3. Summary

  1. After data is removed or deleted, disk fragments are generated. If you do not perform compaction operations, the existing disk space is reused by inserted data.
  2. During disk scale-down, the disk space is recycled. The disk scale-down rate is about 9 GB/min.
0 1 0
Share on

ApsaraDB

504 posts | 155 followers

You may also like

Comments