This page requires JavaScript to display.
K
Unpacking...
← Cloud Platforms
Cloud Platforms

Amazon Kinesis for Data Engineers

Data Streams shards, producers and consumers; Firehose delivery with dynamic partitioning and Parquet conversion; monitoring, scaling and comparisons.

Contents
1. The Kinesis Family 2. Kinesis Data Streams 3. Amazon Data Firehose 4. Monitoring & Scaling 5. Common Interview Questions

1. The Kinesis Family

ServicePurpose
Kinesis Data StreamsDurable, ordered, replayable stream (shards); you write consumers
Amazon Data FirehoseFully managed delivery: buffers a stream and writes it to S3, Redshift, OpenSearch, Iceberg tables, Splunk or HTTP endpoints
Managed Service for Apache FlinkStateful stream processing (SQL, Java, Python) on Kinesis or MSK

2. Kinesis Data Streams

ConceptDetail
ShardUnit of capacity: up to 1 MB/s or 1,000 records/s in, 2 MB/s out (shared by standard consumers)
Partition keyHashed to choose the shard; records with the same key stay ordered
Sequence numberUnique, increasing per shard; consumers checkpoint by it
Retention24 hours by default, extendable up to 365 days
Capacity modesOn-demand (scales automatically) or provisioned (you choose shards and reshard)
Enhanced fan-outDedicated 2 MB/s per consumer per shard with push delivery and lower latency
import json, boto3

kinesis = boto3.client("kinesis")

def send(events: list[dict]) -> None:
    records = [{"Data": json.dumps(e).encode(), "PartitionKey": e["account_id"]} for e in events]
    for i in range(0, len(records), 500):  # PutRecords takes up to 500 records
        batch = records[i:i + 500]
        resp = kinesis.put_records(StreamName="txn-events", Records=batch)
        if resp["FailedRecordCount"]:  # partial failures do not raise
            retry = [r for r, res in zip(batch, resp["Records"]) if "ErrorCode" in res]
            kinesis.put_records(StreamName="txn-events", Records=retry)  # retry with backoff in real code
Consumer optionNotes
Lambda event source mappingSimplest; batch size, parallelization factor (up to 10 batches per shard), bisect on error
Kinesis Client Library (KCL)Java (and multi-language) library; leases and checkpoints in a DynamoDB table
Managed Service for Apache FlinkWindows, joins, state and exactly-once processing
Spark Structured Streaming / Glue streamingMicro-batch processing into the lake
FirehoseNo-code delivery to storage

Starting positions: TRIM_HORIZON (oldest available), LATEST, AT_TIMESTAMP, or AT_SEQUENCE_NUMBER. Replay by starting a consumer from an earlier position.

3. Amazon Data Firehose

Firehose buffers incoming records (by size or time) and writes batches to the destination, with optional Lambda transformation, format conversion to Parquet/ORC (using a Glue table schema), and dynamic partitioning based on record content:

{
  "BucketARN": "arn:aws:s3:::acme-lake-prod",
  "RoleARN": "arn:aws:iam::111122223333:role/firehose-to-s3",
  "Prefix": "raw/txn/channel=!{partitionKeyFromQuery:channel}/dt=!{timestamp:yyyy-MM-dd}/",
  "ErrorOutputPrefix": "raw/txn_errors/!{firehose:error-output-type}/dt=!{timestamp:yyyy-MM-dd}/",
  "BufferingHints": { "SizeInMBs": 128, "IntervalInSeconds": 300 },
  "CompressionFormat": "UNCOMPRESSED",
  "DynamicPartitioningConfiguration": { "Enabled": true },
  "ProcessingConfiguration": {
    "Enabled": true,
    "Processors": [{
      "Type": "MetadataExtraction",
      "Parameters": [
        { "ParameterName": "MetadataExtractionQuery", "ParameterValue": "{channel: .channel}" },
        { "ParameterName": "JsonParsingEngine", "ParameterValue": "JQ-1.6" }
      ]
    }]
  },
  "DataFormatConversionConfiguration": {
    "Enabled": true,
    "InputFormatConfiguration": { "Deserializer": { "OpenXJsonSerDe": {} } },
    "OutputFormatConfiguration": { "Serializer": { "ParquetSerDe": { "Compression": "SNAPPY" } } },
    "SchemaConfiguration": { "DatabaseName": "raw", "TableName": "txn", "RoleARN": "arn:aws:iam::111122223333:role/firehose-to-s3" }
  }
}

4. Monitoring & Scaling

MetricMeaning
GetRecords.IteratorAgeMillisecondsHow far behind consumers are; rising = they cannot keep up
WriteProvisionedThroughputExceededProducers are throttled: add shards, or fix a hot partition key
ReadProvisionedThroughputExceededToo many consumers on shared throughput: use enhanced fan-out
Firehose DeliveryToS3.DataFreshnessAge of the oldest record not yet delivered
Kinesis Data StreamsAmazon MSKSQS
ModelReplayable ordered streamReplayable ordered stream (Kafka)Queue: each message consumed once
OrderingPer shardPer partitionOnly FIFO queues (per group)
EcosystemAWS-nativeKafka APIs, Connect, StreamsAWS-native
Use whenAWS-only streaming with minimal opsKafka skills/tools, portability, high throughputDecoupling tasks and work queues

5. Common Interview Questions

QuestionShort answer
What is a shard, and what are its limits?The capacity unit of a stream: 1 MB/s or 1,000 records/s in and 2 MB/s out
How is ordering guaranteed?Per shard, by partition key; use a key such as account_id for related events
Data Streams vs Firehose?Data Streams is a replayable stream you consume yourself; Firehose is managed buffering and delivery to destinations, with no replay
Consumers are falling behind. What do you check?IteratorAge, consumer errors and duration, throttling, hot shards; add shards, enhanced fan-out or more parallelism
How do you land streaming data as Parquet in S3?Firehose with format conversion (Glue schema), dynamic partitioning and suitable buffering, or Spark/Flink writing a table format