ApsaraDB RDS for MySQL provides the storage compression feature that you can use to compress your data, including actual data and system logs, at the storage layer. This reduces the unit storage cost.
Feature description
By default, the storage compression feature is disabled. You can enable the feature for your ApsaraDB RDS for MySQL instance based on your business requirements. After you enable the storage compression feature, the storage cost can be reduced by up to 50%. In theory, after you enable the storage compression feature, the amount of data that can be written is up to 2.5 times the amount of data that can be written before you enable the feature. For example, if the storage capacity of your RDS instance is 100 GB, you can write 100 GB of data before you enable the storage compression feature and you can write up to 250 GB of data after you enable the feature. The actual amount of data that can be written varies based on your business requirements.
The storage compression feature is suitable for table data in data storage and files in log storage, such as transaction log files. You can use the storage compression feature to compress a large amount of data to save disk storage and indirectly reduce data storage costs. The data includes the business data generated in daily operations or logs used for recovery and audit.
Enabling the storage compression feature has minimal impact on the instance performance. For more information, see Appendix: Stress testing of the storage compression performance.
Implementation
ApsaraDB RDS for MySQL leverages the intelligent transparent compression disk developed by Alibaba Cloud and the embedded dedicated chip and uses a compression algorithm whose compression level is equivalent to Level 6 of zlib to compress and decompress data in physical disks in real time. The data compression and decompression process is fully transparent and imperceptible to user applications. This prevents compatibility issues. Transparent compression reduces data migration within the disk and effectively reduces the inherent write amplification of the disk. Compared with traditional soft compression, transparent compression is more efficient and reduces the unit price of data storage without significant impacts on performance.
Billing rules
After you enable the storage compression feature, the billing rule for the storage capacity and the free quota on storage are changed.
You are charged storage fees based on the amount of physical data after the data is compressed.
Storage capacity fee
After you enable the storage compression feature, you can write more data. The formula that is used to calculate fees for the storage capacity changes. The following table describes the formula.
Storage compression status | Formula for storage capacity fees |
Disabled | Unit price of storage capacity × Storage capacity × Usage duration |
Enabled | 1.25 × Unit price of storage capacity × Storage capacity × Usage duration |
If you enable the storage compression feature, you must pay the price difference. The fees in the ApsaraDB RDS console prevail. If you place an order to enable the storage compression feature for a subscription RDS instance, the order is a configuration upgrade order. If you place an order to enable the feature for a pay-as-you-go RDS instance, the order is a specification change order. The billing logic is the same as the billing logic for a specification change.
Free quota on backup storage
If the total size of the backup files of your RDS instance does not exceed the free quota on backup storage, no fees are charged. For more information, see View and manage the size of backup files. If the total size exceeds the free quota, you are charged an hourly fee for the excess backup storage. The hourly fee is calculated by using the following formula: Hourly fee for backup storage = (Total size of backup files - Free quota) × Unit price of backup storage.
For more information about the billing rules of regular and archived backups, see Billable items. For more information about the unit price of the resources that are used to store regular and archived backup files, see Backup storage fees.
Storage type | Storage compression status | Free quota | Description |
Premium Enterprise SSD (ESSD) | Disabled | The free quota is equal to 200% of the storage capacity that you purchase for your RDS instance. | To view the free quota, you can check the Backup Usage parameter in the Usage Statistics section of the Basic Information page of your RDS instance. The Backup Usage parameter indicates the actual amount of logical data. |
Enabled | The free quota is equal to 400% of the storage capacity that you purchase for your RDS instance. | ||
Premium Local SSD | Disabled | The free quota is equal to 50% of the storage capacity that you purchase for your RDS instance. | |
Enabled | The free quota is equal to 100% of the storage capacity that you purchase for your RDS instance. |
The database backup objects refer to the user data before compression.
Prerequisites
The RDS instance meets the following requirements:
The RDS instance runs MySQL 8.0, MySQL 5.7, or MySQL 5.6.
The RDS instance runs RDS High-availability Edition or RDS Cluster Edition.
The RDS instance uses a dedicated instance type.
The RDS instance uses Premium ESSDs or Premium Local SSDs.
If the RDS instance uses Premium ESSDs, the storage capacity ranges from 1,000 to 25,000 GB. If the RDS instance uses Premium Local SSDs, the storage capacity ranges from 1,000 to 2,400 GB.
The RDS instance uses the subscription or pay-as-you-go billing method.
Limits
The storage compression feature cannot be disabled after the feature is enabled.
If you enable the storage compression feature for your RDS instance, the following limits are imposed on specification changes:
If the RDS instance uses a dedicated instance type, you cannot change the instance type to a general-purpose instance type.
If the RDS instance uses the pay-as-you-go to billing method, you cannot change the billing method to serverless.
If the RDS instance uses Premium Local SSDs, you cannot change the storage type to cloud disk.
You cannot reduce the storage capacity to a value lower than 1,000 GB.
If the RDS instance uses cloud disks, you cannot perform elastic upgrades.
Read-only RDS instances: Before you can enable the storage compression feature for the primary RDS instance, you must enable the feature for the read-only RDS instances. For more information, see Read-only ApsaraDB RDS for MySQL instances. If you enable the storage compression feature for the primary RDS instance, the storage compression feature is automatically enabled for the new read-only RDS instances attached to the primary RDS instance.
Backup and restoration:
The database backup objects refer to the user data before compression.
After you enable the storage compression feature, the backup data cannot be compressed. However, you can enable the storage compression feature for RDS instances that are restored from backup files. For more information, see Backup and restoration.
Recycle bin: If you enable the storage compression feature for the original RDS instance, the storage compression feature is also enabled for the RDS instance that is restored from the recycle bin. For more information, see Use the recycle bin feature.
Enable the storage compression feature
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which your RDS instance resides. Then, find the RDS instance and click the instance ID.
In the Configuration Information section of the Basic Information page, click Enable Storage Compression.
NoteIf the button is not displayed, you must check whether your RDS instance meets the requirements described in Prerequisites.
In the Enable Storage Compression dialog box, read and confirm the usage notes and click OK.
Click OK to enable the storage compression feature. The status of the RDS instance changes to Upgrading/Downgrading. If Enabled is displayed for the storage compression feature in the Configuration Information section, the storage compression feature is enabled.
FAQ
How do I view the disk space metrics after I enable the storage compression feature?
On the Standard Monitoring tab of the Monitoring and Alerts page of your RDS instance, you can view the MySQL Storage Space Used (MB) Disk Usage (%), and MySQL Physical Storage Space Used (MB) metrics to analyze the storage usage after the storage compression feature is enabled. For more information, see View the monitoring information.
Appendix: Stress testing of the storage compression performance
If you enable the storage compression feature for your RDS instance, the instance performance is not affected. This section compares the instance performance before and after you enable the storage compression feature to check the impacts of storage compression on instance performance.
Test environment
Application server: an Alibaba Cloud Elastic Compute Service (ECS) instance
RDS instance specifications: RDS High-availability Edition and a dedicated instance type that provides 8 cores and 32 GB of memory
Storage type: Premium ESSD with I/O performance burst enabled
Storage capacity: 1,000 GB
Test case
sysbench provides the following test cases:
oltp_read_only
oltp_read_write
oltp_write_only
Sample command:
sysbench oltp_write_only --mysql-host=xxxxxx --mysql-port=xxxxxx --mysql-user=xxxxxx --mysql-password=xxxxxx --tables=12 --table_size=4000000 --report-interval=1 --mysql-db=xxxxxx --rand-type=uniform --threads=1 --time=100 runTest results
The following figure shows the results of the test on a dataset of 12 GB.

Concurrency
oltp_read_only
oltp_read_write
oltp_write_only
Before compression
After compression
Increase ratio
Before compression
After compression
Increase ratio
Before compression
After compression
Increase ratio
1
6738.05
6534.69
-3%
4698.92
4620.96
-2%
3296.62
3151.49
-4%
8
49446.32
48834.86
-1%
30464.41
29389.79
-4%
17935.94
17371.47
-3%
16
79411.76
78639.35
-1%
47852.25
46415.14
-3%
27851.15
27257.97
-2%
32
100070.48
100314.49
0%
68408.67
68521.4
0%
40468.31
39921.37
-1%
64
113637.5
112402.16
-1%
82387.07
82751.29
0%
57843.89
57267.82
-1%
128
113871.22
112133.53
-2%
90124.61
89783.53
0%
69850.39
68477.59
-2%
256
108770.33
107001.19
-2%
88390.16
88001.18
0%
79330.67
79290.03
0%
512
104325.11
102797.59
-1%
85701.04
84782.41
-1%
77186.74
76983.98
0%
The following figure shows the results of the test on a dataset of 48 GB.

Concurrency
oltp_read_only
oltp_read_write
oltp_write_only
Before compression
After compression
Increase ratio
Before compression
After compression
Increase ratio
Before compression
After compression
Increase ratio
1
1945.09
1902.89
-2%
1700.04
1748.47
3%
1639.68
1722.17
5%
8
15934.45
15155.32
-5%
13049.89
13230.25
1%
12203.44
12518.78
3%
16
32436.32
31072.3
-4%
23130.89
23727.46
3%
20668.33
21196.57
3%
32
56018.88
55409.98
-1%
38182.38
39864.06
4%
30498.33
31356.85
3%
64
72838.53
73459.99
1%
51153.83
51888.1
1%
41560.41
42073.77
1%
128
80598.87
80788.34
0%
58943.65
58837.55
0%
50755.55
51526.62
2%
256
80500.57
80369.96
0%
58969.94
59222.25
0%
56874.2
56512.52
-1%
512
74476.62
74758.1
0%
58756.28
58347.02
-1%
58009.1
58565.04
1%