This lesson combines 5 topics: Amazon Kinesis Data Streams, Amazon Data Firehose, Amazon MSK and MSK Serverless, Kinesis vs MSK — Choosing a streaming technology, Managed Service for Apache Flink and Streaming ETL.
Learning Objectives
- Understand the Kinesis Data Streams architecture: shard, partition key, sequence number
- Distinguish provisioned vs on-demand capacity mode
- Know the producer/consumer options: SDK, KPL/KCL, enhanced fan-out
- Diagnose the classic problems: hot shard, ProvisionedThroughputExceeded, iterator age
- Understand that Firehose is a delivery service: sources, destinations, buffering
- Know transformation with Lambda and record format conversion to Parquet
- Know dynamic partitioning and error handling (S3 backup)
- Clearly distinguish Firehose vs Kinesis Data Streams
- Review Kafka concepts: topic, partition, consumer group, offset
- Understand MSK provisioned: brokers, storage, multi-AZ HA
- Know MSK Serverless and MSK Connect
- Know the security options and the scenarios where you pick MSK
- Compare Kinesis Data Streams vs MSK comprehensively along the decision axes
- Match the right service to the signals in the question (exam cues)
- Know the typical end-to-end streaming architectures
- Review SQS/SNS/EventBridge to eliminate distractors
- Understand Amazon Managed Service for Apache Flink: architecture, KPU, checkpointing
- Know windowing: tumbling, sliding, session — and pick the right one for the requirement
- Know the other streaming ETL options: Glue streaming, Lambda
- Pick the right stream processing tool for the level of complexity
Part 1: Amazon Kinesis Data Streams
1. Core architecture
- Record ≤ 1 MiB by default (since 10/2025 configurable up to 10 MiB per stream via
UpdateMaxRecordSize; the 1 MB/s per-shard write limit is unchanged, so large records are for occasional payloads only); assigned a sequence number within the shard - The partition key decides which shard a record goes to (MD5 hash) — same key → same shard → ordering per key
- Data is stored and replayable within the retention window — the core difference from Firehose
Per-shard limits (must memorize)
| Direction | Limit |
|---|---|
| Write | 1 MB/s or 1,000 records/s |
| Read (shared) | 2 MB/s total across all consumers, 5 GetRecords/s |
| Read (enhanced fan-out) | 2 MB/s for EACH consumer (push over HTTP/2, ~70ms) |
2. Capacity modes
| Provisioned | On-demand | |
|---|---|---|
| Shard management | You size it and reshard (split/merge) | AWS scales automatically |
| Cost | Per shard-hour — cheaper when traffic is steady and predictable | Per GB in/out — suits spiky, unpredictable traffic |
| Exam keyword | "predictable traffic, cost-effective" | "unpredictable/spiky, least operational overhead" |
3. Producers
| Option | Characteristics |
|---|---|
AWS SDK (PutRecord/PutRecords) | Simple; PutRecords batches up to 500 records |
| KPL (Kinesis Producer Library) | Batching + aggregation (packs many small records into 1 Kinesis record) → high throughput, low cost; the price is extra latency (RecordMaxBufferedTime); automatic retries |
| Kinesis Agent | Installed on the server, tails log files and sends them to the stream |
| AWS services | CloudWatch Logs subscription, EventBridge, IoT Core... |
KPL aggregation: the consumer side needs KCL (or the deaggregation library) to split records. Question says "millions of small records, optimize throughput" → KPL.
4. Consumers
| Option | Characteristics |
|---|---|
| Lambda (event source mapping) | Polls for you, batch size/window, parallelization factor up to 10 concurrent batches/shard; error handling: bisect, retry, DLQ/on-failure destination |
| KCL (Kinesis Client Library) | Self-managed app (EC2/ECS); checkpoints to a DynamoDB table, distributes shards across workers automatically (leases) |
| Enhanced fan-out (EFO) | Each consumer registers separately, dedicated 2MB/s/shard, HTTP/2 push — use when there are many consumers or you need low latency; extra cost |
| Firehose / Managed Flink | Read the stream as a source for delivery/analytics |
5. Resharding and troubleshooting
Hot shard / hot partition
A poorly distributed partition key (e.g. all records sharing one large store_id) → 1 shard is overloaded while the others sit idle → ProvisionedThroughputExceededException even though total capacity is sufficient.
- Fix: higher-cardinality partition key (add a random suffix/salt), or split the hot shard, or switch to on-demand (does not help when the key is badly skewed)
High iterator age (consumer falling behind)
The GetRecords.IteratorAgeMilliseconds metric rises → the consumer cannot keep up:
- Add shards (for Lambda: 1 concurrent invocation per shard), raise the parallelization factor, optimize the code, increase Lambda memory
- Check for repeated failures (poison record) causing endless retries — configure
maximum retry attempts, bisect batch, on-failure destination (SQS/SNS)
CloudWatch metrics to remember
IncomingBytes/IncomingRecords,WriteProvisionedThroughputExceededGetRecords.IteratorAgeMilliseconds— how far the consumer lagsReadProvisionedThroughputExceeded— many consumers sharing 2MB/s → consider EFO
6. Kinesis vs SQS (quick distinction)
| Kinesis Data Streams | SQS | |
|---|---|---|
| Model | Stream, many consumers read the same data, replay | Queue, each message is processed by 1 consumer and then deleted |
| Ordering | By partition key within a shard | FIFO queue (limited throughput) |
| Retention | 24h-365 days, replay | Up to 14 days, no replay after deletion |
| Use case | Real-time analytics, fan-out, replay | Decoupling, task queue, simple buffering |
Part 2: Amazon Data Firehose
1. Overview
Amazon Data Firehose (formerly Kinesis Data Firehose, renamed 2/2024) is a fully managed service that receives streaming data and delivers it to storage/analytics destinations. No shards to manage, no consumers to write, it scales automatically.
Core characteristics
- Near real-time: data is buffered and then flushed on buffer size or buffer interval, whichever is reached first
- Buffer interval from 0 seconds (zero buffering — delivers within a few seconds) to 900 seconds; a common default is 300s/5MB
- Scales automatically, no shards, no capacity planning — "least operational overhead" for delivery
- Does not store data for replay (if you need replay → put Kinesis Data Streams in front)
- Billed per GB ingested (+ format conversion and dynamic partitioning fees if enabled)
2. Transformation and format conversion
Lambda transformation
Firehose invokes Lambda to process batches of records before writing to the destination: parse, enrich, filter, normalize.
- Lambda returns each record with a status:
Ok/Dropped/ProcessingFailed - Failed records are written to the S3 error prefix (processing-failed) — no data loss
Record format conversion (built-in)
Convert JSON → Parquet or ORC inside Firehose:
- Requires a schema defined in the Glue Data Catalog
- Source is not JSON (e.g. CSV)? → use a Lambda transform to turn it into JSON first, then format conversion
- This is the standard answer for "streaming JSON into S3 as Parquet, least operational overhead"
Dynamic partitioning
Writes to S3 prefixes based on values inside the record (jq expression or metadata from Lambda):
s3://lake/events/customer_id=1234/year=2026/month=07/...
- Replaces having to run a re-partitioning job later; extra cost per GB
- Combine with
year/month/daykeys derived from the record timestamp
3. Delivery to each destination — exam-worthy details
| Destination | Mechanism | How failures are handled |
|---|---|---|
| S3 | Writes objects per buffer, custom prefix + error prefix | Retry, then write to the error prefix |
| Redshift | Writes to intermediate S3, then issues COPY | Error manifest in S3 |
| OpenSearch | Indexes directly | Failed docs → S3 backup |
| HTTP endpoint / Splunk... | POSTs batches | Retry + S3 backup |
- S3 backup: you can enable backup of all source records (before transformation) to a separate bucket — for reprocessing/audit
- Output compression: GZIP/Snappy/ZSTD; KMS encryption
4. Firehose vs Kinesis Data Streams (must-memorize table)
| Kinesis Data Streams | Amazon Data Firehose | |
|---|---|---|
| Nature | Stream storage — arbitrary producers/consumers | Delivery service — fixed destination |
| Latency | Real-time (~ms-s) | Near real-time (buffer; 0s-900s) |
| Replay | Yes (retention 24h-365d) | No |
| Arbitrary consumers | Yes (Lambda, KCL, Flink, many apps) | No (only supported destinations) |
| Capacity management | Shards (or on-demand) | Fully automatic |
| Custom processing | Write your own consumer | Only Lambda transform in the flow |
| Use case | Real-time analytics, many consumers, ordering, replay | Loading data into S3/Redshift/OpenSearch with little operations |
Common combined pattern: KDS (many real-time consumers + replay) → one consumer is Firehose, archiving to S3 as Parquet.
5. Typical scenarios
| Question | Answer |
|---|---|
| Clickstream JSON → S3 Parquet, partitioned by date, least ops | Firehose + format conversion + dynamic partitioning |
| Application logs → OpenSearch for search, near real-time | Firehose with an OpenSearch destination |
| Need both real-time alerting and an S3 archive | KDS → (Lambda alert) + (Firehose → S3) |
| "Deliver within seconds, don't want to wait for a 60s buffer" | Zero buffering (buffer interval 0) |
| Records need extra fields added before storage | Lambda transformation in Firehose |
Part 3: Amazon MSK and MSK Serverless
1. Kafka basics (enough for the exam)
- A topic is split into partitions; each message has an offset within its partition; ordering is guaranteed within a single partition
- Consumer group: consumers share the partitions among themselves; multiple groups read independently (similar to fan-out)
- Replication factor (usually 3): a partition has a leader + replicas on other brokers → tolerates broker failure
- Retention is configurable (hours/days/unlimited with tiered storage)
Concept mapping to Kinesis: topic ≈ stream, partition ≈ shard, offset ≈ sequence number, consumer group ≈ consumer application (KCL).
2. Amazon MSK (provisioned)
Managed Apache Kafka: AWS operates the control plane (provisioning, patching, metrics, broker recovery), you control the Kafka configuration.
- A cluster of multiple brokers spread across 2-3 AZs (3 recommended) in your VPC
- Choose the instance type (kafka.m5/m7g...), number of brokers, EBS storage per broker (+ storage auto scaling)
- Tiered storage: moves older data to a cheaper tier, practically unlimited retention
- Self-managed clients: producers/consumers are standard Kafka applications (running on EC2/ECS/EKS/Lambda*)
- You still have to: size the cluster, choose partition counts, rebalance (Cruise Control), manage clients
MSK security
| Layer | Options |
|---|---|
| Encryption in-transit | TLS (client-broker, broker-broker) |
| Encryption at-rest | KMS on EBS |
| AuthN/AuthZ | IAM access control (simplest, recommended), SASL/SCRAM (user/pass in Secrets Manager), mTLS (Private CA); Kafka ACLs |
| Network | Cluster inside a VPC, security groups; multi-VPC private connectivity/PrivateLink for cross-account |
3. MSK Serverless
- No broker/storage choices — pay per cluster-hour + partition-hour + GB in/out/storage
- Scales capacity automatically; suits unpredictable workloads or teams that don't want to size a cluster
- Configuration is limited compared with provisioned (maximum retention, throughput per partition...) — for the exam you only need: "Kafka without managing capacity" → MSK Serverless
- AuthN: IAM access control only
4. MSK Connect
Managed Kafka Connect: runs connectors that move data into/out of Kafka without managing workers:
- Source connector: e.g. Debezium CDC from a database → topic
- Sink connector: topic → S3, OpenSearch, Redshift (via community/Confluent connectors)
- Worker auto scaling; pay per worker-hour
Also: Firehose can read from MSK → deliver into S3 (less operational overhead than running a sink connector when the destination is S3).
5. When to choose MSK? (preparing for the comparison in Part 4)
Choose MSK when the question contains these signals:
- Already uses Apache Kafka on-prem/self-managed → migrate with "minimal code changes" (clients stay the same)
- Needs the Kafka ecosystem: Kafka Connect, third-party Schema Registry, Kafka exactly-once transactions, compacted topics
- Needs very long retention with tiered storage, or custom per-partition throughput
- Multi-cloud/portability (avoiding API lock-in)
Choose Kinesis when: you want serverless native AWS, direct integration with Lambda/Firehose, and the team has no Kafka experience (details in Part 4 just below).
Part 4: Kinesis vs MSK — Choosing a streaming technology
1. Overall comparison table
| Axis | Kinesis Data Streams | Amazon MSK |
|---|---|---|
| Nature | Native AWS streaming service | Managed Apache Kafka |
| Unit | Shard (or on-demand) | Topic/partition, broker |
| Operations | Very low (on-demand ≈ zero) | Medium (provisioned) / low (Serverless) |
| Client | AWS SDK/KPL/KCL | Standard Kafka client (any Kafka-ecosystem language) |
| AWS integration | Very deep: Lambda ESM, Firehose, Flink, EventBridge Pipes | Good, but via connectors/Firehose (MSK source)/Lambda ESM |
| Retention | 24h → 365 days | Configurable; tiered storage → very long |
| Ordering | By partition key within a shard | By key within a partition |
| Exactly-once producer transactions | No (at-least-once, dedupe yourself) | Yes (Kafka transactions/idempotent producer) |
| Ecosystem | AWS services | Kafka Connect, ksqlDB, Debezium, Schema Registry... |
| Migration from existing Kafka | Must rewrite clients | Keep the code as is |
| Pricing | Shard-hour or GB (on-demand) | Broker-hour + storage, or serverless pay-per-use |
2. Exam cues — read the question, guess the answer
| Signal in the question | Choose |
|---|---|
| "already uses Apache Kafka", "minimal application changes" | MSK |
| "Kafka Connect / Debezium / compacted topic / ecosystem" | MSK |
| "fully managed, integrates with Lambda, no infrastructure" | Kinesis Data Streams |
| "unpredictable throughput, no capacity management" | KDS on-demand (or MSK Serverless if Kafka is mandatory) |
| "deliver to S3/Redshift/OpenSearch, near real-time, least ops" | Firehose (not KDS/MSK) |
| "replay events for multiple consumers" | KDS (retention) or MSK — eliminate Firehose/SQS |
| "simple decoupling, one consumer per message, no ordering need" | SQS (a common distractor) |
| "fan-out notifications to email/SMS/Lambda" | SNS |
| "route events by pattern to many targets, SaaS events, cron" | EventBridge |
3. Quickly eliminating SQS / SNS / EventBridge
| SQS | SNS | EventBridge | KDS/MSK | |
|---|---|---|---|---|
| Model | Queue (pull) | Pub/sub (push) | Event bus + rules | Stream (log) |
| Replay | No | No | Archive+replay available | Yes |
| Multiple consumers reading the same message | No (except fan-out via SNS) | Yes | Yes | Yes |
| Ordering | FIFO queue | FIFO topic | Not guaranteed | By key/partition |
| High analytics throughput | Limited (FIFO) | Not meant for data | Not meant for large volume | Yes |
Rule of thumb: high-volume data analytics/pipeline problems → Kinesis/MSK/Firehose. App integration/decoupling problems → SQS/SNS/EventBridge.
4. Typical streaming architectures
4.1 Standard AWS clickstream analytics
4.2 CDC → lakehouse
(Or: Debezium on MSK Connect → MSK → sink connector/Firehose.)
4.3 Real-time log analytics
4.4 IoT
5. Checklist for choosing a streaming service (use during the exam)
- Only need to deliver data to a destination (S3/Redshift/OpenSearch/Splunk)? → Firehose
- Need arbitrary real-time processing / many consumers / replay? → KDS (default)
- Is there a Kafka constraint (existing code, ecosystem, transactions)? → MSK
- Unpredictable workload? → the on-demand/serverless flavor of the choice above
- Is it app messaging, not a data pipeline? → SQS/SNS/EventBridge
Part 5: Managed Service for Apache Flink and Streaming ETL
1. Managed Service for Apache Flink
Overview
Formerly Kinesis Data Analytics (renamed 8/2023). A service that runs managed Apache Flink applications: stateful stream processing, low latency, exactly-once processing.
Key characteristics
- Stateful: keeps state (counts, sessions, join buffers) — automatically checkpointed to S3 → recovers with exactly-once processing on failure
- Scales by KPU (Kinesis Processing Unit = 1 vCPU + 4GB); auto scaling
- Billed per KPU-hour (runs continuously — not per invocation like Lambda)
- Use cases: windowed aggregation, anomaly detection, stream joins, sessionization — logic that a single Lambda struggles to get right
2. Windowing — an exam focus
| Window | Definition | Example |
|---|---|---|
| Tumbling | Fixed-size windows, non-overlapping | Sales every 5 minutes (00:00-00:05, 00:05-00:10) |
| Sliding (hopping) | Fixed-size windows that slide/overlap | "Last 5 minutes, updated every 1 minute" (moving average) |
| Session | Closes when inactivity exceeds the gap | User session: group events until idle for 15 minutes |
Tumbling (5m): |----W1----|----W2----|----W3----|
Sliding (5m/1m):|----W1----|
|----W2----|
|----W3----|
Session (gap): |--W1--| gap |----W2----| gap |W3|
Keywords: "every N minutes, non-overlapping" → tumbling; "last N minutes updated every M" / moving average → sliding; "user session / inactivity gap" → session.
- Event time vs processing time + watermark: handle late-arriving data by event time — Flink supports this fully (a strength compared with raw processing in Lambda)
3. Other streaming ETL options
Glue Streaming job
- Spark Structured Streaming (micro-batch, default ~100s window, adjustable) reading from Kinesis/Kafka
- A good fit when: the team already uses Glue/Spark, needs to write into the lake (including Iceberg/Hudi), and accepts seconds-to-minutes latency
- Also has checkpoints (stores the read position) for recovery
Lambda
- Per-batch, stateless processing from Kinesis/MSK — simple transform, routing, alerting
- Not suitable for: long windows, large state, stream joins — you would have to keep state externally (DynamoDB) → complex and error-prone
Choosing a stream processing tool
| Requirement | Choose |
|---|---|
| Windowed aggregation, sessionization, stream join, exactly-once | Managed Flink |
| Micro-batch ETL into a data lake (Parquet/Iceberg), Spark team | Glue streaming |
| Simple, stateless transform/filter/alert | Lambda |
| Only deliver + convert format | Firehose (with Lambda transform) |
| Interactive SQL to explore a stream | Managed Flink Studio notebook |
4. Reference architecture: real-time dashboard
5. Common confusions
- "Managed Flink" runs continuously and is billed per KPU-hour — a job that processes once a day is needlessly expensive → use batch (Glue) for that
- Flink reads from KDS/MSK — it does not replace the ingestion layer, it is the processing layer
- Kinesis Data Analytics for SQL (the legacy product) has been discontinued by AWS: no new applications since October 15, 2025, and remaining applications deleted starting January 27, 2026 — the current exam uses Managed Flink (Flink SQL/Table API replaces it)
- Flink's exactly-once is a processing semantic achieved through checkpoints + sinks that support transactional/idempotent writes; if the sink doesn't, duplicates can still appear in the output
Review Questions
-
A stream has 10 shards (provisioned). What is the maximum write throughput? If 3 consumers read in shared mode, how much does each consumer get?
Show answer
Write: 10 × 1 MB/s = 10 MB/s (or 10,000 records/s). Shared read: 2 MB/s per shard, shared among all 3 consumers (20 MB/s total across all consumers combined) → each consumer averages only ~0.66 MB/s/shard and easily hits ReadProvisionedThroughputExceeded. If each consumer needs its own 2 MB/s/shard → enhanced fan-out.
-
A producer gets
ProvisionedThroughputExceededExceptioneven though total traffic is below the stream's total capacity. Cause and fix?Show answer
Hot shard: a skewed partition key distribution makes 1 shard exceed 1MB/s while other shards sit idle. Fix: choose a higher-cardinality/more even partition key (e.g. add a random suffix), split the hot shard, or use backoff-retry in the producer. Switching to on-demand does not help if all records pile onto one key.
-
IteratorAgeMillisecondskeeps rising with a Lambda consumer. How do you fix it?Show answer
The consumer is falling behind the producer. Fixes: (1) raise the parallelization factor (up to 10 concurrent batches/shard), (2) add shards to increase total concurrency, (3) increase memory/optimize the Lambda code, (4) increase batch size to reduce per-invocation overhead, (5) check for a poison record causing repeated retries — set max retries + an on-failure destination. If iterator age exceeds retention, data is lost before it is processed.
-
An application needs per-device event ordering for thousands of IoT devices. How do you design the partition key?
Show answer
Use device_id as the partition key: all records from one device go to the same shard, so per-device ordering is preserved; thousands of devices provide enough cardinality to spread evenly across shards. Kinesis does not guarantee ordering across different partition keys — but the requirement is only per device, so it is satisfied.
-
When do you choose on-demand mode instead of provisioned?
Show answer
On-demand when traffic is unpredictable or spiky and you want to avoid resharding operations — pay per GB. Provisioned when traffic is steady/predictable — pay per shard-hour, usually cheaper at large, consistent volume. Keywords "unpredictable workload / least operational overhead" → on-demand; "steady, cost-effective" → provisioned.
-
What is KPL aggregation and what is the trade-off?
Show answer
KPL packs many user records into one Kinesis record (≤ 1 MiB by default, configurable up to 10 MiB) (aggregation) + batches many records into one PutRecords call (collection) → greatly increases throughput, lowers per-record cost. Trade-off: (1) extra latency from buffering (
RecordMaxBufferedTime), (2) the consumer must deaggregate (KCL does it for you), (3) not suitable for ultra-low latency requirements. -
Can Firehose replace Kinesis Data Streams when multiple consumers need to process the same data?
Show answer
No. Firehose is a one-way delivery service to a preconfigured destination; it does not store data and does not let arbitrary consumers read/replay. Multiple independent consumers (real-time app + analytics + archive) → Kinesis Data Streams (each consumer reads on its own, enhanced fan-out can be added), where one consumer can itself be Firehose for archiving.
-
Streaming JSON events must be stored in S3 as Parquet so Athena queries are cheap. Which solution has the least operational overhead?
Show answer
Firehose record format conversion: declare the schema in the Glue Data Catalog, enable JSON → Parquet conversion (with Snappy), and when the buffer fills it writes Parquet straight into S3 — no separate Glue conversion job needed. If the source isn't JSON, add a Lambda transform to convert it to JSON before the conversion step.
-
How do buffer hints work? What do you do to get data into S3 as fast as possible?
Show answer
Firehose flushes when it reaches the buffer size (e.g. 5MB) or the buffer interval (e.g. 300s) — whichever comes first. For maximum speed: set a small buffer interval, as low as 0 seconds (zero buffering) — delivery within a few seconds, at the cost of more small files on S3 (the small-files trade-off with Athena — compaction may be needed later).
-
A Lambda transform returns errors for some records. Is that data lost?
Show answer
No. ProcessingFailed records are written by Firehose to the S3 error output prefix (with error metadata) for later reprocessing. You can also enable source record backup to store all originals before transformation in a backup bucket. Failed delivery to the destination (e.g. OpenSearch down) is also retried and then falls back to the S3 backup — Firehose is designed not to lose data silently.
- How does Firehose write into Redshift?
Show answer
Not directly: Firehose first writes to intermediate S3, then issues a COPY command into Redshift (requires cluster, table, and IAM role configuration). So latency = buffer + COPY. This is also why, when you see "Firehose → Redshift" on the exam, you must remember it goes through S3 (and Redshift Serverless is supported too).
- Athena costs are rising because Firehose produces too many small files. How do you fix it?
Show answer
(1) Increase buffer size/interval so each object is larger; (2) enable format conversion to Parquet (compressed + columnar); (3) dynamic partitioning on the right query keys; (4) run periodic compaction (Glue job or Athena CTAS/OPTIMIZE with Iceberg). Small files increase both S3 request costs and query time.
- A company runs self-managed Kafka on EC2 and spends a lot of effort operating it. They want to reduce operations WITHOUT changing producer/consumer code. Solution?
Show answer
Amazon MSK — real Kafka, fully compatible clients: only the bootstrap servers + auth configuration change. Moving to Kinesis requires rewriting producers/consumers (different API) — violating "minimal code changes". If they also don't want to size a cluster → MSK Serverless.
- At what scope is message ordering guaranteed in Kafka? How do you keep per-customer ordering?
Show answer
Ordering is only guaranteed within a single partition. To keep per-customer ordering: use customer_id as the message key — Kafka hashes the key to the same partition, so all of a customer's messages stay in order. Exactly the same logic as the Kinesis partition key.
- How does MSK Serverless differ from MSK provisioned, and when do you choose it?
Show answer
Serverless: no broker/storage choices, scales automatically, pay per use (cluster-hour + partition-hour + GB), IAM-only auth — choose it when the workload is unpredictable or you want "least operational overhead". Provisioned: deep control over instances/storage/Kafka configuration (tiered storage, custom config), usually cheaper at high, steady throughput — choose it for large, consistent workloads that need the full feature set.
- You need CDC from MySQL into a Kafka topic without running Kafka Connect workers yourself. Solution?
Show answer
MSK Connect running a managed Debezium MySQL source connector: AWS manages the workers, with auto scaling. (Depending on the question, an alternative: DMS with a Kinesis/Kafka target.) If the final destination is S3 and Kafka isn't mandatory, DMS → S3 directly has even less operational overhead.
- What are the authentication options for MSK clients? Which has the least operational overhead?
Show answer
(1) IAM access control — auth/authz via IAM policies, no separate credentials to manage, least operational overhead (and the only option on MSK Serverless); (2) SASL/SCRAM — username/password stored in Secrets Manager; (3) mutual TLS — certificates from ACM Private CA, the most complex. All of them come with TLS in-transit.
- A startup is building a brand-new clickstream pipeline entirely on AWS; the team has never used Kafka and needs real-time aggregation + an S3 archive. Which stack?
Show answer
Kinesis Data Streams (on-demand if traffic is hard to predict) + Managed Service for Apache Flink for real-time aggregation + a Firehose consumer loading S3 as Parquet. Without a Kafka constraint, KDS wins thanks to native integration and low operations; MSK would add unnecessary operational cost and knowledge requirements.
- A company is migrating an on-prem Kafka system to AWS with dozens of producers/consumers running, requiring "minimal code changes" and lower operations. Solution?
Show answer
Amazon MSK — managed Kafka, clients stay the same (change bootstrap + auth). Use MSK Replicator/MirrorMaker 2 to sync data during cutover. Kinesis forces a rewrite of every client — wrong for the requirement. If the question adds "doesn't want to manage capacity" → MSK Serverless.
- Requirement: each message must be processed by exactly one worker once and then disappear, no ordering needed, no replay needed. Which service?
Show answer
SQS (standard queue) — a true queue model: a message is received by one consumer, processed, and deleted. Kinesis/MSK are streams for many consumers + replay — excess features, and the consumer must manage checkpoints itself. This is the classic "streaming vs queueing" elimination question.
- A pipeline must guarantee exactly-once from producer to topic (no duplicates on retry). Kinesis or MSK?
Show answer
MSK/Kafka — it has the idempotent producer and transactions that support exactly-once semantics within Kafka. The Kinesis producer is at-least-once (retries may create duplicates); the consumer must dedupe on its own (e.g. by unique ID). A question stressing end-to-end exactly-once leans toward Kafka (or handling it with Flink checkpointing + an idempotent sink).
- Sensor data must be kept for 90 days so new consumers can re-read from the beginning. Does Firehose meet this? What do you configure if you use KDS?
Show answer
Firehose does not — no storage/replay. Use KDS with extended retention (24h default → configurable up to 365 days; 90 days falls under long-term retention, with extra storage charges). Alternative: KDS with short retention + Firehose archive to S3, and new consumers re-read from S3 (backfill) — cheaper for 90 days.
- Compute "the average number of orders in the last 10 minutes, updated every minute" — which window type?
Show answer
Sliding (hopping) window: 10-minute size, sliding every 1 minute — the windows overlap, and every minute a result is emitted for the last 10 minutes. Tumbling only emits once every 10 minutes and does not overlap — it does not satisfy "updated every minute".
- Group a user's events into "sessions", where a session ends when the user is inactive for 30 minutes. Which window?
Show answer
Session window with a 30-minute inactivity gap — the window has no fixed size and closes itself when no new event arrives within the gap. This is the typical "sessionization" question that only Flink/stateful stream processors handle cleanly.
- Why is Lambda not suitable for a 30-minute windowed aggregation on Kinesis?
Show answer
Lambda is stateless per invocation: a 30-minute window needs to keep state across thousands of invocations → you would have to store it in DynamoDB/ElastiCache yourself, handle late data, and recover from failures — complex and error-prone. (Lambda tumbling windows support up to 15 minutes, but that is still limited.) Managed Flink is built for this: managed state, checkpoints, watermarks, exactly-once.
- A Flink app fails and restarts — is the data being processed counted twice?
Show answer
No (with the right configuration): Flink periodically checkpoints the state + source read position; on restart, the app restores from the latest checkpoint and re-reads from that offset → exactly-once processing for internal state. The output needs a transactional or idempotent sink to avoid duplicates end to end.
- The team wants to explore stream data with interactive SQL before writing the real application. Which tool?
Show answer
Managed Service for Apache Flink Studio — a managed Zeppelin notebook where you write interactive Flink SQL directly against Kinesis/MSK, then deploy the notebook as a continuously running application.
- JSON streamed from Kinesis must be written as an Iceberg table on S3 every ~1 minute, and the team is comfortable with PySpark. What is a sensible choice?
Show answer
Glue streaming job (Spark Structured Streaming): reads Kinesis, ~1-minute micro-batches, writes Iceberg natively (Glue 4.0/5.0), leveraging the existing PySpark skills. Flink can do it too (Iceberg sink), but if the team isn't familiar with Java/Flink, Glue streaming is the "path of least resistance"; Firehose can now write Iceberg tables but doesn't hold complex transform logic.
Hands-on Exercises
Part 1: Amazon Kinesis Data Streams
- Create an on-demand stream, use the CLI
aws kinesis put-recordandget-recordsto try out the record lifecycle - Attach a Lambda consumer with batch size 100, watch the IteratorAge metric in CloudWatch
- Calculate the number of shards needed for 5,000 records/s at 2KB per record (hint: the bottleneck is records/s → 5 shards)
- Read Kinesis Data Streams quotas
Part 2: Amazon Data Firehose
- Create a Direct PUT → S3 Firehose stream, buffer 60s, send a few records with the CLI
aws firehose put-record - Enable dynamic partitioning on the
event_typefield (jq) and check the prefix structure in S3 - Add a simple Lambda transform (adds a
processed_atfield) and inspect the output - Read Firehose record format conversion
Part 3: Amazon MSK and MSK Serverless
- Draw the Kafka ↔ Kinesis concept mapping (topic/stream, partition/shard, offset/sequence, consumer group)
- Read the MSK Serverless pricing and estimate the cost for 10 partitions at 1MB/s
- Sketch the pipeline: Debezium (MSK Connect) → MSK → Firehose → S3 Parquet
- Read MSK security
Part 4: Kinesis vs MSK — Choosing a streaming technology
- Redraw the 4 architectures in section 4 from memory and explain each component
- For each service (KDS, Firehose, MSK, SQS, SNS, EventBridge), write 1 sentence "choose it when..."
- Run through the section 5 checklist with 3 questions you make up yourself
- Read Best practices for MSK ↔ Kinesis selection (AWS blog streaming)
Part 5: Managed Service for Apache Flink and Streaming ETL
- Write Flink pseudo-SQL for a 5-minute tumbling window counting events by
event_type - Identify the window type for 5 requirements you make up yourself (at least 1 of each type)
- Compare costs: Flink with 2 KPUs running 24/7 vs Lambda with 1M invocations/day (rough estimate)
- Read Flink windowing concepts
References
- Kinesis Data Streams — key concepts
- Enhanced fan-out consumers
- Using Lambda with Kinesis
- Resharding a stream
- Amazon Data Firehose
- Buffering hints
- Dynamic partitioning
- Data transformation with Lambda
- Amazon MSK
- MSK Serverless
- MSK Connect
- MSK tiered storage
- Amazon Kinesis Data Streams FAQs
- Amazon MSK FAQs
- What is streaming data?
- EventBridge vs SNS vs SQS
- Amazon Managed Service for Apache Flink
- Managed Flink Studio
- Glue streaming ETL jobs
- Lambda with Kinesis — windows