By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
For AWS Solutions Architects who need to build, debug, and optimize real-time data pipelines in production.
You’re a cloud engineer at a fintech startup. Your team just built a fraud-detection system that processes 10,000 transactions per second. The legacy batch pipeline (dumping CSVs into S3 and running nightly Spark jobs) is too slow—by the time fraud is detected, the money is already gone.
Enter real-time streaming:- Amazon Kinesis (AWS’s managed streaming service) lets you ingest, process, and analyze data in milliseconds.- Amazon MSK (Managed Streaming for Kafka) gives you Apache Kafka as a service, if you need open-source compatibility or advanced Kafka features.
Why this matters in production:- If you ignore streaming, you’re stuck with batch processing (slow, high latency).- If you misconfigure it, you’ll either lose data (no durability) or blow up costs (over-provisioned shards).- If you don’t monitor it, you won’t know when your pipeline is silently failing (e.g., a producer stuck retrying).
Real-world scenario:You inherit a Kinesis Data Stream that’s dropping records during peak traffic. Your boss asks: - "Why is our fraud detection missing transactions?" - "Can we scale this without downtime?" - "How do we debug this without losing data?"
This guide gives you the exact steps to answer those questions.
user_id
transactions
aws --version
boto3
Build a pipeline that: 1. Ingests fake transaction data into Kinesis Data Streams.2. Processes it with Kinesis Data Analytics (SQL) to detect fraud.3. Delivers results to S3 via Firehose.
# Create a stream with 2 shards (handles ~2MB/s write, 4MB/s read) aws kinesis create-stream --stream-name fraud-detection-stream --shard-count 2 # Verify it's active (takes ~1 min) aws kinesis describe-stream --stream-name fraud-detection-stream
Expected output:
{ "StreamDescription": { "StreamName": "fraud-detection-stream", "StreamARN": "arn:aws:kinesis:us-east-1:123456789012:stream/fraud-detection-stream", "StreamStatus": "ACTIVE", "Shards": [...] } }
Production insight: If StreamStatus is CREATING, wait. If it’s DELETING, you have a problem.
StreamStatus
CREATING
DELETING
Create a Python script (producer.py) to send fake transactions:
producer.py
import boto3 import json import random import time kinesis = boto3.client('kinesis', region_name='us-east-1') def generate_transaction(): return { "transaction_id": str(random.randint(100000, 999999)), "user_id": f"user_{random.randint(1, 100)}", "amount": round(random.uniform(1.0, 1000.0), 2), "timestamp": int(time.time()) } while True: transaction = generate_transaction() kinesis.put_record( StreamName="fraud-detection-stream", Data=json.dumps(transaction), PartitionKey=transaction["user_id"] # Distributes records by user ) print(f"Sent: {transaction}") time.sleep(0.1) # ~10 records/sec
Run it:
python3 producer.py
Production insight: If you see ProvisionedThroughputExceededException, you need more shards.
ProvisionedThroughputExceededException
fraud-detection-analytics
fraud-detection-stream
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "FRAUD_ALERTS" SELECT STREAM user_id, COUNT() AS transaction_count, FLOOR("APPROXIMATE_ARRIVAL_TIME" TO SECOND) AS window_start FROM "SOURCE_SQL_STREAM_001" WINDOWED BY STAGGER ( PARTITION BY user_id RANGE INTERVAL '10' SECOND ) GROUP BY user_id, FLOOR("APPROXIMATE_ARRIVAL_TIME" TO SECOND) HAVING COUNT() > 3; ``` 6. Destination: Create a new Kinesis Firehose delivery stream (we’ll set this up next).7. Start the app.
Production insight: If the app fails, check CloudWatch Logs for SQL errors.
aws firehose create-delivery-stream \ --delivery-stream-name fraud-alerts-firehose \ --s3-destination-configuration '{ "RoleARN": "arn:aws:iam::123456789012:role/FirehoseDeliveryRole", "BucketARN": "arn:aws:s3:::your-fraud-alerts-bucket", "Prefix": "fraud-alerts/", "BufferingHints": { "SizeInMBs": 5, "IntervalInSeconds": 300 }, "CompressionFormat": "GZIP" }'
Production insight:- Buffering: Firehose waits until 5MB or 5 minutes before delivering to S3. Adjust based on your latency needs.- IAM Role: You need a role with permissions for Firehose to write to S3. Create one if missing.
fraud-alerts-firehose
s3://your-fraud-alerts-bucket/fraud-alerts/
.gz
IncomingBytes
IncomingRecords
IteratorAgeMilliseconds
DeliveryToS3.Success
DeliveryToS3.Records
Production insight: If IteratorAgeMilliseconds keeps rising, your consumers can’t keep up—scale your shards or optimize your app.
kinesis:PutRecord
kinesis:PutRecords
kinesis:GetRecords
kinesis:GetShardIterator
kinesis:DescribeStream
firehose:PutRecordBatch
IntervalInSeconds
app-name-environment-stream
fraud-detection-prod-stream
app-name-environment-firehose
fraud-detection-prod-firehose
Environment
Owner
Project
DeliveryToS3.FailedRecords
country
"A gaming company wants to analyze player behavior in real time. They need to process 5,000 events/sec, store raw data in S3, and run SQL queries on the stream. Which services should they use?"
Answer:1. Kinesis Data Streams (ingest 5,000 events/sec).2. Kinesis Data Analytics (SQL) (run real-time queries).3. Kinesis Firehose (deliver raw data to S3).
Why not MSK?- Overkill if they don’t need Kafka’s ecosystem.- More complex to manage.
Challenge:You have a Kinesis Data Stream with 1 shard. Your producer is sending 1,500 records/sec, but CloudWatch shows IncomingRecords at 1,000 records/sec and ProvisionedThroughputExceededException. Fix the throttling without losing data.
Solution:
# Scale to 2 shards (each shard handles 1,000 records/sec) aws kinesis update-shard-count \ --stream-name your-stream \ --target-shard-count 2 \ --scaling-type UNIFORM_SCALING
Why it works:- Each shard supports 1,000 records/sec write.- Scaling to 2 shards gives 2,000 records/sec capacity.- UNIFORM_SCALING splits existing shards evenly.
UNIFORM_SCALING
bash aws kinesis create-stream --stream-name my-stream --shard-count 2 aws kinesis put-record --stream-name my-stream --data "data" --partition-key "key" aws kinesis get-shard-iterator --stream-name my-stream --shard-id shardId-000000000000 --shard-iterator-type TRIM_HORIZON
bash aws firehose create-delivery-stream --delivery-stream-name my-firehose --s3-destination-configuration '{"BucketARN": "arn:aws:s3:::my-bucket", "RoleARN": "arn:aws:iam::123456789012:role/FirehoseRole"}'
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.