Database & AnalyticsSection 078 min read10 questions

Databases & Analytics

RDS, Aurora, DynamoDB, Redshift, Athena & more

ภาพรวม Database & Analytics ทั้งหมดของ AWS ตั้งแต่ Relational (RDS, Aurora), NoSQL (DynamoDB, DocumentDB), In-memory (ElastiCache), Data Warehouse (Redshift), Big Data (EMR, Athena, QuickSight, Glue) ไปจนถึง Specialty DB (Neptune, QLDB, Managed Blockchain) — เลือกใช้ให้ถูกกับ workload

ในหน้านี้17 sections
  1. 01Databases Intro — เมื่อไหร่ควรใช้ DB?
  2. 02AWS RDS — Managed Relational Database
  3. 03Amazon Aurora
  4. 04RDS Deployments — Read Replicas vs Multi-AZ
  5. 05Amazon ElastiCache
  6. 06Amazon DynamoDB
  7. 07Amazon Redshift
  8. 08Amazon EMR — Elastic MapReduce
  9. 09Amazon Athena
  10. 10Amazon QuickSight
  11. 11Amazon DocumentDB
  12. 12Amazon Neptune
  13. 13Amazon QLDB — Quantum Ledger Database
  14. 14Amazon Managed Blockchain
  15. 15Database Migration Service (DMS)
  16. 16AWS Glue — ETL Service
  17. 17Summary — เลือก service ให้ถูก
01

Databases Intro — เมื่อไหร่ควรใช้ DB?

ก่อนเลือก database ต้องเข้าใจว่า เมื่อไหร่ควรใช้ database แทนการเก็บไฟล์ใน disk storage (EFS, EBS, S3) — Database เหมาะกับข้อมูลที่มี structure, ต้องการ indexes สำหรับ query เร็ว, และมี relationships ระหว่างข้อมูล

  • Disk storage (EFS/EBS/S3) — เก็บไฟล์ดิบ (images, videos, logs, backups) ไม่มี query engine
  • Database — เก็บ structured data ที่ต้อง query, filter, join, sort ได้เร็ว มี indexes
  • ใช้ DB เมื่อ: ต้องการ relationships, transactions, ACID, ค้นหาเร็วผ่าน index
  • ใช้ S3/EFS/EBS เมื่อ: เก็บไฟล์ binary, archive, shared storage ระหว่าง EC2

Relational Database (SQL)

เหมือน Excel — มีตาราง, columns, rows, relationships ระหว่างตาราง ใช้ SQL query (SELECT, JOIN) เหมาะกับข้อมูลที่ schema ชัดเจน เช่น users, orders, products

NoSQL Database

Schema ยืดหยุ่น scale-out (horizontal) ได้ดี performance สูง — มีหลายแบบ: key-value (DynamoDB), document (DocumentDB), graph (Neptune), in-memory (ElastiCache), search (OpenSearch)

02

AWS RDS — Managed Relational Database

Amazon RDS คือ Managed Relational Database Service ที่ใช้ SQL — AWS จัดการ infrastructure ให้ คุณแค่สร้าง DB instance แล้วใช้ได้เลย

  • รองรับ 6 engines: PostgreSQL, MySQL, MariaDB, Oracle, MS SQL Server, Aurora
  • Automated provisioning + OS patching — AWS จัดการให้
  • Continuous backups + point-in-time restore
  • Monitoring dashboards — ดู metrics ผ่าน CloudWatch
  • Read Replicas เพิ่ม read performance
  • Multi-AZ สำหรับ disaster recovery (DR)
  • Maintenance windows สำหรับ upgrade
  • Scaling capability — vertical และ horizontal
  • Storage backed by EBS (gp2/gp3/io1)
03

Amazon Aurora

Amazon Aurora เป็น proprietary relational database ของ AWS รองรับ PostgreSQL และ MySQL — ออกแบบมาให้เร็วและ scale ได้ดีกว่า RDS ปกติ

  • เร็วกว่า MySQL บน RDS ถึง 5x และเร็วกว่า PostgreSQL บน RDS ถึง 3x
  • Storage auto-grows ทีละ 10GB จนถึง 64TB
  • ราคาแพงกว่า RDS ~20% แต่ more efficient (cost-effective ในระยะยาว)
  • ไม่อยู่ใน Free Tier
  • Cloud-native — เก็บ 6 copies ของข้อมูลใน 3 AZ
  • รองรับ Aurora Serverless (auto-scaling) และ Aurora Global Database (multi-region)
04

RDS Deployments — Read Replicas vs Multi-AZ

RDS มี deployment patterns 3 แบบที่ต่างกัน — เลือกตามจุดประสงค์: scale reads, high availability, หรือ multi-region DR

Read Replicas — Scale READ

สร้าง replica ได้สูงสุด 5 ตัว (15 สำหรับ Aurora) — ข้อมูลถูก WRITE เข้า main DB เท่านั้น แล้ว replicate ไปยัง replicas เพื่อรับ READ workload ช่วยเพิ่ม performance

Multi-AZ — High Availability

สร้าง 1 standby ใน AZ อื่น สำหรับ failover เมื่อ AZ หลักล่ม — Standby ไม่รับ traffic (ไม่ใช่สำหรับ scale read) ข้อมูลยังคง read/written ที่ main เท่านั้น

Multi-Region (Read Replicas)

Replicate ไปยัง Region อื่นเพื่อ Disaster Recovery + local read performance สำหรับ users ทั่วโลก — มีค่า replication network cost

05

Amazon ElastiCache

Amazon ElastiCache คือ managed in-memory database service รองรับ Redis หรือ Memcached — ใช้สำหรับลด load จาก database หลักโดยเก็บ frequently-read data ไว้ใน memory

  • เลือก engine ได้: Redis (HA, persistence, advanced data types) หรือ Memcached (simple, multi-threaded)
  • High performance + low latency — sub-millisecond
  • ลด load จาก database หลักสำหรับ read-heavy workloads
  • AWS จัดการ OS patching, optimization, setup, configuration, monitoring, failure recovery, backups ให้
  • Use cases: session store, leaderboard, real-time analytics, caching
06

Amazon DynamoDB

Amazon DynamoDB คือ fully managed NoSQL key-value database — serverless, distributed, scale ได้ระดับ planet-scale

  • Highly available — replicate ข้ามตั้ง 3 AZ อัตโนมัติ
  • Serverless, distributed — ไม่ต้องจัดการ infrastructure
  • รองรับ millions of requests/second, trillions of rows, 100s of TB
  • Single-digit millisecond latency
  • Integrate กับ IAM สำหรับ security
  • Low cost + auto-scaling capability
  • Key/value data model (รองรับ document ได้ด้วย)

DAX — DynamoDB Accelerator

In-memory cache เฉพาะ DynamoDB — เร็วขึ้น 10x (จาก ms → microseconds) ไม่ต้องเปลี่ยน application code (compatible กับ DynamoDB API)

DAX vs ElastiCache

DAX = ใช้ได้เฉพาะ DynamoDB เท่านั้น | ElastiCache = general-purpose ใช้ได้กับ database ใดก็ได้ (RDS, Aurora, custom) — ถามเรื่อง cache DynamoDB ตอบ DAX

DynamoDB Global Tables

Multi-region, multi-master replication (active-active) — read/write ได้ทุก region, low-latency สำหรับ users ทั่วโลก

DynamoDB Streams

Time-ordered sequence of changes (insert/update/delete) — trigger Lambda ได้ event-driven, เก็บ 24 ชั่วโมง

07

Amazon Redshift

Amazon Redshift คือ data warehouse service — based on PostgreSQL แต่ออกแบบมาสำหรับ OLAP (Online Analytical Processing) ไม่ใช่ OLTP (Online Transaction Processing)

  • OLAP = analytics + data warehousing (ไม่เหมาะกับ transaction-heavy workload)
  • Load data per hour (batch) ไม่ใช่ per second
  • เร็วกว่า data warehouses อื่น 10 เท่า
  • Scale ได้ถึง PB-scale
  • Columnar storage (แทน row-based) เพื่อ analytics performance
  • MPP (Massively Parallel Processing) — ประมวลผล query ขนาดใหญ่ขนานกัน
  • Pricing: pay per instance ที่ provision
  • Integrate กับ BI tools เช่น Amazon QuickSight, Tableau
08

Amazon EMR — Elastic MapReduce

Amazon EMR (Elastic MapReduce) ใช้สร้าง Hadoop clusters สำหรับ big data processing — รัน บน hundreds of EC2 instances

  • สร้าง Hadoop clusters วิเคราะห์ + process big data
  • Cluster ใช้ EC2 instances ได้เป็น หลายร้อยตัว
  • รองรับ frameworks: Apache Spark, HBase, Presto, Flink และอื่น ๆ
  • EMR จัดการ provisioning + configuration + auto-scaling ให้
  • Integrate กับ Spot Instances เพื่อลดค่าใช้จ่าย
  • Use cases: data processing, machine learning, web indexing, big data analytics
09

Amazon Athena

Amazon Athena คือ serverless query service ที่ใช้ SQL query ข้อมูลใน S3 โดยตรง — ไม่ต้องโหลดเข้า database ก่อน

  • Fully serverless — ไม่ต้อง provision อะไรทั้งสิ้น
  • Query ข้อมูลใน S3 ด้วย SQL ได้เลย
  • Pay per query (จ่ายตาม data ที่ scan)
  • Output ผลลัพธ์ลง S3 อีกที่หนึ่ง
  • Secured ด้วย IAM
  • Use cases: one-time SQL queries, log analytics, ad-hoc analysis, BI reporting บน S3 data
10

Amazon QuickSight

Amazon QuickSight คือ serverless, machine-learning powered business intelligence (BI) service — สร้าง interactive dashboards และ visualizations

  • Serverless BI service — ไม่ต้องดูแล infrastructure
  • Interactive dashboards + visualizations
  • ML-powered insights (anomaly detection, forecasting)
  • Per-session pricing — จ่ายตาม session ที่ user เปิดใช้
  • Integrate กับ RDS, Aurora, Athena, Redshift, S3 และอื่น ๆ
  • Use cases: business analytics, building visualizations, ad-hoc analysis, การ insights ทาง business
11

Amazon DocumentDB

Amazon DocumentDB คือ "Aurora แต่สำหรับ MongoDB" — เป็น NoSQL document database (JSON) ที่ MongoDB-compatible

  • MongoDB-compatible document database (NoSQL JSON)
  • Fully managed, highly available — replicate ข้าม 3 AZ
  • Storage auto-grows ทีละ 10GB จนถึง 64TB
  • รองรับ millions of requests/second
  • เหมาะกับ migration จาก MongoDB on-premise มา AWS
12

Amazon Neptune

Amazon Neptune คือ fully managed graph database — เหมาะกับข้อมูลที่มี relationships ซับซ้อน

  • Graph database — เก็บ nodes + edges (relationships)
  • Highly available ข้าม 3 AZ, 15 read replicas
  • รองรับ billions of relations, query ระดับ milliseconds
  • Use cases: social networks, recommendation engines, fraud detection, knowledge graphs
13

Amazon QLDB — Quantum Ledger Database

Amazon QLDB (Quantum Ledger Database) คือ ledger database สำหรับเก็บ financial transactions และ history of changes ที่ immutable และ cryptographically verifiable

  • Fully managed, serverless, highly available, replicate ข้าม 3 AZ
  • เก็บ complete history of changes ของทุก application data
  • Immutable (ลบ/แก้ไม่ได้) + cryptographically verifiable (ตรวจสอบความถูกต้องได้)
  • Use case: financial transaction ledger, audit trail, compliance
14

Amazon Managed Blockchain

Amazon Managed Blockchain ใช้สร้าง applications ที่ multiple parties สามารถทำ transaction ระหว่างกันได้โดยไม่มี central authority

  • Decentralized — ไม่มี central authority
  • รองรับ Hyperledger Fabric และ Ethereum
  • Fully managed — AWS ดูแล infrastructure
  • Use cases: supply chain, multi-party transactions, decentralized applications
15

Database Migration Service (DMS)

AWS Database Migration Service (DMS) ใช้ migrate database มา AWS — source database ยังคงทำงานต่อได้ระหว่าง migration (zero-downtime หรือใกล้เคียง)

  • Quickly + securely migrate databases มา AWS
  • Source DB ยังคงใช้งานได้ระหว่าง migration (resilient + self-healing)
  • Homogeneous migration: Oracle → Oracle, MySQL → MySQL
  • Heterogeneous migration: Microsoft SQL Server → Aurora, Oracle → PostgreSQL (ใช้ร่วมกับ AWS Schema Conversion Tool — SCT)
  • Use cases: lift-and-shift to RDS, consolidate databases, replicate ระหว่าง regions
16

AWS Glue — ETL Service

AWS Glue คือ managed ETL (Extract, Transform, Load) service ที่เป็น serverless — เตรียม + transform data สำหรับ analytics

  • Managed ETL service — extract, transform, load data
  • Serverless — ไม่ต้อง provision/manage server
  • เตรียม + transform data ก่อนทำ analytics
  • Glue Data Catalog: catalog ของ datasets (metadata, schema) ใช้กับ Athena, Redshift Spectrum, EMR
17

Summary — เลือก service ให้ถูก

สรุปแต่ละ service กับ use case หลัก — ข้อสอบ CLF-C02 ชอบถามแบบเลือก service ให้ถูกกับโจทย์:

RDS

Managed Relational DB (SQL) — PostgreSQL/MySQL/MariaDB/Oracle/SQL Server

Aurora

Cloud-native relational, 5x MySQL / 3x PostgreSQL — high performance

ElastiCache

In-memory cache — Redis / Memcached, ลด DB load

DynamoDB

Serverless NoSQL key-value, single-digit ms latency, planet-scale

DAX

Cache เฉพาะ DynamoDB → microsecond latency

Redshift

Data warehouse (OLAP), columnar, PB-scale analytics

EMR

Hadoop/Spark cluster สำหรับ big data processing

Athena

Serverless SQL query บน S3 — pay per query

QuickSight

Serverless BI dashboards + visualizations

DocumentDB

MongoDB-compatible (Aurora for MongoDB)

Neptune

Graph DB — social networks, recommendations, fraud

QLDB

Immutable ledger — financial transactions, audit trail

Managed Blockchain

Decentralized — Hyperledger Fabric / Ethereum

DMS

Migrate DB มา AWS (homogeneous + heterogeneous)

Glue

Serverless ETL + Data Catalog (ใช้กับ Athena/Redshift/EMR)

  • OLTP (transactional) → RDS / Aurora
  • OLAP (analytics, data warehouse) → Redshift
  • NoSQL key-value, planet-scale → DynamoDB
  • Cache เพื่อลด DB load → ElastiCache (general) หรือ DAX (สำหรับ DynamoDB)
  • Query S3 ด้วย SQL แบบ serverless → Athena
  • Big data processing (Hadoop/Spark) → EMR
  • Graph data → Neptune, MongoDB-compatible → DocumentDB
  • Migrate database มา AWS → DMS (+ SCT ถ้าเปลี่ยน engine)
ทดสอบ

คำถามทบทวน

10 ข้อ — เลือกคำตอบเพื่อดูเฉลยและคำอธิบาย

ข้อ 1 / 10คะแนน 0

Application ต้องการเก็บ user profiles ที่มี schema ยืดหยุ่นและ scale ระดับ millions of requests/second ด้วย single-digit ms latency ควรใช้ service ใด?