Skip to content

Assistance Required with AWS DMS for Large Table Replication

0

Dear AWS re:Post,

My company is attempting to replicate a PostgreSQL database from our on-premises environment to an Aurora cluster (V2 Serverless) using AWS DMS. One of the tables in this database is particularly large, at 5 TB, and we've encountered several challenges during the replication process.

When we attempt to replicate the 5 TB table using primary keys, the replication starts well but eventually slows down to a point where it would take over a month to complete.

In a subsequent test, we partitioned the table (retaining the primary keys). While this initially improved the replication speed, it again slowed down significantly after some time.

We have ruled out the source database as the issue. Additionally, we scaled the DMS replication instance and Aurora database to their maximum configurations, but the problem persists. When the replication slows, the Aurora database’s Performance Insights indicate that most of the time is spent on io:DataFileReads.

To circumvent this issue, we conducted a test where we disabled primary keys during the replication. This significantly improved the performance, reducing the replication time to approximately four days for the entire table. However, this approach introduced another problem: if the replication is interrupted and restarted, duplicate records are created. Given the size of the table, removing duplicates is time-intensive.

We then tried to re-enable the indices after the replication to mitigate this issue. However, even at the maximum ACU configuration, we encountered the following error after about an hour:

ERROR: could not write to file "base/pgsql_tmp/pgsql_tmp55136.0.fileset/1.199": No space left on device.

Could you please provide guidance on:

  1. How to allocate additional space to avoid the above error.
  2. Alternative strategies or optimizations for replicating large tables like this efficiently without compromising data integrity.

We appreciate your assistance in helping us resolve this issue.

Best regards,
Max

2 Answers
0

Hi,

Did you think of an initial bulk upload of your tables and then applying DMS from a known CDC Start point ?

See https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Task.CDC.html#CHAP_Task.CDC.StartPoint

This way you can accelerate the initial load of the data in a quasi up-to-date state and catch up with updates from the CDC start point.

Best,

Didier

EXPERT

answered 2 years ago

  • Hi,

    Thank you for your response!

    We are performing a migrate and replicate migration, and the challenges we are encountering occur during the Full Load phase. Unfortunately, we are unable to create a dump of the database on our on-premises server, so we are reliant on AWS DMS for the initial data migration.

    Additionally, the large table I previously mentioned does not include a timestamp column or some other value based on which we could determine a known CDC start point.

    Best regards, Max

0

Thank you for providing such a detailed description of your AWS DMS replication challenges. I understand you're facing difficulties replicating a 5 TB PostgreSQL table to an Aurora cluster. Let me address your concerns and provide some recommendations.

  1. Allocating additional space: The error you're encountering suggests that the Aurora cluster has run out of storage space. To resolve this, you can:
  • Increase the maximum storage size for your Aurora Serverless v2 cluster. This can be done through the AWS Management Console or AWS CLI.
  • Consider enabling Aurora Auto Scaling, which automatically increases storage as needed.
  • If possible, temporarily move some data to another storage solution to free up space for the index creation process.
  1. Strategies for efficient large table replication:

a. Table Partitioning with Parallel Load: You mentioned you've tried partitioning, which is a good approach. To optimize this further:

  • Use the "parallel load" feature in AWS DMS for partitioned tables.
  • Configure the auto-partition option in the table mapping of your DMS task.
  • This allows DMS to load partitions in parallel, potentially speeding up the process.

b. Range Partitioning for Non-Partitioned Tables: If your table isn't partitioned on the source:

  • Use the "ranges" option in DMS task settings.
  • This allows you to specify range boundaries manually, enabling parallel loading of different sections of the table.

c. Optimize Task Settings:

  • Adjust the BatchApplyEnabled option to group transactions, potentially improving performance.
  • Tune the ChangeProcessingTuning settings to optimize change processing.

d. Use Table Mapping to Split the Large Table:

  • Create multiple tasks, each replicating a subset of the large table.
  • Use column filters or partition filters in the table mapping to divide the table logically.

e. Consider a Two-Step Approach:

  1. Perform an initial load without primary keys for speed.
  2. Set up a separate CDC (Change Data Capture) task to capture changes during and after the initial load.
  3. After the initial load, create the primary keys and apply the captured changes.

This approach maintains data integrity while leveraging the speed of replication without primary keys.

f. Optimize the Target Database:

  • Ensure proper indexing on the Aurora side to improve write performance.
  • Monitor and adjust the Aurora cluster's configuration, particularly focusing on I/O-related parameters.

g. Use DMS Data Validation:

  • Enable the data validation feature in DMS to ensure data integrity without relying solely on primary keys during replication.

Remember to thoroughly test these approaches in a non-production environment before implementing them in your production migration. Each strategy may have different impacts depending on your specific database structure and requirements.

By combining these strategies and continuously monitoring the replication process, you should be able to improve the efficiency of your large table replication while maintaining data integrity. If you continue to face issues, consider engaging AWS Support for personalized assistance with your specific use case.
Sources
AWS DMS best practices for moving large tables with table parallelism settings | AWS Database Blog
Step-by-step SQL Server AlwaysOn databases on primary replica to Amazon Aurora PostgreSQL migration walkthrough - Database Migration Guide
Troubleshooting target latency issues - AWS Database Migration Service

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.