Amazon Redshift

Petabyte-scale columnar OLAP warehouse, forked from PostgreSQL. A leader node plans queries, compute nodes execute slices in parallel (MPP). Best for BI / analytics SQL over TB–PB of structured data with predictable joins.

Warehouse cột OLAP quy mô petabyte, fork từ PostgreSQL. Leader node lên kế hoạch, compute node chạy slice song song (MPP). Hợp với SQL BI/analytics trên TB–PB data structured, join đoán được.

Reach for itNên dùng

  • BI dashboards / ad-hoc analytics with predictable JOINs across GB → PB of structured dataDashboard BI / analytics ad-hoc với JOIN đoán được trên GB → PB data structured
  • You want SQL-only workflow, not SparkMuốn quy trình toàn SQL, không dùng Spark
  • Concurrent users need sub-second-to-seconds latency, not minutesNhiều user cần latency dưới giây tới vài giây, không phải phút
  • Cross-team data sharing without copy → Redshift Data SharingChia sẻ data cross-team không copy → Redshift Data Sharing

Not the right toolKhông hợp

  • OLTP / high-write single-row workloads → Aurora / RDSOLTP / write nhiều dòng đơn → Aurora / RDS
  • Ad-hoc SQL on S3 with no warehouse to manage → AthenaSQL ad-hoc trên S3 không muốn quản warehouse → Athena
  • Semi-structured, wildly variable schemas → DynamoDB or query with AthenaData semi-structured schema thay đổi loạn → DynamoDB hoặc dùng Athena
  • Real-time single-key lookups → not columnar's gameLookup single-key real-time → không phải sân của columnar

1 · Overview1 · Tổng quan

  • Redshift is based on PostgreSQL, but it's not used for OLTP. It's OLAP — online analytical processing (analytics and data warehousing).Redshift dựa trên PostgreSQL nhưng không dùng cho OLTP. Nó là OLAP — analytical processing (analytics và data warehousing).
  • 10× better performance than other data warehouses; scales to PB of data.Hiệu năng tốt hơn 10 lần so với data warehouse khác; scale tới PB.
  • Columnar storage (not row-based) — queries read only the columns they touch, blocks with values outside predicate ranges are skipped via zone maps.Storage dạng cột (không phải theo row) — query chỉ đọc cột đụng đến, block ngoài range predicate được bỏ qua nhờ zone map.
  • Massively Parallel Query Execution (MPP) — every compute node runs a slice of every query in parallel.Massively Parallel Query Execution (MPP) — mỗi compute node chạy 1 slice của mỗi query song song.
  • Two modes: Provisioned cluster or Serverless workgroup.Hai mode: Provisioned cluster hoặc Serverless workgroup.
  • SQL interface for queries; BI tools like QuickSight and Tableau integrate directly.Giao diện SQL để query; công cụ BI như QuickSight, Tableau tích hợp trực tiếp.

2 · Architecture — nodes, storage, load sources2 · Kiến trúc — node, storage, nguồn load

Redshift architecture — sources feed a leader + parallel compute nodes; BI tools consume via JDBC/ODBC Load sources (COPY) S3 Kinesis Firehose DynamoDB DMS Redshift cluster Leader node plan · aggregate results Compute slices Compute slices Compute slices … up to 100+ nodes · 16 TB / node columnar · MPP · Redshift Managed Storage (S3-backed) Enhanced VPC Routing → COPY/UNLOAD stay inside VPC SQL / BI (JDBC · ODBC) QuickSight Tableau Any SQL client

Load sources feed a leader node that plans; compute nodes run slices in parallel; BI clients hit the leader over JDBC/ODBC.

Nguồn load đổ vào leader node để plan; compute node chạy slice song song; client BI kết nối leader qua JDBC/ODBC.

  • Load sources: S3, Kinesis Firehose, DynamoDB, DMS (plus EMR / SSH remote). COPY is the fast, parallelised path; use an IAM role via iam_role, never inline creds.Nguồn load: S3, Kinesis Firehose, DynamoDB, DMS (thêm EMR / SSH remote). COPY là đường nhanh, song song; dùng IAM role qua iam_role, đừng inline credential.
  • Sizing envelope: up to 100+ nodes, up to 16 TB per node.Kích thước: tới 100+ node, tới 16 TB/node.
  • Multi-AZ scope caveat: single-cluster active/active Multi-AZ is only available on certain RA3 configurations (and on Serverless workgroups). Classic HA otherwise = automated snapshots + cross-AZ restore.Lưu ý phạm vi Multi-AZ: Multi-AZ active/active trong 1 cluster chỉ có trên một số cấu hình RA3 (và Serverless workgroup). HA cổ điển còn lại = snapshot tự động + restore cross-AZ.
  • Leader node: query planning, result aggregation. There is exactly one, and no cost for it.Leader node: plan query, gộp kết quả. Chỉ có 1, không tính phí riêng.
  • Compute nodes: perform the queries against local slices, send partial results to the leader for merge.Compute node: chạy query trên slice local, gửi kết quả tạm về leader để gộp.
  • Backup & restore, security (VPC / IAM / KMS), monitoring are all built in.Backup & restore, security (VPC / IAM / KMS), monitoring đều có sẵn.
  • Enhanced VPC Routing: forces COPY / UNLOAD traffic through your VPC (endpoints, VPN, Direct Connect) instead of the public internet — required for many compliance regimes.Enhanced VPC Routing: ép COPY / UNLOAD đi qua VPC của bạn (endpoint, VPN, Direct Connect) thay vì internet công cộng — nhiều chuẩn compliance bắt.
  • When Redshift is worth it: sustained usage. If your queries are sporadic and don't justify running a cluster, use Athena instead.Khi nào Redshift đáng dùng: usage đều đặn. Query rời rạc, không xứng chạy cluster thì dùng Athena.

Provisioned (RA3) vs ServerlessProvisioned (RA3) vs Serverless

RA3 Provisioned Serverless
You pickBạn chọn Node type (ra3.large/xlplus/4xl/16xl), node countNode type (ra3.large/xlplus/4xl/16xl), số node Base RPU (8+) + max RPU cap; AWS auto-scalesBase RPU (8+) + cap RPU max; AWS auto-scale
StorageStorage Redshift Managed Storage (RMS) — S3-backed, decoupled from computeRedshift Managed Storage (RMS) — trên S3, tách khỏi compute RMS (same)RMS (như trên)
Billing when idleTính phí khi idle Full node-hour rate (pause to stop compute charges)Full node-giờ (pause để dừng phí compute) Storage only; RPU only while queries runChỉ storage; RPU chỉ tính khi query chạy
Best forHợp với Steady workloads where you can size & commit (Reserved for -50 %+)Workload đều đặn, có thể size & commit (Reserved -50 %+) Spiky, unpredictable, dev/test, first projectSpiky, khó đoán, dev/test, project đầu
Snapshot / restoreSnapshot / restore Manual + auto snapshots, cross-region copyManual + auto snapshot, copy cross-region Recovery points; restore into serverless workgroup or provisionedRecovery point; restore về serverless workgroup hoặc provisioned

3 · Snapshots & DR3 · Snapshot & DR

  • Point-in-time backups of the cluster, stored internally in S3.Backup point-in-time của cluster, lưu nội bộ trong S3.
  • Incremental — only what has changed since the previous snapshot is saved.Incremental — chỉ lưu phần thay đổi so với snapshot trước.
  • You restore into a new cluster (Redshift does not do in-place restore).Restore vào cluster mới (Redshift không restore in-place).
  • Automated: fires every 8 hours OR every 5 GB of change, or on your schedule. Set retention (default 1 day, up to 35).Auto: chạy mỗi 8 giờ HOẶC mỗi 5 GB thay đổi, hoặc theo lịch bạn đặt. Set retention (mặc định 1 ngày, tối đa 35).
  • Manual: retained until you delete it — good for compliance holds.Manual: giữ tới khi bạn xoá — hợp cho compliance hold.
  • Redshift can be configured to automatically copy snapshots (automated or manual) to another AWS Region — the standard DR primitive.Redshift có thể tự động copy snapshot (auto hoặc manual) sang region khác — DR primitive chuẩn.

4 · Cross-region snapshot copy for a KMS-encrypted Redshift4 · Cross-region snapshot copy khi Redshift có KMS

Cross-region snapshot copy — snapshot copy grant lets Redshift re-encrypt with the destination KMS key Source region · us-east-1 Redshift cluster Snapshot encrypted 🔑 KMS Key A Destination region · eu-west-2 Redshift cluster Snapshot re-encrypted 🔑 KMS Key B copy to eu-west-2 snapshot copy grant

The snapshot copy grant (dashed accent) is what lets Redshift use Key B in the destination region to re-encrypt the incoming snapshot. Without it, the copy fails.

Snapshot copy grant (nét đứt màu accent) cho Redshift dùng Key B ở region đích để re-encrypt snapshot. Thiếu grant thì copy fail.

Encrypted cross-region copy is the classic "grant" question. The source cluster uses KMS Key A in the source Region; the destination uses KMS Key B. Because the two keys live in different Regions, Redshift can't re-encrypt on arrival unless you explicitly say so — that's what the snapshot copy grant is for. Copy cross-region khi encrypted là câu hỏi "grant" kinh điển. Cluster nguồn dùng KMS Key A ở region nguồn; đích dùng KMS Key B. Vì hai key ở hai region khác nhau, Redshift không tự re-encrypt được khi tới nếu bạn không cấp phép rõ ràng — đó là snapshot copy grant.

  • Create the snapshot copy grant in the destination Region, pointing at the destination KMS key (Key B).Tạo snapshot copy grant ở region đích, trỏ vào KMS key đích (Key B).
  • Enable snapshot copy on the source cluster and reference that grant — Redshift can now perform encryption operations in the destination Region.Bật snapshot copy trên cluster nguồn và trỏ grant đó — Redshift được phép làm encryption operation ở region đích.
  • Without the grant, the copy fails — the copy job can't unwrap-and-rewrap the data key across Regions.Không có grant thì copy fail — job copy không unwrap/rewrap được data key qua region.

5 · Redshift Spectrum5 · Redshift Spectrum

Redshift Spectrum — SQL client → Redshift cluster leader → thousands of Spectrum nodes → S3 SQL client JDBC · ODBC Redshift cluster (must be running) Leader plans query Compute Compute Compute merge partial results from Spectrum Redshift Spectrum (AWS-managed fleet · thousands of nodes) S1 S2 S3 … Sn S3 (data lake) via Glue Catalog external table SQL dispatch scan scan objects

Client → cluster leader plans → dispatches to the Spectrum fleet, which scans S3 in parallel → partial results stream back to the cluster's compute nodes for merge.

Client → leader cluster plan → dispatch cho fleet Spectrum, scan S3 song song → kết quả tạm stream về compute node để merge.

  • Query data already in S3 without loading it into the cluster — the "lake extension" for Redshift SQL.Query data đã ở S3 mà không load vào cluster — "phần mở rộng lake" cho SQL Redshift.
  • Must have a running Redshift cluster to submit Spectrum queries — Spectrum isn't standalone; it borrows the leader node for planning.Phải có cluster Redshift đang chạy để submit query Spectrum — Spectrum không đứng riêng; mượn leader node để plan.
  • The query is dispatched to thousands of Spectrum compute nodes (AWS-owned fleet) that scan the S3 objects; results stream back to your cluster's compute nodes for final merge.Query gửi tới hàng nghìn Spectrum compute node (fleet AWS quản) scan object S3; kết quả stream về compute node cluster để merge cuối.
  • Wired via Glue Data Catalog: CREATE EXTERNAL SCHEMA … FROM DATA CATALOG, then query schema.table. Billed per TB scanned (like Athena) on top of your existing cluster cost.Wire qua Glue Data Catalog: CREATE EXTERNAL SCHEMA … FROM DATA CATALOG, rồi query schema.table. Tính phí TB scan (như Athena) cộng vào phí cluster.

6 · Workload Management (WLM)6 · Workload Management (WLM)

WLM — admin/user queries are routed to Superuser, Short-running, or Long-running queues before hitting the cluster Admin system queries User short-running queries long-running queries Superuser queue reserved · admin only Short-running queue many slots · low memory Long-running queue few slots · high memory Redshift cluster Automatic WLM: queues + slots managed by Redshift · Manual WLM: you set memory % and concurrency per queue

Each query is routed to a queue with its own memory + concurrency budget before it reaches the cluster — the point is to stop short queries getting stuck behind long ones.

Mỗi query được route vào 1 queue có ngân sách memory + concurrency riêng trước khi tới cluster — mục tiêu là không để query ngắn kẹt sau query dài.

  • Flexibly manage query priorities within a workload — the classic problem is short, fast queries getting stuck behind a long-running one.Quản priority query linh hoạt — vấn đề kinh điển là query ngắn/nhanh bị kẹt sau 1 query dài.
  • Define multiple query queues (Superuser queue + user-defined queues); route queries to the right queue at runtime.Định nghĩa nhiều query queue (Superuser queue + queue user tự định); route query tới queue đúng lúc chạy.
  • Automatic WLM — queues and resources managed by Redshift (recommended default).Automatic WLM — queue và resource do Redshift tự quản (mặc định nên dùng).
  • Manual WLM — queues and resources managed by you (memory %, concurrency slots per queue). Only worth it when you know the workload cold.Manual WLM — bạn tự quản queue và resource (% memory, slot concurrency mỗi queue). Chỉ đáng khi hiểu rõ workload.

7 · Concurrency Scaling7 · Concurrency Scaling

Concurrency Scaling — when the main cluster's queues fill, Redshift routes overflow queries to a transient concurrency-scaling cluster Users · concurrent queries Main Redshift cluster node node node always-on · billed by node-hour Concurrency-Scaling cluster node node … transient · billed per second WLM decides which queue's queries spill onto the concurrency-scaling cluster · free credits accrue daily

Main cluster runs the steady load; overflow is routed to transient concurrency-scaling clusters that AWS spins up on demand and bills per second.

Cluster chính chạy tải đều; phần tràn được route sang cluster concurrency-scaling tạm mà AWS tự bật và tính theo giây.

  • Provides consistently fast performance with virtually unlimited concurrent users — Redshift auto-adds extra cluster capacity (a Concurrency-Scaling Cluster) when the main cluster's queues fill up.Giữ hiệu năng ổn định với gần như unlimited concurrent user — Redshift auto thêm capacity (một Concurrency-Scaling Cluster) khi queue của cluster chính đầy.
  • WLM decides which queries get routed to the concurrency-scaling cluster (via the queue setting).WLM quyết query nào chạy trên concurrency-scaling cluster (qua setting queue).
  • Charged per second. Free credits accrue daily (~1 h of concurrency scaling per 24 h of main-cluster runtime) — many workloads pay nothing extra.Tính phí theo giây. Có credit miễn phí mỗi ngày (~1 h concurrency scaling / 24 h main cluster) — nhiều workload không tốn thêm gì.

8 · Physical design8 · Thiết kế vật lý

The single biggest lever for real-world Redshift performance. Bad distribution or sort keys make every query broadcast. Núm lớn nhất quyết định performance Redshift thực tế. Distribution/sort key sai làm query nào cũng broadcast.

  • Distribution key: hash a column across slices. Great when two big tables always join on the same column (co-located join = no network shuffle). Bad if the key is skewed — hot slices.Distribution key: hash 1 cột qua slice. Rất tốt khi 2 bảng lớn luôn join trên cùng cột (join co-located, không shuffle mạng). Xấu khi key lệch — hot slice.
  • DISTSTYLE ALL replicates the full table on every node — perfect for small dim tables. DISTSTYLE EVEN is round-robin (safe default). DISTSTYLE AUTO lets Redshift start ALL and switch to KEY/EVEN as the table grows.DISTSTYLE ALL replicate cả bảng lên mọi node — hoàn hảo cho dim table nhỏ. DISTSTYLE EVEN round-robin (mặc định an toàn). DISTSTYLE AUTO cho Redshift bắt đầu ALL rồi đổi sang KEY/EVEN khi bảng lớn.
  • Sort key orders rows on disk so predicate filters (WHERE date > …) skip whole blocks via zone maps. Compound (default) speeds up leading-column filters; interleaved weighs all columns equally (rarely worth the vacuum cost).Sort key sắp xếp row trên disk để filter (WHERE date > …) skip block qua zone map. Compound (mặc định) tăng tốc filter cột đầu; interleaved cân đều các cột (hiếm khi bù nổi chi phí vacuum).
  • VACUUM reclaims space and resorts after big deletes/updates; ANALYZE refreshes stats. Auto-vacuum + auto-analyze are on by default; check the console for jobs that fell behind.VACUUM lấy lại space và sort lại sau delete/update lớn; ANALYZE làm mới stats. Auto-vacuum + auto-analyze bật mặc định; theo dõi console cho job tụt lại.

9 · Modern integrations9 · Tích hợp hiện đại

Newer features worth knowing — they replace hand-rolled ETL for common cases. Tính năng mới hơn, nên biết — thay cho ETL tự viết ở các case phổ biến.

  • Zero-ETL integration: near-real-time replication from Aurora / RDS / DynamoDB into a Redshift database — replaces the DMS + Glue pipeline for the common case.Zero-ETL integration: replicate gần real-time từ Aurora / RDS / DynamoDB vào Redshift — thay pipeline DMS + Glue cho case phổ biến.
  • Streaming ingestion: materialised view directly on top of a Kinesis stream / MSK topic — data lands with seconds of lag, no Firehose needed.Streaming ingestion: materialized view trực tiếp trên Kinesis stream / MSK topic — data về trong vài giây, không cần Firehose.
  • Federated Query: query live Aurora / RDS PostgreSQL / MySQL from Redshift without ETL — good for occasional joins to operational data.Federated Query: query live Aurora / RDS PostgreSQL / MySQL từ Redshift không cần ETL — hợp join thi thoảng với data operational.
  • Data Sharing: producer cluster exposes live tables to consumer clusters (or other accounts) with no copy. Read-only on the consumer side.Data Sharing: cluster producer share bảng live cho cluster consumer (hoặc account khác) không copy. Chỉ đọc phía consumer.
  • Redshift Data API: lets Lambda / Step Functions submit SQL asynchronously — no persistent JDBC connection needed.Redshift Data API: cho Lambda / Step Functions submit SQL async — không cần connection JDBC bền.
  • Materialised views can be auto-refreshed and auto-rewritten — the query planner substitutes the MV for matching SELECTs behind the scenes.Materialized view có thể auto-refresh và auto-rewrite — query planner tự thay MV vào SELECT khớp.