Amazon Managed Service for Apache Flink
Run Apache Flink jobs (Java, Scala, Python, SQL) on a managed cluster. It's the stream-processing layer that sits between an ingest stream (KDS/MSK) and its sinks: windowed aggregations, joins, filtering, enrichment. Previously named Kinesis Data Analytics for Apache Flink.
Chạy job Apache Flink (Java, Scala, Python, SQL) trên cluster managed. Đây là tầng xử lý stream nằm giữa nguồn ingest (KDS/MSK) và đích: window aggregate, join, filter, enrich. Tên cũ: Kinesis Data Analytics for Apache Flink.
Reach for itNên dùng
- Windowed aggregations, joins, sessionization on a streamAggregation theo window, join, sessionization trên stream
- Stateful stream processing with strict exactly-onceStream processing có state với exactly-once chặt
- Real-time ETL from Kafka/KDS into S3, OpenSearch, or another streamETL real-time từ Kafka/KDS vào S3, OpenSearch, hoặc stream khác
- Fraud/anomaly detection with per-key statePhát hiện fraud/anomaly theo state của từng key
Not the right toolKhông hợp
- Simple record-by-record transform → Firehose + Lambda transformerTransform từng record đơn giản → Firehose + Lambda transformer
- Batch ETL over S3 → Glue (Spark)ETL batch trên S3 → Glue (Spark)
- SQL analytics over S3 → AthenaAnalytics SQL trên S3 → Athena
- Reading from Firehose — not supported. Read from KDS/MSK, write to Firehose is fine.Đọc từ Firehose — không hỗ trợ. Đọc từ KDS/MSK, ghi vào Firehose thì OK.
The compute modelMô hình compute
You provision a number of KPUs. The service runs a Flink cluster of that size, distributes your job graph across it, and handles restarts, upgrades, and checkpointing. Scale by changing KPU count (or turn on autoscaling). Bạn provision số KPU. Service chạy cluster Flink kích thước đó, phân phối job graph, và lo restart, upgrade, checkpoint. Scale bằng đổi số KPU (hoặc bật autoscaling).
- KPU = 1 vCPU + 4 GB RAM + 50 GB app storage. Extra parallelism per KPU controls how many parallel operators map to one KPU.KPU = 1 vCPU + 4 GB RAM + 50 GB app storage. Tham số parallelism per KPU quyết định bao nhiêu operator song song ánh xạ vào 1 KPU.
- Autoscaling watches CPU utilization; scale-out and scale-in each restart the job from the latest checkpoint (brief downtime + processing lag catch-up).Autoscaling theo CPU utilization; scale-out và scale-in đều restart job từ checkpoint gần nhất (downtime ngắn + phải xử lý bù lag).
- Deploy the job JAR/ZIP to an S3 location; the service pulls it. Update = upload new artifact + call
UpdateApplication.Deploy JAR/ZIP của job lên S3; service tự kéo về. Update = upload artifact mới + gọiUpdateApplication.
Checkpoints, snapshots, exactly-onceCheckpoint, snapshot, exactly-once
Checkpoints are automatic, periodic backups of application state — used by the service to restart the job on failure. Snapshots are user-triggered checkpoints kept until you delete them — used to redeploy or roll back code. Checkpoint = backup state tự động, định kỳ — service dùng để restart job khi fail. Snapshot = checkpoint do user tạo, giữ tới khi xoá — dùng để redeploy hoặc rollback code.
- Default checkpoint interval 60 s; tune down for tighter recovery, up for lower overhead.Checkpoint mặc định 60 s; giảm để recovery chặt hơn, tăng để giảm overhead.
- Exactly-once end-to-end needs (a) checkpointing on, (b) source that supports replay from an offset (KDS/MSK do), (c) transactional sink (Kafka/KDF/OpenSearch connectors support it).Exactly-once end-to-end cần (a) bật checkpoint, (b) source có replay theo offset (KDS/MSK có), (c) sink transactional (connector Kafka/KDF/OpenSearch hỗ trợ).
- Restore-from-snapshot when redeploying code — otherwise the new version starts from an empty state.Restore-from-snapshot khi redeploy — nếu không, phiên bản mới khởi động với state trống.
Managed Flink StudioManaged Flink Studio
Zeppelin notebook fronting a Flink cluster. Interactive SQL / PyFlink / Scala on top of KDS or MSK — great for prototyping. When ready, "promote" the notebook to a long-running managed Flink app. Notebook Zeppelin dựng trước cluster Flink. SQL / PyFlink / Scala tương tác trên KDS hoặc MSK — hợp để prototype. Khi xong, "promote" notebook thành app Flink managed chạy dài hạn.
- This is the replacement for legacy Kinesis Data Analytics for SQL (retired Jan 2026).Đây là bản thay thế Kinesis Data Analytics for SQL cũ (ngừng 1/2026).
- Cheaper than running a full production Flink app 24/7 for occasional analysis.Rẻ hơn chạy full app Flink 24/7 nếu chỉ phân tích thi thoảng.
Common patternsPattern hay gặp
- KDS → Flink → KDS. Enrich or join two streams, write a derived stream back into KDS for downstream consumers.KDS → Flink → KDS. Enrich hoặc join 2 stream, ghi stream dẫn xuất trở lại KDS cho consumer downstream.
- MSK → Flink → OpenSearch. Windowed aggregates from Kafka topics land as documents for real-time dashboards.MSK → Flink → OpenSearch. Aggregate theo window từ Kafka topic đổ vào OpenSearch cho dashboard real-time.
- KDS → Flink → S3 (via KDF). Flink handles the compute, Firehose handles the S3 partitioning/format.KDS → Flink → S3 (qua KDF). Flink lo compute, Firehose lo phân partition/format cho S3.
- Anti-pattern: KDF → Flink. Doesn't work; Firehose is delivery-only.Anti-pattern: KDF → Flink. Không chạy; Firehose chỉ deliver.