Skip to Content

Amazon Redshift

Redshift as the AWS data warehouse, its leader and compute nodes, provisioned and serverless modes, Multi-AZ, snapshots and cross-Region DR, loading data, zero-ETL, and Redshift Spectrum.

What it is

Amazon Redshift is the AWS data warehouse.

  • It's based on PostgreSQL, but it's not for OLTP (transactions). It's OLAP: online analytical processing, for analytics and data warehousing.
  • Columnar storage (instead of row-based) and a massively parallel query engine: scans and aggregations over billions of rows are fast. It scales to petabytes.
  • Two modes: provisioned cluster or Redshift Serverless.
  • A SQL interface (JDBC/ODBC) for queries; BI tools such as QuickSight or Tableau connect to it.
  • vs Athena: Redshift is faster for heavy, frequent queries, joins and aggregations, because data is loaded and organised (sort keys, distribution) inside the warehouse. Athena is better for occasional, ad-hoc queries on files in S3.

Cluster and Serverless

Redshift cluster and Spectrum: a SQL client connects over JDBC or ODBC to the leader node, which plans the query and aggregates results from compute nodes running in parallel; with Spectrum, the cluster hands the part of the query that reads S3 to thousands of Spectrum nodes, so data in S3 is queried without loading it Redshift cluster and Spectrum: a SQL client connects over JDBC or ODBC to the leader node, which plans the query and aggregates results from compute nodes running in parallel; with Spectrum, the cluster hands the part of the query that reads S3 to thousands of Spectrum nodes, so data in S3 is queried without loading it

A leader plans, compute nodes work in parallel.
  • Leader node: receives the query, plans it, and aggregates the results. Clients only talk to the leader.
  • Compute nodes: run the query on their part of the data and send results to the leader.
  • Provisioned mode: choose node types and count in advance; reserve nodes for cost savings.
  • Redshift Serverless: capacity is provisioned and scaled automatically, and billing applies only when the warehouse is in use. Good for unpredictable or occasional workloads.

High availability, snapshots and DR

Redshift snapshots for disaster recovery: an incremental snapshot of the original cluster in us-east-1 is stored in S3 and copied, automatically or manually, to eu-west-1, where it is restored into a new cluster Redshift snapshots for disaster recovery: an incremental snapshot of the original cluster in us-east-1 is stored in S3 and copied, automatically or manually, to eu-west-1, where it is restored into a new cluster

Copy snapshots to another Region for disaster recovery.
  • Multi-AZ: available for provisioned RA3 (and the newer RG) clusters. Compute runs in two AZs behind one endpoint, so the warehouse survives an AZ failure.
  • Snapshots are point-in-time backups of a cluster, stored internally in S3.
    • Incremental: only what changed is saved.
    • Restore a snapshot into a new cluster.
  • Automated snapshots: about every 8 hours or every 5 GB per node of changes (whichever comes first), or on a schedule. Retention 1 to 35 days (default 1 day).
  • Manual snapshots: kept until they are deleted (or for a set retention period).
  • Cross-Region copy: configure Redshift to automatically copy snapshots (automated or manual) of a cluster to another Region, for disaster recovery.

Loading data into Redshift

Loading data into Redshift: Firehose buffers records into S3 and runs COPY; the COPY command loads files from S3 using an IAM role, over the internet or through the customer's VPC with enhanced VPC routing; an EC2 application using JDBC should write in large batches rather than single rows Loading data into Redshift: Firehose buffers records into S3 and runs COPY; the COPY command loads files from S3 using an IAM role, over the internet or through the customer's VPC with enhanced VPC routing; an EC2 application using JDBC should write in large batches rather than single rows

Large batch inserts are much better than single rows.

Large inserts are MUCH better than many small ones. Three common ways:

  • Amazon Data Firehose: buffers streaming records into S3, then issues a COPY into Redshift.

  • S3 with the COPY command: load files from S3 in parallel, using an IAM role attached to the cluster:

    copy customer
    from 's3://mybucket/mydata'
    iam_role 'arn:aws:iam::123456789012:role/MyRedshiftRole';

    The traffic goes over the internet by default. With enhanced VPC routing, all COPY and UNLOAD traffic goes through the customer's VPC, so VPC endpoints, security groups and flow logs apply.

  • EC2 application with the JDBC driver: write data in batches.

Not in the course slides

Zero-ETL integrations replicate data from Aurora MySQL and PostgreSQL, RDS for MySQL, PostgreSQL and Oracle, DynamoDB and some SaaS apps into Redshift automatically, within seconds, with no pipeline to build. Look for it in questions about "near real-time analytics on transactional data with the least effort".

Redshift Spectrum

The diagram at the top of this page shows Redshift Spectrum below the cluster.

  • Query data that's already in S3 without loading it into Redshift tables.
  • A Redshift cluster is required (or Serverless workgroup), available to start the query.
  • The query is then submitted to thousands of Redshift Spectrum nodes, which read S3 in parallel.
  • Queries can join S3 data (for example years of history) with tables in the warehouse (recent data). Several clusters can query the same S3 data.
  • Spectrum reads table definitions from the Glue Data Catalog (external tables).

Real-world examples

  • A retailer loads every night's sales into a Redshift cluster with COPY from S3, and analysts run reports in QuickSight every morning.
  • A finance team keeps two years of data in Redshift and ten years of history in S3, and joins them with Spectrum without loading the old data.
  • A bank copies Redshift snapshots automatically to a second Region so it can restore the warehouse there after a Regional outage.

Exam tips

  • "Data warehouse", "OLAP", "BI on petabytes", "complex joins and aggregations" → Redshift.
  • "Query S3 data from Redshift without loading it" → Redshift Spectrum.
  • "Disaster recovery for Redshift in another Region" → automated cross-Region snapshot copy.
  • "Load data into Redshift efficiently" → COPY from S3 (large batches), or Firehose for streams.
  • "COPY traffic must not leave the VPC" → enhanced VPC routing.
  • "Unpredictable, occasional warehouse workloads" → Redshift Serverless.

Common traps

  • "Redshift for an OLTP application." It's an analytics warehouse; use RDS or Aurora.
  • "Insert rows one at a time from an app." Very slow; batch them or use COPY.
  • "Spectrum works without a cluster." It needs a Redshift cluster or Serverless; for no warehouse at all, use Athena.
  • "Restore a snapshot into the existing cluster." A restore creates a new cluster.

Check yourself

A Redshift cluster costs from about $0.25 an hour, and Serverless bills at least 60 seconds of capacity each time it runs, so instead:

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt