Data archiving

更新时间:
复制 MD 格式

As the data volume in an ApsaraDB RDS for MySQL instance grows, so do your storage costs. You can archive infrequently accessed data, also known as cold data, to Object Storage Service (OSS) to significantly reduce your storage costs.

Note

You can join the RDS Storage Capability Communication DingTalk group (ID: 121770005512) to obtain more information about RDS storage capabilities. You can ask questions, communicate, and provide feedback in the group.

How it works

After you enable the data archiving feature for an ApsaraDB RDS for MySQL instance that uses Premium ESSD, you can run DDL statements to move data between the Premium ESSD and OSS. This feature allows you to archive large, infrequently accessed tables to OSS and read the data using native InnoDB access methods. The following DDL statements are supported:

  1. Archive a table

    ALTER TABLE $table_name ENGINE_ATTRIBUTE='{"OSS":"Y"}';
    Note

    ApsaraDB RDS for MySQL allows you to archive an entire table to OSS. After a table is archived, it becomes read-only. You can only perform SELECT, DROP TABLE, DROP DATABASE, and RENAME operations on it.

  2. Retrieve a table

    ALTER TABLE $table_name ENGINE_ATTRIBUTE='{"OSS":"N"}';

Archived tables in ApsaraDB RDS for MySQL retain their complete InnoDB index information and transactional properties. This enables fast offset queries and cache acceleration, which significantly improves the access efficiency for cold tables.

Benefits

By leveraging the massive capacity, high security, low cost, and high reliability of OSS, the data archiving feature provides a cost-effective solution for storing data on your ApsaraDB RDS for MySQL instance. It supports infrequent data access while retaining full InnoDB transactional capabilities. This can reduce your storage costs by up to 80% compared to using Premium ESSD PL1 disks.

Note

To improve query performance, you can enable the Buffer Pool Extension (BPE) feature.

Prerequisites

  • Engine: ApsaraDB RDS for MySQL

  • Product type: Standard and Yitian

  • Storage type: Premium ESSD

    Note
  • Billing method: pay-as-you-go and subscription

  • Engine version: MySQL 8.0 with a minor engine version of 20240131 or later

  • Edition: RDS Basic Edition, RDS High-availability Edition, and RDS Cluster Edition

  • Unavailable regions: Thailand (Bangkok), South Korea (Seoul), UK (London), and UAE (Dubai)

Billing

Free during public preview

During the public preview, which runs from April 24, 2024 to July 7, 2024, you can use this feature free of charge. After the public preview ends, you will be charged based on the amount of data archived to OSS.

Billing details

This feature supports only the pay-as-you-go billing method. The following table describes the pricing for different RDS editions and regions.

Region

Basic Edition pricing

High-availability Edition pricing

Cluster Edition pricing (per node)

China (Hangzhou), China (Shanghai), China (Nanjing), China (Fuzhou), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Wuhan), China (Shenzhen), China (Heyuan), China (Guangzhou), and China (Chengdu)

CNY 0.00021 per GB-hour

CNY 0.00042 per GB-hour

CNY 0.00021 per GB-hour

China (Hong Kong)

CNY 0.00022 per GB-hour

CNY 0.00044 per GB-hour

CNY 0.00022 per GB-hour

Philippines (Manila), US (Silicon Valley)

CNY 0.00038 per GB-hour

CNY 0.00076 per GB-hour

CNY 0.00038 per GB-hour

Japan (Tokyo), Singapore, Indonesia (Jakarta), Germany (Frankfurt)

CNY 0.00022 per GB-hour

CNY 0.00044 per GB-hour

CNY 0.00022 per GB-hour

Malaysia (Kuala Lumpur)

CNY 0.00037 per GB-hour

CNY 0.00074 per GB-hour

CNY 0.00037 per GB-hour

US (Virginia)

CNY 0.00035 per GB-hour

CNY 0.0007 per GB-hour

CNY 0.00035 per GB-hour

Note

Unavailable regions: Thailand (Bangkok), South Korea (Seoul), UK (London), and UAE (Dubai).

Limitations

  • The data archiving feature is not available for serverless ApsaraDB RDS for MySQL instances.

  • Tables stored in OSS are read-only and support only the SELECT, DROP TABLE, DROP DATABASE, and RENAME operations. After you retrieve a table to a Premium ESSD, it supports all operations.

  • You cannot archive partitioned tables, tables with full-text indexes, encrypted tables, tables with foreign keys, tables with triggers, or compressed tables (including table and page compression) to OSS.

  • Due to the access latency of OSS, querying cold tables stored in OSS may experience higher latency, of about 10 ms, compared to querying tables on a Premium ESSD.

  • A table must be at least 6 MB to be archived.

  • The execution time for an archive DDL statement depends on the table size. During the execution, the table is readable but not writable.

  • Enabling data archiving affects instance backups and other features as described in the following table:

    Unsupported feature

    Description

    Single-digit second backup

    • To use Single-digit second backup, you must first disable the data archiving feature.

    • Before you can enable the data archiving feature, you must make sure that Single-digit second backup is disabled.

    Cross-region backup

    • To use cross-region backup, you must first disable the data archiving feature.

    • Before you can enable the data archiving feature, you must make sure that cross-region backup is disabled.

    Restoration of individual databases and tables

    When you restore a database, you can restore only the non-archived data in that database.

    Backup set download

    A downloaded backup set contains only non-archived data.

    Note

    For an instance with data archiving enabled, backup and restoration operations take longer because the system must retrieve and restore archived data.

Usage notes

Archiving data to OSS and reading archived data from OSS consume memory. You must adjust the speed and frequency of data conversion and data access based on your workload.

Enable and disable data archiving

  1. Go to the Instances page, select a region in the top navigation bar, and then click the ID of the target instance. The instance must meet the prerequisites for data archiving.

  2. On the instance details page, click Configure Premium ESSD to the right of Premium ESSD, and then toggle the Data Archiving switch.

    Important
    • When you enable or disable the data archiving feature, a primary/standby switchover occurs, which causes a temporary interruption of about 30 seconds. We recommend that you perform this operation during off-peak hours and ensure that your application has an automatic reconnection mechanism.

    • To disable the data archiving feature, you must ensure that no archived tables exist in OSS. If there are archived tables in OSS, you must first run a DDL statement to retrieve them to the Premium ESSD or drop them before you can disable the feature.

View archived data

For ApsaraDB RDS for MySQL 8.0 instances with a minor engine version of 20241130 or later, you can directly query information_schema.innodb_tablespaces_oss to retrieve tablespace information more efficiently.

-- For ApsaraDB RDS for MySQL instances running a version earlier than 20241130
SELECT t.NAME AS tablespace_name, SUBSTRING_INDEX(t.NAME, '/', 1) AS database_name, SUBSTRING_INDEX(t.NAME, '/', -1) AS table_name, oss.OSS_OBJECT_NUM * oss.OSS_OBJECT_SIZE AS SIZE_IN_OSS_BYTES FROM information_schema.innodb_tables AS t JOIN information_schema.innodb_tablespaces_oss AS oss ON t.space = oss.space;

-- For ApsaraDB RDS for MySQL instances running version 20241130 or later
SELECT NAME AS tablespace_name, SUBSTRING_INDEX(NAME, '/', 1) AS database_name, SUBSTRING_INDEX(NAME, '/', -1) AS table_name, OSS_PART_SIZE AS SIZE_IN_OSS_BYTES FROM information_schema.innodb_tablespaces_oss;

References

The data archiving feature introduces several parameters that you can modify based on your business requirements. For more information, see List of available parameters for RDS MySQL 8.0.

Parameter

Default

Description

innodb_oss_ddl_threads

16

  • The number of concurrent threads for archiving and retrieving data.

  • Increasing this value can speed up data conversion until the bandwidth limit is reached, but it also increases memory and bandwidth consumption.

innodb_oss_files_limit

10240

  • The number of control blocks for archived data that can be cached in memory.

  • When data is archived to OSS, the table on the Premium ESSD is split into multiple data file blocks. Information such as the tablespace and data range for each block is stored in a control block. These control blocks are cached in memory to quickly locate the data requested from an archived table and are managed using a least recently used (LRU) algorithm.

innodb_oss_prefetch

ON

  • Specifies whether to enable prefetching for archived data.

  • When enabled, if the conditions for linear or random prefetching are met, the system caches the entire archived data file block directly in the buffer pool. This reduces OSS access frequency and improves access efficiency.

innodb_oss_prefetch_linear_pct_threshold

10%

  • The linear prefetch threshold for archived data.

  • When the number of sequentially read pages in an archived data block reaches this threshold, the entire data file block is cached in the buffer pool.

innodb_oss_prefetch_random_pct_threshold

30%

  • The random prefetch threshold for archived data.

  • When the number of randomly read pages in an archived data block reaches this threshold, the entire data file block is cached in the buffer pool.

innodb_oss_prefetch_task_limit

32

  • The maximum number of prefetch cache tasks.

  • Before a data file block is fully cached, additional memory is required to store its content. Increasing this value may lead to higher memory consumption.

oss_max_connections

64

  • The maximum number of concurrent HTTP connections allowed when the instance accesses OSS.

  • In high-concurrency scenarios, increasing this value can accelerate access to OSS, but it also increases CPU, memory, and bandwidth consumption.

FAQ

Q: Why does running an ALTER DDL command in MySQL result in the error [OSS] Size of tables is less than 6291456?

A: A table must be at least 6 MB to be archived.