Ravindra BagaleCourses & study guides मराठी Track your progress

What Is Amazon Kinesis? Streaming Data on AWS Explained

Batch jobs wait for a file at midnight. Streaming apps react as events happen: clicks, GPS pings, payments. Amazon Kinesis is a family of services for ingesting and processing streaming data on AWS — pipes that never sleep.

What you'll learn in this chapter

  • Why streaming vs batch
  • Data Streams vs Firehose vs Data Analytics
  • Shards, producers, consumers
  • When to pick MSK or SQS instead
  • Lab, errors, FAQ, interview

1. Everyday example first

A cab app in Hyderabad emits location every few seconds. You cannot wait for nightly CSV. Producers write to a Kinesis data stream; consumers update ETAs and fraud checks in near real time. Firehose can also archive raw events to S3 for later Athena.

2. Why Kinesis?

Why do we need this?

Queues (SQS) are great for work tickets. Streams keep ordered records for multiple consumers over a retention window. Analytics and dashboards need that firehose of events.

3. What is in the Kinesis family?

What is it?

ServicePlain job
Data StreamsDurable real-time stream with shards
Data FirehoseLoad streams to S3/Redshift/OpenSearch with batching
Data Analytics / FlinkSQL/Flink processing on streams
Producers → Stream → Consumers / Firehose → S3Events every second
Near real-time + archive

4. How shards work (simple)

How to do it (step by step)

  1. A stream is split into shards; each shard has throughput limits.
  2. Partition key chooses the shard (e.g., rider_id).
  3. Consumers use iterators or enhanced fan-out.
  4. Scale shards when throttled (or use on-demand mode).
  5. Set retention (hours to days) for replay.
  6. Monitor IteratorAge — lagging consumers.
# Producer sketch (boto3 mental model)
# kinesis.put_record(
#   StreamName='rides',
#   Data=b'{"rider":"R1","lat":17.4}',
#   PartitionKey='R1')

5. Kinesis vs MSK vs SQS

ChoiceWhen
Kinesis Data StreamsAWS-native streaming, simple ops
Amazon MSKNeed Kafka ecosystem/tools
SQSTask queue, competing consumers, no long replay

6. Industries

  • Mobility: GPS + ETA
  • Fintech: payment event pipelines
  • IoT factories: sensor telemetry
  • Media: clickstream personalization

7. Lab: paper design + console click-tour

Do this in ap-south-1 (Mumbai) unless your org forbids it. Set a budget alert first.

How to do it (step by step)

  1. Define three event fields for a sample clickstream.
  2. Choose partition key and explain hot-shard risk.
  3. Decide Firehose vs custom consumer for S3 archive.
  4. In console, open Kinesis and note on-demand vs provisioned.
  5. Write alarm idea: IteratorAge > 60s.

Cleanup (stop billing)

  1. Delete any lab stream you created.
  2. Stop Firehose delivery streams to halt S3 put costs.

8. Common errors and fixes

Each row is a real mistake students and juniors hit. Read the fix before you panic.

Error / symptomFix
Hot shard from bad partition keyHigh-cardinality keys; avoid status=OK.
Consumer lag ignoredAlarm on IteratorAge.
PutRecord over 1MBSplit or compress carefully.
Firehose dynamic partitioning misconfigTest prefixes; monitor failures.
Retained data but no replay planDocument who replays how.
Used SQS but needed multiple replayable consumersPick a stream.
No encryptionEnable SSE (KMS).
Provisioned mode under-scaledOn-demand or reshard.
PII in cleartext eventsTokenize; encrypt fields.
Lambda consumer timeout loopsBatch size + bisect on error.

9. Troubleshooting checklist

  1. ProvisionedThroughputExceeded → scale or on-demand.
  2. AccessDenied on put → IAM kinesis:PutRecord.
  3. Empty consumers → check iterator / subscription.
  4. Firehose to S3 403 → bucket policy + role.
  5. Wrong region stream name.
  6. Clock skew on producers → NTP.

10. FAQ

Q. Is Kinesis Kafka?

Different product; MSK is Kafka. Kinesis is AWS-native streaming.

Q. Firehose without Streams?

Firehose can ingest directly from many sources.

Q. How long is data kept?

Configurable retention on streams.

Q. Exactly-once?

Plan for at-least-once; make consumers idempotent.

Q. Cost control tip?

On-demand carefully; compress; sample debug streams.

11. Interview Q&A

Q. What is a shard?

A throughput unit inside a data stream.

Q. Partition key purpose?

Routes records to shards; keep cardinality healthy.

Q. Streams vs Firehose?

Streams=raw durable stream; Firehose=managed delivery.

Q. IteratorAge?

How late consumers are.

Q. When MSK?

Need Kafka APIs/ecosystem.

Q. Idempotent consumer?

Same record twice does not double-apply.

12. Tips in English, Marathi and Hindi

Ravindra Bagale's Tip (EN)

Pick the partition key with a whiteboard, not with a coin flip. Hot shards wake you at 3 AM.

Ravindra Bagale's Tip (MR)

Partition key whiteboard वर ठरवा. Hot shards रात्री उठवतात.

Tip (HI)

Partition key व्हाइटबोर्ड पर चुनो — hot shards रात में जगाते हैं।

Try at home

  1. List five events your phone apps probably stream.
  2. Compare SQS vs Kinesis in five bullets.
  3. Sketch producer → stream → Lambda → DynamoDB.

In short

  1. Kinesis moves streaming data on AWS.
  2. Streams vs Firehose vs Analytics = ingest vs load vs process.
  3. Shards + partition keys decide scale and hotspots.
  4. Prefer idempotent consumers; watch IteratorAge.

Revision, interview and comparison cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Revision card: What is Amazon Kinesis?. Batch ETL every night is too late for fraud, clickstream, or IoT alarms. Kinesis ingests and processes streaming data in near real time (Data Streams, Firehose, Data Analytics). Producers PutRecords → stream shards → consumers (Lambda, Flink, Firehose to S3). POS scanners stream sales events; a consumer updates a live dashboard in seconds.
Revision card: What is Amazon Kinesis? · Download PNG · Open card page
Revision card: Shards and throughput. Too few shards throttle producers; too many waste cost. A shard is a capacity unit (ingest/egress limits). Scale with shard count or on-demand mode. Watch WriteProvisionedThroughputExceeded; split hot shards or use on-demand; pick good partition keys. All events with the same storeId key heat one shard — add more key entropy or split.
Revision card: Shards and throughput · Download PNG · Open card page
Revision card: Streams vs Firehose. You may only need S3/Redshift delivery without custom consumers. Data Streams: real-time consumers you build. Firehose: managed delivery to S3/OpenSearch/Redshift with buffering. Use Streams for fraud scoring Lambda; Firehose to land raw JSON in S3 for later Athena. Clickstream Firehose buffer 60s → parquet in s3://lake/clicks/.
Revision card: Streams vs Firehose · Download PNG · Open card page
Revision card: Ordering and retries. At-least-once delivery means duplicates; wrong key loses per-user order. Same partition key preserves order inside a shard. Consumers must be idempotent. Include eventId; dedupe in DynamoDB; do not assume exactly-once from the stream alone. Payment tip events for one bill share billId key so sequence stays correct.
Revision card: Ordering and retries · Download PNG · Open card page
Revision card: Secure the stream. Open producers or plaintext data invite abuse and leaks. Encrypt with KMS; IAM on PutRecords/GetRecords; VPC interface endpoints when required. Producers get put on one stream ARN; consumers get get/list; enable CloudWatch metrics. Compromised laptop without the producer role cannot PutRecords to prod stream.
Revision card: Secure the stream · Download PNG · Open card page
Comparison: Kinesis Data Streams vs Kinesis Data Firehose. Kinesis Data Streams: Real-time consumers you build (Lambda/Flink). Kinesis Data Firehose: Managed delivery to S3/OpenSearch/Redshift.
Comparison: Kinesis Data Streams vs Kinesis Data Firehose · Download PNG · Open card page
Comparison: Provisioned shards vs On-demand mode. Provisioned shards: You pick shard count; risk throttle or waste. On-demand mode: AWS scales ingest capacity with traffic.
Comparison: Provisioned shards vs On-demand mode · Download PNG · Open card page
Interview card: When choose Kinesis?. When you need near-real-time ingest/processing of event streams at scale. Nightly batch alone is not enough for fraud/IoT alerts. POS clickstream to live dashboard.
Interview card: When choose Kinesis? · Download PNG · Open card page
Interview card: What is a shard?. A capacity unit with ingest/egress limits; scale count or use on-demand. Hot partition keys cause throttling on one shard. WriteProvisionedThroughputExceeded → split or on-demand.
Interview card: What is a shard? · Download PNG · Open card page
Interview card: Streams vs Firehose?. Streams for custom real-time consumers; Firehose for managed delivery to S3/analytics stores. Often use both in one pipeline. Fraud Lambda on Streams; raw land on S3 via Firehose.
Interview card: Streams vs Firehose? · Download PNG · Open card page
Interview card: Lambda as stream consumer?. Event source mapping polls shards; set batch size, window, and on-failure destination; make handler idempotent. Bisect batch on error to find poison records. Failed batch → SQS DLQ with the partition key and sequence.
Interview card: Lambda as stream consumer? · Download PNG · Open card page

More cards: Ravi Sir's Cards.

Practice Tasks

About this scenario

Nairobi Ride is a transport business in Nairobi. Wanjiru Kamau looks after its IT and cloud work. They count money in KES and run their AWS resources in the af-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 16

Easy List streams

Why: See data streams.

What to do: List Kinesis streams.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Describe stream

Why: Shard count.

What to do: Describe stream nairobiride-rides.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy List delivery streams

Why: Delivery inventory.

What to do: List Firehose delivery streams.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Shard write MB/s classic

Why: Throughput unit.

What to do: Classic shard write capacity MB/s often taught (enter 1)?

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy SQS is not a stream — 0

Why: Pick right tool.

What to do: Is SQS the same as a Kinesis stream? Enter 0 for no.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Partition key required — 1

Why: Routing.

What to do: Enter 1 if put-record needs a partition key.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Put record

Why: Producer write.

What to do: Put record on nairobiride-rides partition key R1 data file://e.json.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Describe delivery stream

Why: Check destination.

What to do: Describe delivery stream nairobiride-to-s3.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Stream summary

Why: Faster than full describe.

What to do: Describe stream summary nairobiride-rides.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium GetRecords

Why: Consumers.

What to do: Allow kinesis:GetRecords on arn:aws:kinesis:af-south-1:104591109902:stream/nairobiride-rides.

How:
  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Medium Event JSON

Why: Sample payload.

What to do: JSON rider R1 lat 17.4.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.

Medium IteratorAge alarm seconds sample

Why: Lag alarm.

What to do: Sample IteratorAge alarm threshold seconds (enter 60)?

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard List shards

Why: Inspect hotspots.

What to do: List shards on nairobiride-rides.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Delete stream

Why: Stop lab cost.

What to do: Delete stream nairobiride-lab.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard PutRecord on one stream

Why: Producers scoped.

What to do: Allow kinesis:PutRecord on arn:aws:kinesis:af-south-1:104591109902:stream/nairobiride-rides.

How:
  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Hard Retention hours JSON

Why: Replay window.

What to do: JSON RetentionHours 24.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.