devHọc Dev

Week 2 - Day 1: Data Stores (Redshift, Athena, DynamoDB, OpenSearch) and Choosing by Use Case

Week 2 – Day 1

This lesson combines 5 topics: Redshift — Architecture, Distribution and Sort Keys, Redshift Serverless, Spectrum and WLM, Amazon Athena, DynamoDB for Data Engineering, OpenSearch and Choosing a Data Store by Use Case.

Learning Objectives

  • Understand Redshift's MPP architecture: leader node, compute nodes, slices
  • Choose the right distribution style: AUTO, EVEN, KEY, ALL
  • Choose sort keys and understand zone maps
  • Know compression encoding, VACUUM, ANALYZE
  • Understand Redshift Serverless: RPU, workgroup/namespace, when to choose it
  • Master Redshift Spectrum: external tables, cost, optimization
  • Understand WLM, Concurrency Scaling, materialized views
  • Know data sharing and the data sharing features
  • Understand Athena: serverless SQL on S3, pricing by data scanned
  • Optimize cost/performance: Parquet, partitions, CTAS, result reuse
  • Master workgroups, federated query, Iceberg on Athena
  • Distinguish Athena vs Redshift (Spectrum) — pick the right one for the question
  • Quick DynamoDB review: key schema, capacity modes, GSI/LSI
  • Master the data engineering angle: Streams, export to S3, zero-ETL, TTL
  • Understand hot partitions and key design
  • Know when DynamoDB fits or does not fit in a pipeline
  • Understand OpenSearch Service/Serverless: search, log analytics, dashboards
  • Review where RDS/Aurora sit in the data picture
  • Build a decision matrix for choosing a data store — a high-scoring skill for Domain 2
  • Practice the reflex of matching use case → store

Part 1: Redshift — Architecture, Distribution and Sort Keys

1. MPP architecture

SQLclients/BI(JDBC/ODBC,DataAPI)│┌────────▼────────┐│LEADERNODE│parse,plan,aggregateresults└────────┬────────┘┌─────────────────┼─────────────────┐▼▼▼┌────────────┐┌────────────┐┌────────────┐│COMPUTE1││COMPUTE2││COMPUTE3│(RA3nodes)│slice|slice││slice|slice││slice|slice│└─────┬──────┘└─────┬──────┘└─────┬──────┘└──────────RedshiftManagedStorage(S3-backed,RA3)─────────
  • Leader node: receives queries, builds the plan, distributes work to compute nodes, aggregates results — not billed separately
  • Compute nodes are divided into slices; each slice holds part of the data and processes it in parallel
  • RA3 nodes: separate compute and storage (Redshift Managed Storage on S3) — scale independently; the recommended generation
  • Columnar storage + compression + zone maps (min/max per block) → fast analytics

2. Distribution styles — where the data lives

StyleHow data is distributedWhen to use
AUTORedshift chooses (default, changes with size)Not sure — just leave it on AUTO
EVENRound-robin evenly across slicesLarge tables not joined frequently
KEYHash on the DISTKEY column — same value, same sliceFact tables joined on that column — local join, no shuffle
ALLCopies the whole table to every nodeSmall, rarely changing dimension tables

Join design principles

fact_salesDISTKEY(customer_id)──join──dim_customerDISTKEY(customer_id)→co-locatedjoin,nodatamovementbetweennodes(DS_DIST_NONE)dim_date(small,afewthousandrows)→DISTSTYLEALL→localjoinwithanytable
  • Data skew: a low-cardinality or lopsided DISTKEY (e.g. country when 90% is VN) → one slice holds everything → slow queries. Check with svv_table_info (skew_rows)
  • In EXPLAIN: DS_BCAST_INNER/DS_DIST_BOTH = broadcasting/shuffling → reconsider the distkey

3. Sort keys — how data is ordered within blocks

  • Compound sort key (default): sorts by the column order — strong when filtering on the prefix (leading column); the standard choice for time columns: SORTKEY(event_date)
  • Interleaved: balances several independent filter columns — rarely recommended today (high VACUUM REINDEX cost); AUTO sort key is a good default
  • Zone maps: Redshift stores min/max for each 1MB block; a sort key keeps data contiguous → efficient block skipping when the WHERE clause uses the sort column

Exam cue: "queries that filter by date range are slow" → sort key on the date column; "large joins are slow, DS_BCAST shows up" → distkey on the join column.

4. Compression, VACUUM, ANALYZE

  • Compression encoding per column (AZ64, LZO, ZSTD...): reduces I/O; COPY with COMPUPDATE picks automatically; AUTO by default for new tables
  • VACUUM: cleans up deleted/updated rows (new write + delete marker) and re-sorts by the sort key — Redshift now runs auto vacuum/auto sort in the background, but after a large delete you may still run it manually
  • ANALYZE: updates statistics for the planner — auto analyze is available

5. Loading and unloading data

  • COPY from S3: the standard batch load (parallel across slices — Week 1 Day 2); supports Parquet/ORC/CSV/JSON/Avro
  • UNLOAD to S3: exports query results to files (Parquet supported) — the pattern for pushing data marts out to the lake
  • Redshift Data API: run SQL over HTTPS/SDK with no driver/connection — a good fit for Lambda/Step Functions
  • Streaming ingestion: materialized view on Kinesis/MSK — reads the stream directly into an MV (near real-time, no S3 hop)

Part 2: Redshift Serverless, Spectrum and WLM

1. Redshift Serverless

  • No cluster to manage: you declare base RPU (Redshift Processing Units) and Redshift scales automatically; you pay per RPU-second while queries run — idle time incurs no compute charge (storage is billed separately)
  • Namespace (database, users, KMS — the data side) + Workgroup (compute, endpoint, RPU — the compute side)
  • SQL/feature compatible with provisioned (Spectrum, Data API, streaming ingestion...)
Choose Serverless whenChoose Provisioned (RA3) when
Workload is intermittent/unpredictable (dev/test, periodic analysis)It runs continuously and steadily — Reserved nodes are cheaper
You do not want to administer/tune a clusterYou need fine-grained WLM/queue control, node-bound features
Fast start, pay per useLarge, known 24/7 volume

2. Redshift Spectrum

How it works

Redshift(cluster/serverless)│queryexternalschema→pushscandown▼Spectrumfleet(AWS-managed,outsidethecluster)──reads──►S3(Parquet/ORC/CSV...)▲metadata:externaltableinGlueDataCatalog
  • Query S3 data without loading it; can JOIN with local tables
  • Requires: an external schema pointing to the Glue Catalog + an IAM role
  • Cost: $5/TB scanned (on top of cluster cost) → optimize the same way as Athena: Parquet, partitions, compression, column selection
  • Compared with loading into Redshift: Spectrum suits cold/high-volume/infrequently queried data; hot, frequently queried data → loading into local storage (RA3) is faster

3. Workload Management (WLM) and Concurrency Scaling

WLM

  • Orchestrates query queues: memory, concurrency, priority by user group/query group
  • Auto WLM (recommended): Redshift decides concurrency + memory, with query priority (LOWEST→HIGHEST)
  • SQA (Short Query Acceleration): short queries get their own lane and do not wait behind long ones
  • QMR (Query Monitoring Rules): rules such as "query scans > 1TB or runs > 30 minutes → log/abort/change priority" — stops runaway queries

Concurrency Scaling

  • When queues are full (BI peak hours), Redshift automatically adds transient clusters to handle read queries (and some writes) — users see no difference
  • Accrues ~1 hour of free credit per day; after that it is billed per second
  • Exam cue: "dashboards are slow at peak hours, hundreds of concurrent analysts" → Concurrency Scaling (not a permanent cluster resize)

4. Materialized views and query acceleration

  • Materialized view (MV): stores precomputed results (joins/aggregates) — incremental refresh (auto refresh available); auto query rewrite uses the MV even when the original query does not reference the MV by name
  • Pattern: dashboards that repeat the same heavy aggregate → an MV cuts both latency and load
  • Result caching: the leader caches results — identical repeated queries return instantly (free, on by default)

5. Data sharing and the ecosystem

  • Data sharing: share live data between Redshift clusters/workgroups (same/different account, cross-region) without copying — producer/consumer; the foundation for multi-warehouse architectures (ETL cluster writes, BI cluster reads)
  • Zero-ETL from Aurora/RDS/DynamoDB → Redshift (covered in Week 1 Day 2)
  • Querying Iceberg/lake: via Spectrum/Glue Catalog
  • Backup: automated snapshots into managed storage; cross-region snapshot copy for DR

Part 3: Amazon Athena

1. Overview

Athena = a serverless SQL engine (based on Trino/Presto — engine v3) that queries S3 data directly using the schema in the Glue Data Catalog. No infrastructure, you pay $5/TB of data scanned.

SQL(console/JDBC/API)│▼Athena(Trinoengine,serverless)│schema:GlueDataCatalog▼S3(Parquet/ORC/CSV/JSON/Avro,partitioned)│▼Queryresults→S3outputlocation(+resultreuse/cache)
  • Ad-hoc analytics, data lake exploration, log queries (VPC Flow Logs, CloudTrail, ALB logs)
  • DDL (CREATE TABLE) is free; failed queries are not charged
  • Beyond SQL there is also Athena for Apache Spark (serverless Spark notebooks)

2. Cost and performance optimization (exam focus)

TechniqueEffect
Columnar (Parquet/ORC) + compressionCuts data scanned by 90%+
Partitioning (+ partition projection)Partition pruning — scans only what the WHERE clause touches
SELECT only needed columns (drop SELECT *)Columnar reads only the required columns
BucketingFiltering/joining on high-cardinality columns
Merge small files (~128MB+)Less file-open overhead
CTAS / INSERT INTOConvert + re-partition with SQL
Query result reuseReturns cached results within a TTL — repeated dashboards do not rescan
LIMIT does not save scan costLIMIT still scans before truncating (unless the engine pushes it down)

3. Workgroups — governance and cost control

  • Split workgroups by team/application: separate output location, separate metrics, enforced settings
  • Data usage controls: per-query limit (query scans more than X TB → cancelled) and per-workgroup limit (hourly/daily threshold → SNS alert)
  • Tag for cost allocation; enforce result encryption
  • Exam cue: "control Athena cost per team / block queries that scan too much" → workgroups + data usage controls

4. Federated query and Iceberg

Federated query

  • Query sources outside S3 via a Lambda connector (DynamoDB, RDS/JDBC, CloudWatch Logs, Redis...): join lake data with other sources without ETL
  • Fits ad-hoc work; large, repeated volume → replicating into the lake is cheaper

Iceberg and ACID on Athena

  • CREATE TABLE ... TBLPROPERTIES ('table_type'='ICEBERG') — supports INSERT/UPDATE/DELETE/MERGE INTO, time travel (FOR TIMESTAMP AS OF), schema evolution
  • OPTIMIZE table REWRITE DATA USING BIN_PACK — small-file compaction; VACUUM cleans up old snapshots
  • This is the standard way to "UPDATE data on S3 with SQL" in today's exam

5. Athena vs Redshift/Spectrum — which to choose?

CriterionAthenaRedshift (+Spectrum)
InfrastructureNone (pure serverless)Cluster/workgroup (serverless option)
Cost$/TB scanned — cheap when queries are infrequentCluster/RPU — cheap when queries are frequent and continuous
Latency/large BI concurrencyDecent; not built for hundreds of concurrent dashboardsStrong (WLM, concurrency scaling, MV)
DataS3 (+federated)Local + S3 (Spectrum)
Typical use caseAd-hoc, exploration, log analytics, light SQL ETLProduction BI warehouse, repeated aggregates, heavy ELT

Rule of thumb: "occasional/ad-hoc queries on S3, no infrastructure" → Athena. "high-concurrency BI, consistent sub-second dashboards" → Redshift. If the question gives both halves → a combined architecture.

Part 4: DynamoDB for Data Engineering

1. Quick review of the fundamentals

  • NoSQL key-value/document, single-digit millisecond latency, automatic horizontal scaling
  • Partition key (required, determines distribution) + sort key (optional, ordering within a partition)
  • Capacity: On-demand (pay per request, unpredictable traffic) vs Provisioned (+auto scaling, cheaper for steady traffic; RCU/WCU)
  • GSI: a different key to query on — separate capacity, eventual consistency; LSI: same partition key, different sort key (created at table creation)
  • DAX: microsecond read cache
  • 1 item ≤ 400KB — keep large data in S3, DynamoDB holds the pointer/metadata

Hot partition

A poorly distributed partition key (one giant customer, a date key) → throttling (ProvisionedThroughputExceededException) even when total capacity is in surplus — similar to a Kinesis hot shard. Fix: high-cardinality keys, write sharding (add a suffix); DynamoDB adaptive capacity helps partially but cannot rescue a heavily skewed key.

2. DynamoDB in a data pipeline

Getting data OUT of DynamoDB (analytics)

MethodCharacteristicsWhen to use
Export to S3Exports from the PITR backup, does NOT consume RCU, outputs DynamoDB JSON/Amazon Ion (full or incremental export)Periodic batch analysis on Athena/Glue
DynamoDB Streams + LambdaItem-level CDC, 24h retention, near real-timeReacting to events, syncing a search index
Kinesis Data Streams for DynamoDBPushes CDC into KDS → the Kinesis ecosystem (Firehose, Flink)CDC needing long retention/large fan-out
Zero-ETL → Redshift / OpenSearchContinuous managed replicationAnalytics/search without building your own pipeline
Athena federated queryQuery in place via a connectorAd-hoc, small
Scan the table with GlueConsumes RCU, slow, expensiveAvoid — use export to S3

Classic trap: "analyze the entire DynamoDB table with Athena/Glue" → export to S3 (no RCU consumed, no impact on production), NOT a direct scan.

Getting data INTO DynamoDB

  • Batch: Glue/EMR writes (BatchWriteItem), or import from S3 (creates a new table from S3 files, no WCU consumed)
  • Streaming: a Lambda consumer reading from Kinesis writes to the table (real-time aggregate results for serving)

TTL

  • Automatically deletes expired items based on an epoch attribute — no WCU cost; items deleted by TTL appear in Streams (distinguishable) → pattern "hot data for 30 days in DynamoDB, long-term copy on S3 via Streams/Firehose"

3. Typical roles in a data architecture

(1)SERVINGLAYER:aggregateresultsfromFlink/Glue──►DynamoDB──►low-latencyAPI(2)METADATA/STATE:idempotencymarker,jobstate,checkpoint(KCLleasetable)(3)CDCSOURCE:DynamoDB──Streams/KDS──►lake/warehouse/OpenSearch

DynamoDB is not an analytics engine: no JOINs, no SQL aggregates — questions about "complex analytical queries on DynamoDB data" always lead to export/zero-ETL into another tool.

Part 5: OpenSearch and Choosing a Data Store by Use Case

1. Amazon OpenSearch Service

Concept

Managed OpenSearch (an Elasticsearch fork): full-text search, log analytics, visualization (OpenSearch Dashboards — a Kibana fork).

  • A domain consists of data nodes (+ dedicated masters, UltraWarm/cold storage for cheaper older logs)
  • OpenSearch Serverless: collections (search / time series / vector), OCUs scale automatically — no nodes to manage
  • Ingest: Firehose → OpenSearch (standard), OpenSearch Ingestion (managed pipelines), Lambda, zero-ETL from DynamoDB/direct S3 queries
  • Use cases: product/document search, real-time logs/APM, security analytics, vector search

It is not: a SQL warehouse (complex BI JOINs/aggregates → Redshift), or a source of truth (it does not replace S3/a database).

Index lifecycle for logs

Hot (SSD data nodes) → UltraWarm (S3-backed, read) → Cold → Delete
     ISM (Index State Management) policy moves indexes automatically

"Logs real-time for 7 days, occasionally read for 90 days, low cost" → hot + UltraWarm + ISM.

2. RDS/Aurora in the data engineering picture

  • OLTP (transactional, row-based) — a data source for pipelines, not the place to run heavy analytics
  • Analytics on OLTP data: read replica (light), zero-ETL → Redshift (today's standard), DMS CDC → lake
  • Running heavy reports directly on production RDS = a classic anti-pattern in the exam

3. Decision matrix — choosing a data store

Requirement in the questionStore
Object/data lake, any format, cheap, read by many enginesS3
SQL warehouse, high BI concurrency, repeated aggregatesRedshift
Ad-hoc SQL on S3, no infrastructure, pay per scanAthena
Millisecond key-value latency, large scale, serving layerDynamoDB
Relational OLTP, transactions, traditional appsRDS/Aurora
Full-text search, log analytics + dashboardsOpenSearch
Sub-ms cacheElastiCache (Redis/Valkey)
Purpose-built time seriesTimestream (recognize it)
Multi-hop relationship graphNeptune (recognize it)

Quick-distinction mantras

  • "search / log analytics / Kibana-style dashboards" → OpenSearch
  • "single-digit millisecond key-value" → DynamoDB
  • "complex SQL joins across large datasets / BI" → Redshift
  • "occasional SQL on S3" → Athena
  • "store everything cheaply, schema-on-read" → S3
  • "ACID transactions for an app" → RDS/Aurora

4. Multi-store architecture working together (poly-store)

┌─►Redshift(BI,aggregate)Sources─►S3datalake─┼─►Athena(ad-hoc)│(sourceof└─►SageMaker(ML)│truth)├─►DynamoDB(real-timeservingAPI)└─►OpenSearch(search+logdashboards)

Principle: S3 is the source of truth, and each store serves its own access pattern — the DEA exam prefers a "right tool for the job" architecture over "one store does everything".


Review Questions

  1. A 2-billion-row fact table mostly joins with dim_customer on customer_id; dim_date has only 10 thousand rows. How do you design distribution?

    Show answer

    Give fact and dim_customer the same DISTKEY(customer_id) → co-located join with no shuffle. dim_date gets DISTSTYLE ALL — a small table copied to every node, joined locally with any table. This is the classic warehouse design pattern in Redshift questions.

  2. A query filtering WHERE event_date BETWEEN ... on a 500GB table is very slow. How do you improve it?

    Show answer

    Set SORTKEY(event_date) (compound): data ordered by date lets zone maps (min/max per block) eliminate most blocks outside the date range — I/O drops sharply. The distribution key does not help single-table filters; it serves distributed joins/aggregates.

  3. After choosing the status column (5 values) as the DISTKEY, some queries became much slower. Why?

    Show answer

    Data skew: 5 values hash to at most 5 slices — the other slices have no data, and the most common value piles a huge number of rows onto one slice, making that slice the bottleneck for every parallel query. A DISTKEY needs a column with high cardinality, even distribution, and used in joins — not a status column. Check svv_table_info.skew_rows.

  4. What are the consequences of heavy UPDATE/DELETE on a Redshift table, and how do you deal with them?

    Show answer

    Redshift is append-style columnar MVCC: UPDATE = insert a new version + mark the old one deleted → dead rows take up space, the table "bloats", sort order breaks. VACUUM reclaims space and re-sorts (auto vacuum runs in the background; after a large batch delete you can run VACUUM manually), and ANALYZE updates statistics. Better design: avoid scattered updates, use a staging + swap pattern or materialized views.

  5. A Lambda function needs to run SQL on Redshift without managing connections/drivers in a VPC. How should it call Redshift?

    Show answer

    Redshift Data API — called over HTTPS (SDK/CLI), async, IAM auth (or Secrets Manager), no JDBC connection pool or Lambda in a VPC needed. Retrieve results with GetStatementResult or an event on completion. The standard for serverless orchestration (Step Functions also integrates with it directly).

  6. You need to bring Kinesis data into Redshift in near real time without going through S3. Which feature?

    Show answer

    Redshift streaming ingestion: create a materialized view on Kinesis Data Streams (or MSK) — Redshift reads the stream directly and refreshes the MV (can be automatic) with latency in seconds. Compared with Firehose→S3→COPY: fewer steps, lower latency.

  7. The analytics team only runs queries a few hours a day and is idle the rest of the time; there is no DBA. Which form of Redshift and why?

    Show answer

    Redshift Serverless — billed per RPU-second only while queries run, no compute cost when idle; no cluster/WLM to manage. A provisioned cluster running 24/7 bills even while idle; manual pause/resume is extra operational work. This is the "intermittent workload + least operational overhead" answer.

  8. 90% of the data is 5 years of history that is rarely queried; 10% is hot data queried daily. What is the most cost-effective architecture?

    Show answer

    Keep hot data in Redshift local storage (RA3); keep historical data on S3 (Parquet, partitioned) and query it via Spectrum when needed — it can still JOIN with local tables. Paying $5/TB for infrequent scans is far cheaper than keeping 5 years of data in the warehouse. This is the "hot in cluster, cold in lake" pattern.

  9. Dashboards slow down at peak hours because hundreds of queries are queued; outside those hours the cluster is idle. What is the solution without resizing?

    Show answer

    Enable Concurrency Scaling — Redshift automatically adds transient clusters to serve queries when queues are full and removes them after the peak; there is ~1 hour of free credit per day. Combine with Auto WLM + query priority so dashboards get priority, and SQA for short queries. A permanent resize is wasteful because the cluster is idle off-peak.

  10. One analyst often runs full-table-scan queries that clog the cluster. How do you control this automatically?

Show answer

Query Monitoring Rules (QMR) in WLM: define thresholds (rows scanned, execution time, nested loop join...) and actions (log / change priority / hop / abort). Example: "scan > 100M rows and runtime > 10 minutes → abort". Combine with low query priority for the ad-hoc group.

  1. A BI team in another account needs to read live data from the central warehouse and must not create a copy. Which feature?
Show answer

Redshift data sharing: the producer creates a datashare (schema/table), and the consumer (a cluster/workgroup in another account — via authorize + association) queries it live, with no copy and no ETL. The consumer pays for its own compute — isolating workloads between teams. UNLOAD/copying to S3 creates a copy — violates the "live, no copy" requirement.

  1. The same heavy aggregate is called by a dashboard every 5 minutes. How do you reduce cost/latency?
Show answer

Create a materialized view for that aggregate with auto refresh — the dashboard query is routed to the MV by auto query rewrite and runs in milliseconds instead of rescanning the base tables. The result cache also helps if the query repeats exactly and the data does not change between runs.

  1. An Athena query over 1TB of CSV costs $5 and runs slowly. Name three things that cut cost by 90%+.
Show answer

(1) Convert to Parquet + compression (CTAS) — columnar reads only the needed columns; (2) partition on the commonly filtered column (e.g. date) to prune; (3) drop SELECT * and SELECT only the columns you use. Together these usually cut data scanned by >90% — the classic formula for every "reduce Athena cost" question.

  1. You need to stop analysts from running queries that scan more than 1TB and track cost per team. Which Athena feature?
Show answer

Workgroups: give each team its own workgroup, enable a per-query data usage control (over 1TB → the query is cancelled) and per-workgroup limits (total hourly/daily threshold → SNS alert), add cost allocation tags, and enforce output location + encryption.

  1. A dashboard re-runs the same query every 10 minutes while the data only updates hourly. How do you reduce scanning?
Show answer

Enable query result reuse with a TTL of ~60 minutes — Athena returns the cached result instead of rescanning S3 (no scan charge for reused runs). Alternative: materialize the result with CTAS/INSERT INTO into a small summary table and have the dashboard query that table.

  1. You need to join S3 data with a DynamoDB table for a one-off ad-hoc analysis. What is the fastest solution?
Show answer

Athena Federated Query with the DynamoDB connector (Lambda) — join directly in SQL, no export needed. If the need recurs frequently on a large table → export DynamoDB to S3 (the built-in export to S3) and then query, which is cheaper and does not consume RCU.

  1. An Iceberg table on Athena gets slower and slower due to thousands of small files from streaming writes. Which command fixes it?
Show answer

Run OPTIMIZE <table> REWRITE DATA USING BIN_PACK — compaction merges small files into larger ones; periodically run VACUUM to expire old snapshots and remove orphan files (which also cuts storage cost). You can automate this with Step Functions/EventBridge Scheduler, or use S3 Tables so AWS handles compaction automatically.

  1. When is Athena the WRONG choice compared with Redshift?
Show answer

When you need: (1) hundreds of concurrent BI queries with consistent sub-second latency — Athena has no equivalent of WLM/concurrency scaling; (2) aggregates repeated continuously all day — paying $/TB scanned every time costs more than a cluster; (3) heavy ELT transforms that depend on local tables/optimized sort and dist keys. Athena wins for ad-hoc, infrequent, no-infrastructure work.

  1. You need to analyze an entire 2TB DynamoDB table daily with Athena without affecting the production application. Solution?
Show answer

DynamoDB export to S3 (requires PITR to be enabled): the export runs from the backup, so it does not consume RCU and does not affect the table; the output (DynamoDB JSON/Ion) can be queried with Athena or converted to Parquet with Glue. Incremental export is available for subsequent runs. Scanning with a Glue connector consumes a lot of RCU — violates "no impact on production".

  1. Every item change must update a search index in near real time. What are the options?
Show answer

(1) Zero-ETL integration DynamoDB → OpenSearch Service — managed, least operational overhead; (2) DynamoDB Streams + Lambda writing to OpenSearch — flexible for customization; (3) Kinesis Data Streams for DynamoDB if you need fan-out/long retention. If the question stresses "least operational overhead" → zero-ETL.

  1. An application writing session logs with the key date (the current day) is throttled at peak hours even though capacity is in surplus. Why, and how do you fix it?
Show answer

Hot partition: every write for the day lands on one partition key (today's date). Fix: design a distributed key — use session_id/user_id (high cardinality) as the partition key, or write sharding: date#<random 0-9> and merge on read. Increasing WCU does not help because the throughput limit is per partition.

  1. Event data only needs to be "hot" for 30 days for an API, but must be kept forever for analytics. Architecture?
Show answer

DynamoDB keeps 30 days with TTL auto-deletion (no WCU cost); the incoming data flow is written to S3 in parallel (e.g. Kinesis source → Firehose → S3, with DynamoDB only for serving) — or capture Streams (including TTL delete events) → Firehose → S3. Athena analyzes on S3; DynamoDB stays lean and cheap because it only holds hot data.

  1. When do you choose on-demand over provisioned capacity?
Show answer

On-demand: unpredictable/spiky traffic, new tables with unknown patterns, wanting zero capacity management — pay per request. Provisioned (+auto scaling): steady/predictable traffic, large stable volume — significantly cheaper, and even cheaper with reserved capacity. The same logic as Kinesis on-demand vs provisioned.

  1. The operations team needs full-text search on application logs and real-time dashboards. Which store, and which ingest path has the least operational overhead?
Show answer

OpenSearch Service (or Serverless) + OpenSearch Dashboards. Least-overhead ingest: Amazon Data Firehose with an OpenSearch destination (plus a Lambda transform to parse logs if needed), with S3 backup for the originals. CloudWatch Logs can also be subscribed to OpenSearch via Firehose/a subscription filter.

  1. Logs are queried hot for 7 days, read occasionally until 90 days, then deleted — how do you reduce OpenSearch cost?
Show answer

ISM policy: indexes stay hot (SSD data nodes) for 7 days → move to UltraWarm (S3-backed, much cheaper, still queryable) until 90 days → delete (or cold storage if long retention is needed). Fully automated, no manual steps.

  1. Match a store to each requirement: (a) shopping cart with <10ms latency; (b) multi-dimensional revenue reporting for 200 analysts; (c) keep all raw events forever; (d) product search by keyword tolerant of typos.
Show answer

(a) DynamoDB — millisecond key-value; (b) Redshift — high BI concurrency, complex SQL; (c) S3 — cheap, durable, schema-on-read; (d) OpenSearch — full-text, fuzzy matching. One tool per access pattern — poly-store is the standard answer for store-selection questions.

  1. Monthly reports running directly on production RDS slow down the app. Give two approaches by level of investment.
Show answer

Light: read replica — point report queries at the replica to offload reads (still an OLTP engine, good enough for moderate reports). Long-term standard: move the data into an analytics store — zero-ETL Aurora/RDS → Redshift (least operational overhead) or DMS/CDC → S3 + Athena. Principle: OLTP should not carry heavy analytics.

  1. When is OpenSearch Serverless a better fit than an OpenSearch domain?
Show answer

Serverless when the workload is variable/unpredictable, you do not want to size nodes/shards, and you want fast development — pay per auto-scaling OCU. Domain (provisioned) when the workload is large and steady (cost-optimize with instances/reserved), or you need detailed features/configuration (UltraWarm, certain plugins, fine-grained tuning). The same logic as Redshift Serverless vs provisioned.

Hands-on Exercises

Part 1: Redshift — Architecture, Distribution and Sort Keys

  • Redraw the leader/compute/slice/RA3 architecture from memory
  • Write DDL: a fact table (DISTKEY + SORTKEY) and 2 dimensions (KEY + ALL) for a sales schema
  • Read the EXPLAIN of a join and identify DS_DIST_NONE vs DS_BCAST_INNER
  • Read Amazon Redshift best practices for designing tables

Part 2: Redshift Serverless, Spectrum and WLM

  • Create a Redshift Serverless workgroup (8 RPU), load a sample table with COPY, run test queries
  • Create an external schema pointing to the Glue Catalog and query last week's S3 table via Spectrum
  • Create a materialized view for an aggregate, run the original query, and check whether the plan was rewritten
  • Read Redshift Serverless billing

Part 3: Amazon Athena

  • Query CloudTrail or VPC Flow Logs with Athena (use the sample DDL in the docs)
  • Create a new workgroup with a 100MB per-query limit and try running a query that exceeds it
  • Create an Iceberg table with Athena, run INSERT + UPDATE + a time travel query
  • Read Athena performance tuning tips

Part 4: DynamoDB for Data Engineering

  • Create a demo table, enable PITR, run export to S3, and query the output with Athena
  • Enable TTL on the expire_at attribute, write items with a short expiry, and watch them get deleted automatically
  • Design a key schema for a clickstream table at 100K events/s — write down why you chose the partition key
  • Read DynamoDB zero-ETL integrations

Part 5: OpenSearch and Choosing a Data Store by Use Case

  • Redraw the poly-store architecture from section 4 and annotate the reason for each branch
  • Make 10 "use case → store" flashcards from the decision matrix
  • Build a test pipeline: Firehose → OpenSearch Serverless collection, send a few JSON logs, view them in Dashboards
  • Review the data store parts before taking the end-of-week quiz

References


Next lesson →