Lesson 11 of 13 Amazon Redshift

Loading Streams Directly into Redshift

This lesson explains how Redshift streaming ingestion reads Kinesis Data Streams and Amazon MSK directly into the warehouse with latency of seconds and no staging in S3, as an alternative to hourly batch COPY jobs.

Learning outcomes

After completing this lesson, you will be able to:

  • Compare Redshift loading methods by latency.
  • Set up streaming ingestion with an external schema and materialised view.
  • Keep refreshes running within the stream's retention.

Loading methods by latency

Redshift can receive data in five ways, ranging from daily batches to seconds. COPY from S3 is the standard bulk load. It loads in parallel across the cluster's slices, so it is fastest with many evenly sized, compressed files rather than one large one. Auto-copy, defined as a COPY JOB, watches an S3 prefix and loads new files automatically within minutes of their arrival.

Streaming ingestion reads a Kinesis stream or MSK topic into a materialised view that refreshes automatically, with latency of seconds. Zero-ETL integrations replicate operational databases continuously, within seconds to minutes. Redshift Spectrum and data lake queries skip loading altogether and query the data in S3 where it is. The following table summarises the methods.

MethodLatencyUse
COPY from S3BatchBulk loads; parallel across slices; best with many evenly sized compressed files
Auto-copy (COPY JOB)MinutesAutomatically loads new files as they land in an S3 prefix
Streaming ingestionSecondsMaterialized view over a Kinesis stream or MSK topic, refreshed automatically
Zero-ETL integrationSeconds to minutesContinuous replication from operational databases
Spectrum / data lake queriesNone (query in place)Query S3 data without loading it

The following diagram orders the loading methods by latency.

Redshift loading methods ordered by latency. COPY from S3 loads batches; auto-copy loads new files within minutes; zero-ETL integrations replicate operational databases within seconds to minutes; streaming ingestion reads a stream into a materialised view within seconds; and Spectrum queries data in S3 without loading it.
Bar lengths show order, not exact times.
Put in order

Loading methods by latency

Exam skills 2.3.1 · 1.1.1

Arrange the Redshift loading methods from highest to lowest latency.

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

Setting up streaming ingestion

Create an external schema that maps to Kinesis or MSK, then a materialised view over the stream. Redshift reads directly from the stream into the view; with AUTO REFRESH YES it keeps up continuously. The payload usually arrives as JSON and is parsed into the SUPER type with JSON_PARSE, as the following statements show.

CREATE EXTERNAL SCHEMA clicks_src FROM KINESIS IAM_ROLE default;

CREATE MATERIALIZED VIEW clicks AUTO REFRESH YES AS
SELECT approximate_arrival_timestamp,
       JSON_PARSE(kinesis_data) AS payload
FROM clicks_src."clickstream";

Design points

Streaming ingestion depends on the stream holding records until Redshift reads them. If refreshes stop, for example because the warehouse is paused or an error blocks the view, records that pass the stream's retention period before refreshes resume are lost. The stream's retention should therefore exceed the longest interruption that could occur.

The raw materialised view usually holds the stream's records with little processing. Further materialised views or scheduled queries parse and aggregate it, for example into per-minute summaries for dashboards. Finally, the stream itself must be sized for the write volume, with enough Kinesis shards, on-demand mode or MSK capacity, because Redshift reads at whatever pace the stream supports.

True or false

Streaming ingestion design

Exam skills 1.1.1 · 1.1.11

Decide whether each statement about streaming ingestion is true.

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

Operations staff need a Redshift dashboard of orders in the last 15 minutes. Orders are already published to a Kinesis data stream, and today Firehose delivers them to Redshift with several minutes of buffering.

Redshift streaming ingestion reads the stream directly into an auto-refreshing materialised view, with latency of seconds and no S3 staging. Firehose can remain in place for delivering the same stream to the lake.

Check yourself

Where does Redshift streaming ingestion put data from Kinesis or MSK?

Show answer

Into materialised views that refresh automatically.

Exam Tips

Remember for the exam

  • Streaming ingestion reads Kinesis or MSK into auto-refreshing materialised views.
  • COPY from S3 for bulk loads; auto-copy loads new files automatically.
  • Use SUPER and JSON_PARSE for semi-structured payloads.
  • Streaming ingestion needs no staging in S3.
  • Keep stream retention long enough to cover interruptions.