Data Engineering
8 bài viết
Đọc theo series
Airflow là gì, vì sao 'pipeline as code', kiến trúc Airflow 3 (API server, scheduler, DAG processor, workers, triggerer, metadata DB) và Task Execution API, khác biệt với Airflow 2, khi nào nên/không nên dùng.
Mổ xẻ DAG và Task: khai báo bằng @dag/@task (TaskFlow) và cách cổ điển, thiết lập phụ thuộc (>>, chain), tham số schedule/start_date/catchup/backfill, data interval, retries và cấu trúc một DAG production.
Các khối xây dựng task: Operators (Bash/Python/SQL/transfer), Sensors (poke vs reschedule, deferrable), Hooks kết nối hệ ngoài, hệ sinh thái Providers, và cách viết custom operator/hook đúng chuẩn.
Truyền dữ liệu giữa các task: TaskFlow API (@task) và XCom hoạt động thế nào, custom XCom backend cho payload lớn, Jinja templating & params, và Dynamic Task Mapping (.expand/.partial) để sinh task theo runtime.
Các executor trong Airflow 3 (Local, Celery, Kubernetes, Edge), khác biệt so với Airflow 2 (bỏ Sequential/hybrid), điều khiển đồng thời (parallelism, pools, max_active_runs/tasks), và chiến lược scale + gỡ nút thắt.
Bên trong bộ lập lịch Airflow: DAG run & data interval, cron/timedelta/preset, custom Timetables, và Assets (tên mới của Datasets) cho lập lịch theo dữ liệu + scheduling hướng sự kiện tích hợp messaging trong Airflow 3.
Đưa Airflow lên production: các cách triển khai (Docker Compose, Helm/Kubernetes, dịch vụ managed MWAA/Cloud Composer/Astronomer), CI/CD cho DAG, quản lý Connections/Variables/Secrets backend, logging, giám sát metrics và bảo mật/RBAC.
Nguyên tắc viết DAG bền vững: idempotency & atomicity, task nhỏ có mục đích rõ, mẫu ETL/ELT, tích hợp Spark/dbt/Kafka, kiểm thử DAG, kiểm tra chất lượng dữ liệu, các anti-pattern cần tránh và điểm mới đáng dùng của Airflow 3.