The full answer
Connect Lambda to the stream with an event source mapping, have it transform each batch, and let Amazon Data Firehose buffer the results and write them to S3 as Parquet. Writing Parquet from Lambda directly is possible, but it produces many small files and duplicates on retries, so Firehose (or a periodic compaction) is the usual design.
1. The stream
- A Kinesis data stream in on-demand mode (it scales shards automatically) or provisioned mode with enough shards: each shard takes 1 MB or 1,000 records per second of writes.
- Producers choose a partition key that spreads load, such as a device ID.
2. Lambda as the processor
- An event source mapping polls each shard and invokes the function with a batch of records. Set the batch size and a batching window (up to 5 minutes) so each call gets a useful amount of data.
- Records in a shard are processed in order, and a failing batch blocks its shard. So configure bisect batch on error, maximum retry attempts and an on-failure destination (an SQS queue or SNS topic), and return partial batch failures so only failed records are retried.
- Processing is at least once, so the code must be idempotent: the same record arriving twice must not produce a different result.
- ParallelizationFactor (1 to 10) processes one shard with several concurrent invocations if Lambda falls behind; watch the IteratorAge metric for that.
3. Firehose to S3 as Parquet
- The function writes its transformed records, as JSON, to a Firehose stream with
PutRecordBatch. - Firehose record format conversion turns JSON into Parquet using the schema of a table in the Glue Data Catalog, buffers by size and time, and writes larger files.
- Use dynamic partitioning or an S3 prefix with the event date (for example
year=!{timestamp:yyyy}/month=!{timestamp:MM}/) so queries can skip partitions.
A simpler variant: if the transformation is light, skip the separate Lambda consumer and use Firehose with Kinesis Data Streams as its source and a Lambda transformation function attached; Firehose then reads the stream, calls Lambda for each buffer and converts to Parquet itself.
4. Query
- Register the table in the Glue Data Catalog (with partition projection for date partitions) and query with Athena or Redshift Spectrum.
- If you want Iceberg tables instead of plain Parquet, Firehose can deliver to Iceberg tables, which also handles compaction and schema changes.
Things to say in an interview: small files and duplicates are the two classic problems in this design; Firehose buffering and idempotent processing are the answers. For heavy stateful logic (windows, joins across streams), use Managed Service for Apache Flink instead of Lambda.
Last updated 16 October 2026