Redshift
Amazon Redshift
🎯 Sebab Apa Wujud
Redshift wujud sebab database transaksi (RDS) lemah bila kau nak aggregate berbilion baris untuk laporan/BI — query SUM/GROUP BY atas data besar jadi sangat lambat sebab data simpan ikut row. Redshift simpan data COLUMNAR + compress + agih kerja ke banyak node (MPP), jadi analytics atas data warehouse berskala petabyte jadi laju — tanpa membebankan database OLTP production.
Apa Dia
Petabyte-scale data warehouse untuk OLAP (analytics), BUKAN OLTP (transaksi → guna RDS). Simpan data secara COLUMNAR + compress → query aggregate (SUM, GROUP BY) atas berbilion baris jadi laju. Massively Parallel Processing (MPP): leader node agih query ke banyak compute node. Spectrum boleh query S3 terus tanpa load.
Contoh Guna
BI/reporting atas data berkumpul (sales, finance), join besar merentas berjuta baris, dashboard berulang yang sama tiap hari
Redshift Anatomy (MPP)
Leader Node → terima query, buat plan, agih ke compute node, kumpul hasil
Compute Nodes → simpan data + jalankan query selari (MPP)
RA3 + Managed Storage → compute & storage berasingan, bayar ikut guna; scale tanpa pindah data
Redshift Spectrum → query data dalam S3 TERUS tanpa load ke cluster
Concurrency Scaling → auto-tambah cluster sementara bila ramai user query serentak
AQUA (Advanced Query Accelerator) → lapisan cache + compute DEKAT storage; tolak (push-down) filter/aggregate dekat data → kurang data lalu network + kurang beban CPU compute node. Auto-managed (RA3, no extra charge)
Redshift MPP + Spectrum flow
SQL Client / BI
JDBC/ODBC
Leader Node
plan + agih
Compute 1
Compute 2
Compute 3
Managed Storage
columnar
Spectrum → S3
query data lake
Leader node pecahkan query, compute nodes proses selari (MPP) atas data columnar. Spectrum extend query terus ke S3 tanpa load. Inilah sebab Redshift laju untuk aggregate besar — tapi LEMAH untuk single-row insert/update (itu kerja OLTP → RDS).
Anatomy komponen Redshift (cluster → slices → storage)
Hierarki: satu Cluster = 1 Leader Node (otak: plan & agih query) + banyak Compute Node (pekerja, ada CPU/RAM/disk sendiri). Tiap compute node dipecah jadi Slices — slice inilah unit MPP yang proses data selari. RA3 simpan data dalam Managed Storage (RMS) columnar atas S3, jadi compute & storage boleh scale berasingan. Spectrum extend query terus ke S3.
Pilih servis query/analytics (decision tree)
OLTP (transaksi) → RDS/Aurora. Analytics berulang/kompleks → Redshift. Ad-hoc SQL atas S3 tanpa setup → Athena. Custom Spark/Hadoop → EMR. Ni trap paling kerap di exam: jangan pilih Redshift untuk "ad-hoc, jarang query" (itu Athena) atau untuk OLTP (itu RDS).
Redshift dah ada, tapi LAMBAT — pilih feature mana? (decision tree)
INGAT exam: baca PUNCA yang soalan sebut. "network bandwidth + CPU limits" → AQUA (BUKAN Spectrum — Spectrum extend ke S3, tak selesai bottleneck dalam cluster, malah boleh tambah trafik). "ramai user serentak" → Concurrency Scaling. "query data lake S3" → Spectrum. AQUA kini auto-managed = pilihan minimum operational overhead.
Redshift — komponen dalaman (anatomy)
| Komponen | Peranan | Nota exam |
|---|---|---|
| Cluster | Keseluruhan: 1 Leader Node + 1 atau lebih Compute Node | Unit yang kau provision (atau guna Serverless) |
| Leader Node | Terima query SQL, buat execution plan, agih kerja ke compute node, kumpul & pulang hasil | TAK dikira caj dalam cluster multi-node; single-node = leader & compute jadi satu |
| Compute Node | Simpan data + jalankan query; ada CPU, memory & disk sendiri | Tambah node = lebih storage + lebih laju (scale horizontal) |
| Node Slices | Tiap compute node dipecah jadi beberapa slice; tiap slice proses sebahagian data SELARI | Inilah unit MPP sebenar — lebih slice = lebih parallelism |
| Managed Storage (RMS) | RA3: data disimpan dalam Redshift Managed Storage atas S3, auto-scale | Asingkan compute & storage → scale satu tanpa tambah satu lagi |
| Columnar + Compression | Simpan data ikut COLUMN (bukan row) + mampat | Sebab aggregate (SUM/GROUP BY) laju; lemah untuk single-row update |
| Zone Maps | Simpan min/max tiap blok data dalam memory → langkau blok tak relevan | Kurangkan jumlah data di-scan = query lagi laju |
| Distribution Style (DISTKEY) | Cara baris diagih antara slices: KEY / EVEN / ALL | KEY co-locate baris untuk join; ALL replicate table kecil ke semua node |
| Sort Key (SORTKEY) | Cara data disusun fizikal atas disk | Range scan & merge join laju bila filter ikut sort key |
| Redshift Spectrum | Query data dalam S3 TERUS guna external table, tanpa load | Warehouse + data lake S3 dalam satu query |
| Concurrency Scaling | Auto-tambah cluster sementara bila ramai query serentak | Spike concurrent users → tak beratur |
Ingat: Aliran: Cluster → Leader Node (otak: plan & agih) → Compute Nodes (pekerja) → Node Slices (unit selari MPP) → Managed Storage (columnar atas S3). DISTKEY & SORTKEY tuning prestasi; Spectrum extend ke S3; Concurrency Scaling handle ramai user serentak.
Redshift vs Athena vs EMR vs RDS
| Aspect | Redshift | Athena | EMR | RDS/Aurora |
|---|---|---|---|---|
| Jenis | Data warehouse (OLAP) | Serverless SQL on S3 | Big-data cluster | Relational (OLTP) |
| Data | Structured, loaded/Spectrum | Data dalam S3 | Apa saja dalam S3/HDFS | Structured transaksi |
| Server | Cluster (atau Serverless) | 🟢 Serverless, no infra | Kau urus cluster | Managed instance |
| Kos model | Per node/jam atau RPU | Per TB di-scan | Per instance (Spot jimat) | Per instance/jam |
| Best bila | Recurring complex analytics, BI | Ad-hoc, jarang, no setup | Custom Spark/Hadoop/ML | App transaksi (CRUD) |
Ingat: Recurring + complex + structured + perlu laju konsisten → Redshift. Sekali-sekala / jarang / tak nak urus apa-apa → Athena. Custom big-data processing → EMR. Transaksi → RDS. Jangan campur OLAP (Redshift) dengan OLTP (RDS).
Redshift — features penting exam
| Feature | Apa dia | Trigger |
|---|---|---|
| RA3 + Managed Storage | Compute & storage berasingan, scale sendiri | "Scale compute tanpa bayar storage lebih" |
| Redshift Spectrum | Query S3 TERUS tanpa load ke cluster | "Query data warehouse + data lake S3 sekali" |
| Redshift Serverless | Auto-scale RPU, no cluster management | "Analytics tapi tak nak urus cluster / beban tak tetap" |
| Concurrency Scaling | Auto-tambah cluster bila ramai query serentak | "Banyak user query serentak, jangan slow / queue" |
| Zero-ETL (Aurora→Redshift) | Data Aurora auto-flow ke Redshift, tak payah pipeline ETL | "Analytics near-real-time tanpa bina ETL" |
| AQUA (Advanced Query Accelerator) | Cache+compute dekat storage; push-down filter/aggregate → kurang data lalu network + beban CPU. Auto-managed, RA3, no extra charge | 🟢 "performance issues due to NETWORK BANDWIDTH + CPU limits" → AQUA |
Ingat: Spectrum = warehouse + S3 dalam satu query. Serverless = tak nak urus cluster. Concurrency Scaling = ramai user serentak. Zero-ETL = buang kerja bina pipeline Aurora→Redshift. AQUA = kurangkan network movement + CPU load (auto, no overhead).
AQUA vs Redshift Spectrum — DUA-DUA "Redshift feature", JANGAN keliru
| Aspect | AQUA | Redshift Spectrum |
|---|---|---|
| Masalah yang diselesai | Cluster slow sebab NETWORK + CPU bottleneck | Nak query data S3 external tanpa load ke cluster |
| Cara kerja | Push compute (filter/aggregate) DEKAT storage → kurang data bergerak | Compute layer asing query data dalam S3 (external table) |
| Kesan pada network | KURANGKAN data lalu network (dalam cluster) | Boleh TAMBAH trafik (tarik data dari S3) |
| Setup / overhead | 🟢 Auto-managed — Redshift decide sendiri, no toggle | Kena define external schema + external table |
| Kos | No extra charge (RA3) | Bayar per data DI-SCAN dalam S3 |
Ingat: Keyword pembeza: "network bandwidth + CPU processing limits" → AQUA. "query data dalam S3 / data lake / external table tanpa load" → Spectrum. Dua-dua bunyi "Redshift + performance", tapi AQUA selesai bottleneck DALAM cluster; Spectrum extend query KELUAR ke S3. AQUA config status kini RETIRED — Redshift auto-tentukan (zero ops overhead).
⚡ Quick Sifir — hafal ni
- ▪Redshift = data warehouse OLAP (columnar + compress + MPP). RDS/Aurora = OLTP.
- ▪Cluster = 1 Leader Node (plan/agih) + banyak Compute Node (proses) → pecah jadi Slices (unit MPP).
- ▪RA3 + Managed Storage = compute & storage berasingan, scale independent.
- ▪Spectrum = query S3 TERUS tanpa load. Athena = serverless ad-hoc (no cluster).
- ▪Concurrency Scaling = auto-tambah cluster bila ramai user serentak.
- ▪Zero-ETL (Aurora→Redshift) = analytics near-real-time tanpa bina pipeline ETL.
- ▪AQUA = push compute dekat storage → kurang NETWORK + CPU bottleneck. Auto-managed, RA3, no extra charge. BUKAN Spectrum (Spectrum = query S3 external).
💡 Exam Scenario
"Dashboard BI berulang atas berbilion baris sales, perlu join kompleks laju & konsisten" → Redshift. "Banyak analyst query serentak waktu puncak, jangan beratur" → Concurrency Scaling. "Nak query data dalam Redshift DAN data lake S3 dalam satu SQL" → Redshift Spectrum. "Beban analytics tak menentu, tak nak urus cluster" → Redshift Serverless. "Redshift slow sebab NETWORK BANDWIDTH + CPU processing limits, minimize overhead/cost" → AQUA (BUKAN Spectrum, BUKAN ElastiCache). Bukan Athena (ad-hoc/jarang), bukan RDS (OLTP).
🪤 Perangkap Soalan
Q: App transaksi e-commerce (banyak insert/update order satu-satu, low latency). Database paling sesuai?
⚠ Umpan: Redshift — sebab dia handle data besar & SQL kompleks, nampak powerful.
✓ Betul: RDS/Aurora — keyword 'transaksi / single-row insert/update / OLTP' = RDS/Aurora. Redshift columnar, teruk untuk write satu-satu baris (itu OLAP, bukan OLTP).
Q: Analyst jarang-jarang nak run SQL ad-hoc atas log dalam S3, tak nak urus apa-apa cluster. Service?
⚠ Umpan: Redshift — sebab dia 'analytics + SQL', nampak macam jawapan analytics default.
✓ Betul: Athena — keyword 'ad-hoc / jarang / no setup / no cluster / data dalam S3' = Athena (serverless). Redshift perlu provision cluster, overkill untuk query jarang-jarang.
Q: Redshift cluster makin slow bila data membesar — punca disebut 'network bandwidth and CPU processing limits'. Nak improve query performance, minimize operational overhead & cost. Pilih?
⚠ Umpan: Redshift Spectrum — sebab data ada dalam warehouse + S3, Spectrum nampak macam jawapan 'Redshift + performance' default. SALAH: Spectrum cuma extend query ke S3 external; ia TAK selesai bottleneck CPU/network DALAM cluster, malah boleh TAMBAH trafik network dari S3.
✓ Betul: AQUA (Advanced Query Accelerator) — push compute dekat storage → kurang data lalu network + kurang beban CPU compute node. Tepat dua-dua keyword 'network bandwidth + CPU'. Auto-managed (Redshift decide sendiri) = zero operational overhead, no extra charge pada RA3.
Q: Nak laju query analytics Redshift, ada yang cadang ElastiCache Memcached untuk cache. Betul tak?
⚠ Umpan: ElastiCache Memcached — sebab 'caching = laju' nampak masuk akal.
✓ Betul: BUKAN — ElastiCache untuk cache OLTP/key-value (depan RDS/DynamoDB), bukan beban analytics columnar Redshift. Untuk percepat Redshift + kurang CPU/network = AQUA. Keyword 'Redshift query performance' ≠ ElastiCache.
🧠 Cara Mudah Ingat
- →Redshift = OLAP/analytics (columnar, aggregate berjuta baris). RDS/Aurora = OLTP (transaksi, single-row read/write). Jangan keliru — soalan "transactional app" JANGAN jawab Redshift.
- →Columnar storage + compression = sebab Redshift laju untuk SUM/AVG/GROUP BY atas data besar, tapi teruk untuk insert/update satu-satu baris.
- →Redshift Spectrum vs Athena: dua-dua query S3. Spectrum = kau dah ada Redshift cluster, nak extend query ke S3. Athena = standalone, no cluster, ad-hoc.
- →RA3 nodes = compute & managed storage berasingan (scale independent). DC2 = compute+storage bercantum (legacy, dataset kecil).
- →Concurrency Scaling: auto add transient cluster untuk handle spike concurrent queries — per-second billing, ada free credits harian.
- →Multi-AZ: Redshift RA3 boleh Multi-AZ untuk HA. Cross-region snapshot untuk DR.
- →Zero-ETL integration: Aurora/RDS → Redshift tanpa bina ETL pipeline sendiri (near-real-time analytics atas data transaksi).
- →AQUA (Advanced Query Accelerator): lapisan cache + hardware-accelerated compute antara compute node RA3 dengan Managed Storage. Push-down filter/aggregate dekat data → kurangkan data yang lalu network + kurangkan beban CPU compute node. Tepat untuk soalan "performance issues due to network bandwidth and CPU processing limits".
- →AQUA vs Spectrum (trap!): AQUA selesaikan bottleneck CPU/network DALAM cluster; Spectrum extend query KELUAR ke S3 (boleh tambah trafik network). Soalan sebut "network bandwidth + CPU limits" → AQUA, bukan Spectrum.
- →AQUA kini AUTO-MANAGED: parameter aqua-configuration-status sudah RETIRED — Redshift sendiri tentukan bila guna AQUA. Available pada RA3, no extra charge. Sebab itu AQUA = pilihan "minimize operational overhead".
- →AQUA ≠ ElastiCache: ElastiCache cache OLTP/key-value (depan RDS/DynamoDB), bukan untuk beban analytics columnar Redshift.
- →PRICING/COST: Manual snapshots TAK auto-delete (kekal selamanya sampai kau padam sendiri) → caj storage berterusan, jadi cluster jangka panjang kos naik kalau tak padam yang lama. Automated snapshots auto-delete lepas retention (default 1, max 35 hari). Jimat kos cluster lama: padam manual snapshots tak perlu + set automated retention rendah. BUKAN Spot (Redshift cluster guna Reserved Instance), BUKAN instance store (data cluster = managed storage, instance store ephemeral = data hilang).
Guna Bila
Data warehouse: complex/recurring analytics atas structured data berskala besar