Lesson 1 of 5 ML Data Sources, Storage and Formats

Extracting Training Data from AWS Data Sources

This lesson explains how to extract training data from object stores, file systems, relational and NoSQL databases and search engines without harming the production systems that depend on them.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain why Amazon S3 is the central store for ML data.
  • Choose between EBS, EFS and FSx for Lustre for training data.
  • Extract data from databases and search engines without affecting production.

Amazon S3 as the central store

Amazon Simple Storage Service (Amazon S3) is the default home of ML data on AWS. SageMaker AI training and processing jobs read input channels from S3 and write model artefacts back to it; AWS Glue, Amazon EMR and Amazon Athena query it; Amazon Bedrock reads fine-tuning data, batch inference input and knowledge base documents from it. For this reason, most extraction work consists of copying or exporting data from other sources into S3 in a format suited to training.

File systems: EBS, EFS and FSx for Lustre

An Amazon Elastic Block Store (Amazon EBS) volume is block storage attached to a single EC2 instance. Data on an EBS volume is therefore not directly available to a SageMaker AI training job; the usual approach is to copy it to S3 or to an EFS file system. Amazon Elastic File System (Amazon EFS) is a shared NFS file system that many instances can mount at the same time. SageMaker AI training jobs can use an EFS file system as an input channel, which avoids copying data when it already lives on EFS, for example because notebooks write to it.

Amazon FSx for Lustre is a high-performance parallel file system. It can be linked to an S3 bucket so that objects appear as files and are loaded lazily, and it delivers very high throughput to distributed training. It is the usual answer when many GPU instances must read the same large dataset quickly. Training jobs that use EFS or FSx for Lustre must run in a VPC that can reach the file system.

Match the pairs

Where training data can live

Exam skills 1.1.1

Match each storage service with how a SageMaker AI training job reaches its data.

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

Databases and search engines

Relational data in Amazon RDS or Amazon Aurora can be extracted in several ways. AWS Glue jobs read tables over JDBC connections and write Parquet to S3; Athena federated queries read them in place; an RDS snapshot export writes a snapshot to S3 as Apache Parquet without any load on the running database; and AWS DMS can replicate ongoing changes. Reading large tables directly from the primary database during business hours is the option to avoid.

Amazon DynamoDB tables are extracted with export to S3, which uses point-in-time recovery data and consumes no read capacity, so production traffic is unaffected. Incremental exports capture only changes in a time window. Amazon OpenSearch Service data is read with its search and scroll APIs or through a Glue connector, which is useful when logs or documents indexed for search must also become training data.

The following table summarises the recommended extraction path for each source.

SourceRecommended extractionAvoid
Amazon S3Read directly as a training channelCopying to EBS first
Amazon EBSCopy to S3 or EFSExpecting training jobs to mount it
Amazon EFSMount as a training input channel (VPC)Unnecessary copies
Amazon RDS / AuroraSnapshot export to S3 (Parquet), Glue JDBC, DMSHeavy queries on the primary
Amazon DynamoDBExport to S3 (full or incremental)Scans that consume read capacity
Amazon OpenSearch ServiceSearch/scroll APIs or Glue connectorAd hoc scripts without paging

The following diagram shows how a churn dataset is built from Aurora, DynamoDB and OpenSearch Service without reading from the live databases.

Extracting the churn dataset without slowing production. The Aurora snapshot is exported to S3 as Parquet, the DynamoDB table is exported in full once and incrementally each day using no read capacity, and a Glue job with the OpenSearch connector reads ticket counts. A Glue ETL job joins the three on customer ID into the training table.
None of the extraction paths reads from the live databases.
Scenario questions

Get data out of the database

Exam skills 1.1.1

Choose how to extract training data from an operational database without harming it.

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

Building a churn dataset

A subscription business wants to train a churn model. Customer profiles are in Aurora MySQL, usage events are in a 4 TB DynamoDB table and support tickets are indexed in OpenSearch Service. The production systems must not slow down.

  • Aurora: export the latest snapshot to S3 as Parquet, which reads nothing from the live cluster.
  • DynamoDB: run a full export to S3 once, then daily incremental exports, consuming no read capacity.
  • OpenSearch: a Glue job with the OpenSearch connector reads ticket counts per customer.
  • A Glue ETL job joins the three datasets on customer ID and writes the training table to S3 as Parquet.

A design that ran nightly SELECT statements against Aurora and full scans of DynamoDB would also produce the data, but it would compete with customer traffic, which the scenario rules out.

Check yourself

How can a DynamoDB table be copied to S3 for training without consuming read capacity?

Show answer

With DynamoDB export to S3, which reads from point-in-time recovery data rather than the table.

Exam Tips

Remember for the exam

  • SageMaker AI training reads from S3, EFS or FSx for Lustre; EBS data must be copied first.
  • DynamoDB export to S3 consumes no read capacity.
  • RDS snapshot export writes Parquet to S3 without loading the database.
  • Many GPU instances reading a large dataset fast: FSx for Lustre linked to S3.
  • Training jobs using EFS or FSx need VPC configuration.