Lesson 2 of 5 Operational and Purpose-Built Databases

Extracting Data from RDS and Aurora Without Harming Applications

This lesson explains how to extract data from relational databases, the most common pipeline sources, without harming the applications they serve, and how serverless pipelines connect to them.

Learning outcomes

After completing this lesson, you will be able to:

  • Extract safely from read replicas and with zero-ETL.
  • Use RDS Proxy for connections from serverless components.
  • Write results back to databases with bulk mechanisms.

The services

Amazon RDS and Amazon Aurora provide managed relational databases, which often serve as sources and occasionally as targets of data pipelines. Amazon RDS runs managed MySQL, PostgreSQL, MariaDB, Oracle, SQL Server and Db2. Amazon Aurora is compatible with MySQL and PostgreSQL and uses a distributed storage layer, with up to 15 low-lag read replicas and Aurora Serverless v2, which scales capacity automatically.

Both are designed for online transaction processing (OLTP): many small reads and writes from applications. They are not designed for heavy analytics, which is why analytical workloads copy or replicate their data into a data lake or Amazon Redshift rather than querying them directly.

Extracting data safely

Extracting data from an operational database must not slow the application that depends on it. Queries against a read replica take the load off the primary instance. An Aurora clone is created quickly using copy-on-write storage, giving a full copy of the database for a large one-off extract without affecting production. For ongoing changes, DMS CDC reads the transaction log with little load.

Exporting snapshots to S3 writes a database snapshot as Parquet files that Athena or Glue can query, without touching the live database. Zero-ETL integrations replicate Aurora and RDS data into Redshift automatically. The following table summarises the methods.

MethodUse for
Query a read replicaExtraction without loading the primary
Aurora cloneA copy-on-write copy of the database for a large one-off extract
DMS CDCOngoing changes, read from the transaction log
Export snapshots to S3 (Parquet)Bulk analytics without touching the live database
Zero-ETL integrationsAutomatic replication into Redshift

The following diagram shows a nightly extract moved off the Aurora writer to a replica through the reader endpoint.

Moving the nightly extract off the writer. The application writes through the cluster endpoint to the writer instance. The extract now reads through the reader endpoint from an Aurora replica, which shares the cluster's storage, so the writer carries no extract load. A zero-ETL integration with Redshift is planned so that the extract can be retired.
Dashed arrows mark planned or optional paths.
Match the pairs

Extracting without harm

Exam skills 2.1.5 · 1.1.2

Match each requirement with the extraction method.

Log in to try this activity Interactive activities are free with an account.

Connections from serverless pipelines

Serverless pipeline components, such as Lambda functions, can open many database connections at once, which relational databases handle poorly. RDS Proxy pools and shares connections, so many invocations use a small number of database connections; it also improves resilience during failovers and supports IAM authentication with credentials from Secrets Manager.

The RDS Data API, available for Aurora, runs SQL over HTTPS without persistent connections, which suits Lambda functions and Step Functions workflows. Glue jobs reach databases in a VPC through a Glue connection that specifies a subnet and a security group with a self-referencing rule.

Scenario questions

Serverless connections

Exam skills 1.4.2 · 2.1.2

Choose the connection approach for each requirement.

Log in to try this activity Interactive activities are free with an account.

Databases as pipeline targets

Pipelines sometimes write results back to operational databases, for example customer scores used by an application. Bulk loads should use the engine's bulk mechanisms, such as LOAD DATA FROM S3 in Aurora MySQL or the aws_s3 extension in Aurora PostgreSQL, rather than row-by-row inserts, and should run outside peak hours.

Worked example

An extract that slows the application

A nightly extraction query against the production Aurora PostgreSQL database causes application timeouts, because it scans large tables while the application is busy. The following table lists the available fixes and their effects.

FixEffect
Run the extract against an Aurora replica (reader endpoint)No load on the writer
Use an Aurora clone for very large extractsA separate copy-on-write cluster for the job
Use zero-ETL integration to RedshiftContinuous replication with no extraction queries
Use DMS CDCReads the transaction log instead of the tables

The team moves the extract to the reader endpoint immediately, and plans a zero-ETL integration so that the extract can be retired.

Check yourself

How can a large analytics copy be taken without affecting the database?

Show answer

By exporting a snapshot to S3, which reads from the snapshot rather than the running database.

Exam Tips

Remember for the exam

  • To extract data without loading the primary, read from a read replica.
  • When many Lambda functions connect to a database, use RDS Proxy.
  • For a bulk analytics copy that does not affect the database, export a snapshot to S3.
  • For an analytics copy in Redshift with no pipeline, use a zero-ETL integration.
  • To run SQL on Aurora from Lambda without connections, use the RDS Data API.