Amazon Data Firehose

Serverless "streaming ETL for landing zones": a buffer that takes records from a producer, optionally transforms them via Lambda, and writes them to S3 / Redshift / OpenSearch / Splunk / HTTP. No shards, no consumers, no code to run. Near real-time, not real-time — smallest buffer window is 60 seconds (S3 direct-PUT with zero-buffer optimizations aside).

"ETL streaming serverless để đổ vào landing zone": buffer nhận record từ producer, có thể transform qua Lambda, và ghi vào S3 / Redshift / OpenSearch / Splunk / HTTP. Không shard, không consumer, không code chạy. Gần real-time, không phải real-time — cửa sổ buffer nhỏ nhất là 60 giây (S3 direct-PUT có tối ưu zero-buffer riêng).

Reach for itNên dùng

  • "Get logs / events into S3 with zero infra to babysit""Đổ log / event vào S3 mà không phải trông infra"
  • JSON → Parquet/ORC conversion for cheap Athena queriesJSON → Parquet/ORC để query Athena rẻ
  • Fan-out endpoint for SNS or CloudWatch Logs into a data lakeEndpoint fan-out cho SNS hoặc CloudWatch Logs vào data lake
  • Loading Redshift/OpenSearch/Splunk without a custom ingesterLoad Redshift/OpenSearch/Splunk mà không viết ingester

Not the right toolKhông hợp

  • Sub-second latency — Firehose is near-real-time (60 s+ buffer)Cần latency dưới giây — Firehose là gần real-time (buffer 60 s+)
  • Replay / long retention — Firehose doesn't store; use KDSReplay / retention dài — Firehose không lưu; dùng KDS
  • Multiple independent consumers on the same feed — Firehose has one sink pipelineNhiều consumer độc lập trên cùng feed — Firehose có 1 pipeline sink
  • Anything reading from Firehose (KCL, Spark, Flink) — Firehose is delivery-only, no consumer APIBất kỳ thứ gì đọc từ Firehose (KCL, Spark, Flink) — Firehose chỉ deliver, không có API consumer

Sources & sinks (fixed list)Source & sink (danh sách cố định)

Memorise both lists. Exam questions often hinge on "can Firehose deliver to X?" or "can X send into Firehose?" Học thuộc cả 2 danh sách. Câu hỏi thi hay xoáy vào "Firehose deliver được sang X không?" hoặc "X đẩy được vào Firehose không?"

SourcesNguồn SinksĐích
YesĐược Direct PUT (SDK / Kinesis Agent / CloudWatch Logs subscription / CloudWatch Events / IoT rule), Kinesis Data Streams, Amazon MSK, SNS (native subscription). PUT trực tiếp (SDK / Kinesis Agent / CloudWatch Logs subscription / CloudWatch Events / IoT rule), Kinesis Data Streams, Amazon MSK, SNS (subscription native). S3, Redshift (COPY through an S3 stage), OpenSearch, Splunk, generic HTTP endpoint, third-party partners (Datadog, New Relic, MongoDB, Coralogix, Elastic…). S3, Redshift (COPY qua S3 stage), OpenSearch, Splunk, HTTP endpoint, partner (Datadog, New Relic, MongoDB, Coralogix, Elastic…).
NoKhông SQS (poll for you? no — go SQS → Lambda → Firehose), EventBridge (route to Firehose is not a native target — go via Lambda/Pipes). SQS (Firehose không tự poll — đi SQS → Lambda → Firehose), EventBridge (Firehose không là target native — đi qua Lambda/Pipes). KDS, MSK/Kafka, DynamoDB, RDS, EMR, Athena, SNS/SQS — none are Firehose sinks. Also no direct write to Lambda (Lambda is the transformer, not the sink). KDS, MSK/Kafka, DynamoDB, RDS, EMR, Athena, SNS/SQS — không cái nào là sink Firehose. Cũng không ghi thẳng vào Lambda (Lambda là transformer, không phải sink).

Buffer sizingKích thước buffer

Every stream has a Size threshold and a Time threshold you set at creation. Whichever hits first triggers a flush. Firehose can auto-scale the buffer size upward when throughput bursts. Mỗi stream có ngưỡng Size và ngưỡng Time đặt lúc tạo. Cái nào đạt trước sẽ flush. Firehose tự nâng ngưỡng Size khi throughput dồn.

  • Size — configurable range (you pick a value inside this band, not defaults): 1–128 MiB for S3, 1–100 MiB for Redshift / OpenSearch / Splunk / HTTP. Defaults shown in the console are around 5 MiB.Size — dải cấu hình (bạn chọn 1 giá trị trong dải này, không phải mặc định): 1–128 MiB cho S3, 1–100 MiB cho Redshift / OpenSearch / Splunk / HTTP. Console mặc định gợi ý khoảng 5 MiB.
  • Time — configurable range: 60–900 s for most sinks. Default is around 300 s (5 min). S3 sink supports a 0-second zero-buffering mode for real-time-ish delivery (Dec 2023).Time — dải cấu hình: 60–900 s cho hầu hết sink. Mặc định khoảng 300 s (5 phút). Sink S3 hỗ trợ mode 0 giây zero-buffer để deliver gần real-time (12/2023).
  • Rule of thumb: high throughput → Size hits first; low throughput → Time hits first. Small time = many small S3 objects (pay per PUT + hurts Athena); big time = high latency.Nguyên tắc: throughput cao → Size chạm trước; thấp → Time chạm trước. Time nhỏ = nhiều object S3 nhỏ (tốn PUT + Athena chậm); time lớn = latency cao.
Concrete examplesVí dụ cụ thể
  • Log firehose from a busy web tier (New-Relic-ish): Size 64 MiB, Time 60 s. At ~5 MiB/s ingest, the buffer fills in ~13 s → Size wins; flushes every 13 s in fat S3 objects (great for Athena scans).Log firehose từ web tier bận (kiểu New Relic): Size 64 MiB, Time 60 s. Ingest ~5 MiB/s, buffer đầy sau ~13 s → Size thắng; flush mỗi ~13 s ra object S3 to (rất hợp Athena scan).
  • Trickle stream from a low-volume IoT device: Size 32 MiB, Time 300 s. At 20 KiB/s, Size would take ~27 min (32,768 KiB ÷ 20); Time (5 min) wins first → predictable 1 flush every 5 min.Stream nhỏ giọt từ thiết bị IoT low-volume: Size 32 MiB, Time 300 s. Ingest 20 KiB/s, Size mất ~27 phút (32,768 KiB ÷ 20); Time (5 phút) chạm trước → mỗi 5 phút flush 1 lần, ổn định.

Transformations & format conversionTransformation & format conversion

A Lambda function can rewrite records in-flight (CSV → JSON, redact PII, enrich, split). For JSON → Parquet/ORC there's a built-in converter — no Lambda needed. Both work only per record, no aggregation across records. Lambda có thể rewrite record giữa đường (CSV → JSON, xoá PII, enrich, split). JSON → Parquet/ORC có converter built-in — không cần Lambda. Cả hai chỉ chạy trên từng record, không gộp giữa các record.

  • Firehose calls Lambda with a batch of records. Function returns each record marked Ok, Dropped, or ProcessingFailed. Failed records go to the S3 backup bucket under a processing-failed/ prefix.Firehose gọi Lambda với 1 batch record. Function trả từng record với Ok, Dropped, hoặc ProcessingFailed. Record fail vào backup bucket S3 dưới prefix processing-failed/.
  • "Blueprints" = AWS-provided Lambda starter templates in the Firehose console. You pick one instead of writing from scratch — common ones: Apache Log → JSON, Syslog → JSON, CloudWatch Logs → decompressed JSON, General Firehose Processing. All shown when you click "Create new" on the transformer step."Blueprint" = template Lambda có sẵn trong console Firehose. Chọn 1 cái thay vì viết từ đầu — hay dùng: Apache Log → JSON, Syslog → JSON, CloudWatch Logs → JSON đã unzip, General Firehose Processing. Hiện lên khi bấm "Create new" ở bước transformer.
  • Parquet/ORC conversion needs a Glue Data Catalog table for the schema. S3 destination only — you can't Parquet-convert into Redshift or OpenSearch.Parquet/ORC cần bảng Glue Data Catalog để có schema. Chỉ dùng cho sink S3 — không convert Parquet vào Redshift hay OpenSearch.
  • Compression for S3: GZIP, Snappy, Zip (and Snappy for Parquet). If output goes on to Redshift via COPY, only GZIP works.Nén cho S3: GZIP, Snappy, Zip (và Snappy cho Parquet). Nếu đưa tiếp vào Redshift qua COPY, chỉ GZIP.
What Parquet / ORC actually areParquet / ORC là gì thực sự Columnar storage formats — instead of writing one JSON row after another (row-oriented), values from the same column are grouped together on disk. Payoff: Athena / Spark / Redshift Spectrum can read only the columns your query mentions and skip the rest → 5–20× cheaper scans and much smaller files thanks to column-aware compression. Parquet comes from the Hadoop world (used by everything: Spark, Athena, Snowflake); ORC is Hive-native and slightly better on Hive/Tez but rarer outside that stack. For an AWS lake, default to Parquet + Snappy. Định dạng cột — thay vì ghi từng row JSON nối nhau (row-oriented), các giá trị cùng cột được gom lại trên đĩa. Lợi: Athena / Spark / Redshift Spectrum chỉ đọc đúng những cột trong query và bỏ phần còn lại → scan rẻ hơn 5–20× và file nhỏ hơn nhiều nhờ nén theo cột. Parquet ra từ hệ sinh thái Hadoop (mọi thứ dùng: Spark, Athena, Snowflake); ORC gốc Hive, tốt hơn chút trên Hive/Tez nhưng ít phổ biến hơn. Trên AWS lake, mặc định chọn Parquet + Snappy.

Delivery failures & backupDelivery fail & backup

Firehose retries with backoff for a bounded window per destination. Whatever still fails goes to the S3 backup bucket under prefixes that tell you why. Firehose retry có backoff trong cửa sổ giới hạn theo từng đích. Cái nào vẫn fail sẽ vào S3 backup bucket theo prefix cho biết lý do.

DestinationĐích Retry windowCửa sổ retry On give-upKhi bỏ cuộc
S3Retries until successRetry tới khi thành côngDelivery does not fail (S3 is durable)Không fail (S3 bền)
Redshift0 s – 2 h (7,200 s)Skips manifest, files stay in S3 stage → replayBỏ manifest, file vẫn ở S3 stage → replay
OpenSearch0 s – 2 h (7,200 s)Failed docs → S3 backup (opensearch-failed/)Doc fail → S3 backup (opensearch-failed/)
Splunk / HTTP0 s – 2 h (7,200 s)→ S3 backup (splunk-failed/ or http-endpoint-failed/)→ S3 backup (splunk-failed/ hoặc http-endpoint-failed/)
Backup modesChế độ backup All source records (write every raw record to S3, in addition to the sink — audit trail) or Failed records only (default — cheaper, still gives you a replay handle). All source records (ghi mọi record gốc vào S3, ngoài sink chính — audit trail) hoặc Failed records only (mặc định — rẻ hơn, vẫn có chỗ replay).

Common patternsPattern hay gặp

  • KDS → Firehose → S3 (Parquet) + Redshift. Real-time layer keeps KDS for other consumers; Firehose lands Parquet in S3 for Athena and COPY into Redshift.KDS → Firehose → S3 (Parquet) + Redshift. Real-time layer giữ KDS cho consumer khác; Firehose đổ Parquet vào S3 cho Athena và COPY vào Redshift.
  • SNS → Firehose → S3. Native SNS-to-Firehose subscription = one-click "archive everything in this topic" without writing a Lambda.SNS → Firehose → S3. Subscription SNS-to-Firehose native = "archive mọi thứ trong topic này" một click, không cần viết Lambda.
  • CloudWatch Logs subscription → Firehose → OpenSearch. Alternative to the Lambda-to-OpenSearch pattern; no code, higher throughput.CloudWatch Logs subscription → Firehose → OpenSearch. Thay cho pattern Lambda-to-OpenSearch; không code, throughput cao hơn.
  • MSK → Firehose → S3. MSK-to-Firehose (native, GA 2023) replaces the older MSK Connect + S3 sink connector for the simple "archive Kafka topics" case.MSK → Firehose → S3. MSK-to-Firehose (native, GA 2023) thay cho MSK Connect + S3 sink connector cũ cho case "archive Kafka topic" đơn giản.

Naming & billing gotchasBẫy tên & billing

  • Renamed to "Amazon Data Firehose" in Feb 2024 (dropped "Kinesis" from the name). It's the same service; SDK/API still say firehose. Older docs may lag.Đổi tên thành "Amazon Data Firehose" tháng 2/2024 (bỏ chữ "Kinesis"). Vẫn là service đó; SDK/API vẫn là firehose. Tài liệu cũ có thể chưa cập nhật.
  • Billed on data ingested (GB) and, on top, per feature (format conversion, VPC delivery, dynamic partitioning). No shard-hour, no idle cost.Tính phí theo data ingested (GB), cộng thêm feature (format conversion, VPC delivery, dynamic partitioning). Không có shard-giờ, không phí idle.
  • Dynamic partitioning writes S3 objects under prefixes derived from record fields (e.g. customer_id=, event_type=) — Hive-style, Athena-friendly. Enable at creation time only.Dynamic partitioning ghi object S3 theo prefix lấy từ field record (vd customer_id=, event_type=) — kiểu Hive, hợp Athena. Chỉ bật lúc tạo stream.