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
- 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
- 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
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
COPYcommand: 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
COPYandUNLOADtraffic 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
COPYfrom 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" →
COPYfrom 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:
Enable cross-Region snapshot copy for the cluster, so automated (and manual) snapshots are copied to the DR Region, and restore a new cluster from them when needed.
Use Redshift Spectrum: define external tables over the S3 data in the Glue Data Catalog and join them with the Redshift tables in one query.
AWS documentation
Amazon Athena
Athena as serverless SQL on data in S3, its pricing, how columnar formats, compression and partitions cut cost and time, and federated queries across other data sources.
Amazon OpenSearch Service
OpenSearch Service for search and log analytics, managed domains and OpenSearch Serverless, and the common patterns for feeding it from DynamoDB, CloudWatch Logs and Kinesis.