Customizing Xcom to enhance data sharing between tasks
summary
Shows concrete code and results for moving large or non-JSON XCom payloads out of the Airflow metadata DB by writing a BaseXCom subclass that implements serialize_value/deserialize_value and a UI-friendly orm method. Demonstrates storing payloads on local disk, Google Cloud Storage and Redis while saving only a key in Postgres, and proves retrieval works end-to-end. Notes pickling is disabled, Redis is memory-bound and can lose data, cloud storage adds latency and cost, and cleanup is handled by a separate maintenance DAG (not lifecycle-tied).
AI-written summary · about
chapters (16)
- 0:00Introduction to XCom
- 2:08XCom Fundamentals
- 3:28Airflow 2.0 TaskFlow API
- 4:52Limitations of Standard XCom
- 6:42Custom XCom Backends
- 7:56Local File System Backend
- 9:15Code Walkthrough: File Backend
- 11:32File Backend Demonstration
- 14:07Distributed Deployment Issues
- 18:09Cloud Storage Backend Setup
- 21:06GCS Backend Demonstration
- 23:41Redis Backend Implementation
- 26:08Redis Backend Demonstration
- 27:43Data Cleanup Strategies
- 30:03Maintenance DAG Example
- 34:41Future Work and Conclusion
