Lesson 2 of 3 Data Analytics and Machine Learning Architectures

Choosing Streaming Ingestion and Processing Services

This lesson explains how differences in ordering, retention, replay and management effort decide which AWS streaming service fits a scenario for acting on continuously arriving data within seconds.

Learning outcomes

After completing this lesson, you will be able to:

  • Compare Kinesis Data Streams, MSK, Firehose and Flink.
  • Explain ordering, partition key and replay considerations.
  • Design real-time scoring with archival.

Streaming services compared

The streaming services take different approaches. Kinesis Data Streams stores records in shards, ordered per partition key and retained for 24 hours to 365 days, so several consumers can read independently and replay. It suits custom real-time processing on AWS. Amazon Data Firehose is fully managed delivery, buffering, transforming and converting streams into S3, Redshift, OpenSearch, Splunk or HTTP endpoints, with no consumer code. Amazon MSK, including MSK Serverless, runs Apache Kafka, which suits existing Kafka applications and tools, very long retention and Kafka Connect.

Managed Service for Apache Flink performs stateful processing on streams, in SQL, Java or Python, for windowed aggregations, joins and anomaly detection. Amazon SQS is a queue, not a stream: each message is deleted after processing, so it suits distributing work where replay and multiple readers are not needed. The following table summarises the services.

ServiceModelChoose when
Kinesis Data StreamsShards with ordered records per partition key; 24 hours to 365 days retention; multiple consumers, replayCustom real-time processing, several independent consumers, AWS-native
Amazon Data FirehoseFully managed delivery with buffering, transformation, format conversionLoading streams into S3, Redshift, OpenSearch, Splunk or HTTP with no consumer code
Amazon MSK (and MSK Serverless)Managed Apache KafkaExisting Kafka applications or ecosystem tools, very long retention, Kafka Connect
Managed Service for Apache FlinkStateful stream processing in SQL, Java, PythonWindowed aggregations, joins, anomaly detection on streams
Amazon SQSQueue, not a stream; messages deleted after processingWork distribution where replay and multiple readers are not needed

Design considerations

Ordering is guaranteed only within a shard in Kinesis, or a partition in Kafka, and the partition key decides where each record goes. A good key keeps related events together, such as all events for one card in a fraud system, while spreading load evenly; a key with few values creates hot shards. Throughput is sized per shard: a Kinesis shard accepts 1 MB or 1,000 records per second of writes, and on-demand mode adds shards automatically as traffic grows.

Fan-out needs attention when several applications read the same stream, because standard consumers share each shard's 2 MB per second of reads; enhanced fan-out gives each registered consumer its own 2 MB per second. Streams deliver at least once, so exactly-once outcomes require idempotent consumers or Flink's checkpointing. Events also arrive late or out of order, for example from devices that were offline, and correct results then require processing by event time with windows, which Managed Service for Apache Flink provides.

1MB/s

Writes per Kinesis shard

1,000records/s

Writes per Kinesis shard

2MB/s

Reads per shard, shared by standard consumers

Worked example

Real-time fraud scoring and archival

A payments company must score each card transaction for fraud within two seconds, alert on suspicious patterns per card over five-minute windows, and keep every event for seven years for audit. One stream feeds three consumers:

Payment API ──► Kinesis Data Streams (partition key = card ID, on-demand, 7-day retention)
                   ├─► Lambda (enhanced fan-out): call SageMaker endpoint, block high scores   < 2 s
                   ├─► Managed Service for Apache Flink: 5-minute windows per card ──► EventBridge alerts
                   └─► Firehose: convert to Parquet, partition by date ──► S3 (Object Lock, lifecycle to Glacier)

Partitioning by card ID keeps each card's events in order for the windowed analysis. Firehose needs no code for the archive path, and S3 Object Lock satisfies the immutability requirement. If the company already ran Kafka with in-house tooling, MSK would replace Kinesis with little change to the rest of the design.

Check yourself

When is Amazon Data Firehose enough on its own, without Kinesis Data Streams?

Show answer

When data only needs to be delivered to a destination such as S3 or OpenSearch, with buffering and optional transformation, and no custom consumers or replay are needed.

Exam Tips

Remember for the exam

  • To deliver streaming data to S3, Redshift or OpenSearch without code, use Firehose.
  • For several independent consumers and replay, use Kinesis Data Streams.
  • For existing Kafka applications, use Amazon MSK.
  • For windowed aggregations and stateful stream processing, use Managed Service for Apache Flink.
  • Choose partition keys that preserve the ordering you need while spreading load.
  • For dedicated read throughput per consumer, use enhanced fan-out.