AWS Kinesis Data Streams — Bare Essentials for DVA-C02


1. Kinesis Data Streams Basics

Kinesis Data Streams is used for real-time streaming data.

Examples: - IoT sensor data - Clickstream data - Logs - Financial transactions

Data is stored in Shards.

Think of a shard as an independent lane that stores and serves records.


2. What is a Shard?

Every shard provides fixed capacity.

Each shard supports:

More shards = - More write capacity - More read capacity - More parallel processing


3. Partition Key

Every record must have a Partition Key.

Kinesis hashes the partition key to decide which shard stores the record.

Example:

Customer123
Customer123
Customer123

All go to the same shard.


4. Hot Shard

If one partition key receives much more traffic than others,

→ One shard becomes overloaded.

This causes

Fix:

Example:

Instead of

Customer123

Use

1-Customer123
2-Customer123
3-Customer123

Traffic spreads across multiple shards.


5. Resharding

When traffic increases,

you can increase shards.

Example

4 shards
↓

8 shards

Important for the exam:

Lambda automatically detects new shards.

No redeployment.

No configuration change.

No manual updates.


6. Ordering Guarantee

Kinesis guarantees ordering

ONLY inside a single shard.

Not across shards.

Example

Shard A

1
2
3

Always processed in order.

Shard B

A
B
C

Also ordered.

But

1
A
2
B

can happen because shards are processed independently.


7. Lambda + Kinesis

Lambda polls Kinesis automatically.

Important rules:

Example

3 shards

↓

3 concurrent Lambda executions

8. Parallelization Factor

Normally

1 Lambda per shard

You can increase the Parallelization Factor.

Example

5 shards

Parallelization Factor = 2

↓

Up to 10 concurrent Lambda executions

Useful when consumers fall behind.


9. Iterator Age

Iterator Age tells you

How far behind the consumer is.

Small value

✅ Consumer is keeping up.

Growing value

❌ Consumer is too slow.

Fixes:


10. Enhanced Fan-Out (EFO)

Normally,

all consumers share the shard's read throughput.

With Enhanced Fan-Out,

each consumer gets

Best when


11. Server-Side Encryption

Kinesis supports encryption at rest.

Enable

Server-Side Encryption (SSE)

using

AWS KMS

You can use

Exam answer:

Enable SSE with a KMS Customer Managed Key.


12. ProvisionedThroughputExceededException

Means a shard exceeded its capacity.

Common fixes:

✅ Add more shards

✅ Use better partition keys

✅ Use random partition key prefixes

Do NOT think of:

Those do not solve hot shards.


13. DynamoDB Hot Partition (Often Asked Together)

Exactly the same idea as a hot shard.

One partition key receives most writes.

Symptoms:

Fix:

Write Sharding

Example

Instead of

Device123

Use

Device123-1
Device123-2
Device123-3

Reads combine results.


14. DynamoDB Query vs Scan

For

Partition Key + Sort Key

Always use

Query

Example

CustomerId = 100

OrderDate BETWEEN A AND B

Never use Scan unless absolutely necessary.


15. Exam Memory Tricks

Lambda after Resharding

✅ Automatically detects new shards


Ordering

✅ Ordered within a shard

❌ Not ordered across shards


Iterator Age Growing

Consumer is slow.

Fix:


Enhanced Fan-Out

Dedicated

2 MB/sec per consumer per shard


Hot Shard

One partition key sends too much traffic.

Fix:


Encryption

Enable

Server-Side Encryption + KMS CMK


Query vs Scan

Need Partition Key + Date Range?

✅ Query

❌ Scan