Lesson 2 of 4 Amazon Kinesis and Streaming Services

Loading Streaming Data with Amazon Data Firehose

This lesson explains how Amazon Data Firehose, formerly Kinesis Data Firehose, loads streaming data into storage and analytics services with no consumer code to write or scale.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe Firehose destinations.
  • Explain how Lambda transformation and format conversion change data in transit.
  • Describe how Kinesis Data Streams and Firehose combine in a pipeline.

What Firehose does

Amazon Data Firehose is a fully managed service that delivers streaming data to storage and analytics destinations: Amazon S3, Amazon Redshift, through S3 and the COPY command, Amazon OpenSearch Service, Splunk, Apache Iceberg tables, HTTP endpoints and partner services. Data arrives from direct PUT requests, Kinesis Data Streams, Amazon MSK or CloudWatch Logs subscriptions.

Firehose scales automatically, with no shards or capacity to manage, and is billed per gigabyte ingested. It buffers data by size and by time, up to 900 seconds, before delivering it, so delivery is near real time rather than immediate. Along the way it can transform records with Lambda and convert them to Parquet.

Transforming data on the way

Firehose can change data on its way to the destination, which removes the need for a separate processing step. A Lambda transformation receives batches of records and can filter, enrich or reformat them. Format conversion turns JSON into the columnar Parquet or ORC formats, using a schema from the Glue Data Catalog, which makes later queries with Athena much faster and cheaper. Compression, such as GZIP or Snappy, reduces storage and query cost.

Dynamic partitioning writes each record to an S3 prefix based on its own fields, such as customer and date, so queries can skip irrelevant data. Backup writes records that could not be delivered, or optionally every source record, to an S3 bucket, so no data is lost. The following table summarises the features.

FeatureUse
Lambda transformationFilter, enrich or reformat records
Format conversionJSON to Parquet or ORC, using a Glue table schema
CompressionGZIP, Snappy and others, to cut storage and query cost
Dynamic partitioningWrite records to S3 prefixes based on their fields, such as customer or date
BackupFailed records, or all source records, to an S3 bucket
Match the pairs

Firehose transformations

Exam skills 3.5.7 · 3.5.6

Match each requirement with the Firehose feature that meets it.

Log in to try this activity Interactive activities are free with an account.

Common pipeline

Kinesis Data Streams and Firehose are often combined in one pipeline, each doing what it does best. Producers write to a Kinesis data stream, from which real-time consumers, such as a fraud-detection application, read with sub-second latency. Firehose reads the same stream as another consumer and delivers the data to Amazon S3 as partitioned Parquet files, where Amazon Athena queries it.

Firehose alone would not suffice, because it offers no replay and no custom consumers; those capabilities need Kinesis Data Streams. Kinesis Data Streams alone would require custom code to write files to S3, which Firehose provides with no code.

The following diagram shows the combined pipeline.

A common streaming pipeline. Producers write to a Kinesis data stream. A real-time consumer, such as a fraud detection application, reads it with sub-second latency, while Amazon Data Firehose reads the same stream as another consumer and delivers partitioned Parquet files to Amazon S3, where Athena queries them.
Each consumer reads the stream independently, so the real-time path and the delivery path do not slow each other.
True or false

Firehose and Kinesis together

Exam skills 3.5.2

Check how Firehose and Kinesis Data Streams combine.

Log in to try this activity Interactive activities are free with an account.
Worked example

A clickstream pipeline

A clickstream pipeline combines several streaming and storage services. The following table identifies the service that meets each requirement.

RequirementService
Collect clicks from the website in real timeKinesis Data Streams
Detect sudden traffic spikes per page over 1-minute windowsManaged Service for Apache Flink
Store every click in S3 as Parquet, partitioned by dateAmazon Data Firehose
Query the history with SQLAmazon Athena

If the company already runs Apache Kafka, Amazon MSK would replace Kinesis Data Streams with little change to the rest. Firehose is the answer whenever data must be delivered to a destination with no consumer code.

Check yourself

Can Firehose convert JSON records to Parquet before writing them to S3?

Show answer

Yes. Record format conversion turns JSON into Parquet or ORC using a schema in the Glue Data Catalog, which makes Athena queries cheaper.

Exam Tips

Remember for the exam

  • To load streaming data into S3, Redshift or OpenSearch without code, use Firehose.
  • To convert streaming JSON to Parquet for Athena, use Firehose format conversion.
  • Firehose is near real time, because it buffers; processing within milliseconds needs Data Streams or Flink.
  • To land streaming data in S3 partitioned by date or customer, use Firehose with dynamic partitioning.