A data job might begin as a few dozen lines of Python: fetch data from an API, clean some fields and write the result to a database. Once it runs manually, add a schedule and it seems finished.
As soon as it must keep running, questions pile up. What if the API times out? If cleaning succeeds and writing fails, which step should we repeat? How do we backfill yesterday? Will overlapping runs write duplicates? Where can someone find out why a report is stale?
The job expands from processing one batch to managing a process over time. Prefect approaches data pipelines from that angle: describe work in Python, then add state tracking, schedules, retries and run management. Prefect introduction
This introduction covers technology available by November 10, 2025. It focuses on Prefect 3 alongside Airflow, Dagster and Kestra. Prefect APIs and terminology follow 3.4.25, released October 23, 2025. Code is illustrative and has not been run. Release notes
What does a workflow add to a scheduled script?
Suppose we generate a daily order report as follows:
flowchart LR
A["获取指定日期的订单"] --> B["校验并清洗字段"]
B --> C["写入分析数据库"]
C --> D["计算日报"]
D --> E["记录结果或发送通知"]
We can already write the SQL, HTTP requests and field transformations. As runs accumulate, we need to manage additional concerns:
| Operational problem | Capability needed |
|---|---|
| Daily schedule with occasional manual runs | Scheduling, manual triggers and parameters |
| Reports must stop if extraction fails | Dependencies and failure propagation |
| A temporarily unavailable API may recover | Retries with limits and intervals |
| Yesterday’s data was missed | Explicit data dates and a backfill entry point |
| A batch ran twice | Idempotent writes, transactions or business-level deduplication |
| Someone needs to know whether a run succeeded and where it failed | State, logs, history and alerts |
An orchestrator handles some of these. Business code still owns others. A tool can retry the write, but we must design how the database avoids duplicate orders.
Cron remains valuable. For one independent script where occasional manual recovery is cheap, a timer and log may suffice. An orchestrator earns its keep when managing dependencies, state and recovery centrally justifies another system.
How do data pipelines, ETL and orchestration relate?
These terms often share a product page while describing different aspects of the work.
A data pipeline is the path from source to destination. It can span a few steps or multiple systems, running in batches or continuously.
ETL means extract, transform, load: fetch orders, clean them in Python and write them to an analytics database. ELT swaps the last two: load data into the target, then use the database or warehouse to transform it. Dagster illustrates this division with dbt models and data replication tools. Example division of responsibilities
Workflow orchestration coordinates the steps: triggers, dependencies, parameters, failure handling and visibility. A workflow can also export reports, process files or train models.
One requirement can be viewed in layers:
| Layer | Daily order report example |
|---|---|
| Business logic | Which orders count toward sales and how to handle refunds |
| Data processing | Call an API, parse JSON, execute SQL |
| Workflow orchestration | Wait for extraction, then clean, load and generate the report |
| Execution environment | Run code in a local process, container or cluster job |
| Storage | Keep raw orders, cleaned records and reports |
Prefect organizes orchestration and connects it to execution environments. The task code and systems it calls perform the actual computations. A flow can submit a distributed Spark job and await its result. Decorating an ordinary Python function does not turn it into a Spark job. Spark documentation
Even a small dataset can need orchestration. Large datasets additionally call for choices about compute engines, storage and layout.
Starting with Prefect: turn Python functions into workflows
Prefect lets us start with existing Python. Keep ordinary function calls, conditions and loops, then add Prefect definitions at boundaries that need visibility or their own retries. Prefect introduction
Start with flows and tasks.
A flow represents the job and tasks represent its steps
A flow typically expresses a complete business process such as handling one date’s orders. Its tasks might fetch, clean and persist orders. A flow can mix ordinary Python and task calls. Every function need not be decorated. Flows
A useful task boundary corresponds to an operational unit. Do we want to time it separately or retry it alone? Are its inputs and outputs clear? Tasks support state tracking, retries and caching and can be submitted for concurrent execution. Tasks
The example uses fixed data. extract_orders simulates an API response and load_orders only logs. There is no actual extraction or database write yet.
from prefect import flow, get_run_logger, task
@task(retries=2, retry_delay_seconds=5)
def extract_orders(business_date: str) -> list[dict]:
# 示意数据;实际项目在这里调用 API,并处理分页和超时。
return [
{"id": 101, "date": business_date, "status": "paid", "amount_cents": 1990},
{"id": 102, "date": business_date, "status": "pending", "amount_cents": 3500},
]
@task
def transform_orders(orders: list[dict]) -> list[dict]:
return [order for order in orders if order["status"] == "paid"]
@task
def load_orders(orders: list[dict], business_date: str) -> None:
# 仅说明写入位置;实际项目还需实现事务与重复执行的处理。
get_run_logger().info(
"日期 %s:准备写入 %s 条已支付订单", business_date, len(orders)
)
@flow(name="daily-orders")
def daily_orders(business_date: str) -> None:
orders = extract_orders(business_date)
cleaned = transform_orders(orders)
load_orders(cleaned, business_date)
if __name__ == "__main__":
daily_orders("2025-11-09")
@flow defines the business entry point, and @task marks independently observable steps. retries=2 permits two retries after an initial failure. The fixed data will not fail; the setting shows where a real extraction task could define recovery. Retries
Direct task calls run in call order here. To fetch independent sources concurrently, investigate .submit(), .map() and task runners. Decorating a function with @task alone does not parallelize every task. Tasks
Distinguishing flows, deployments and runs
Several similar names appear in the UI and documentation. Here is how they map to this example:
| Concept | Meaning | Order workflow example |
|---|---|---|
| Flow | Workflow definition | The daily_orders function |
| Task | Independently tracked step | The extract_orders function |
| Flow run / task run | One invocation of a definition | Record of processing data for 2025-11-09 |
| Deployment | Server-side configuration for running a flow | Entry point, parameters, schedule and execution settings |
| Work pool | Configuration interface for execution infrastructure | A Docker or Kubernetes environment |
| Worker | Process that picks up runs from a matching pool and starts the environment | Submit a flow run as a container or Kubernetes Job |
Flows and tasks define work. Runs record executions. A deployment makes a flow triggerable through the UI, an API, a schedule or an event. A flow can have different deployments for different environments or parameters. Flows, Deployments
Registering a deployment still leaves the execution environment to provide. Plan for code location, dependencies and database access. With a work pool, code can live in an image or be fetched from Git or object storage. Deployments
Where do the server and business code run?
Separate the part storing workflow configuration and run records from the part executing business code.
Prefect Server is self-hostable and includes an API, database and UI. Prefect Cloud is hosted and adds collaboration features such as roles, auditing and SSO, subject to plan availability. Self-hosting leaves server and database maintenance with you. Server documentation
A healthy server does not mean every business task computes on that machine. Choose how the code runs.
Option one: a long-running process serves the workflow
If you have a machine and a few Python flows, start with flow.serve(). It creates a deployment and runs a process that listens for work and starts a subprocess to execute the flow.
The listener must stay running, with access to code, dependencies and data. The 3.4.25 docs also say a normal stop of the serve process pauses the corresponding schedule by default. Running a deployment script once does not eliminate the ongoing service. Local-process deployments
Option two: start environments using work pools and workers
When flows need different images, resource settings or container isolation, consider a work pool. It links Prefect’s orchestration configuration to infrastructure through reusable execution settings. Work pools
A common worker arrangement looks like this:
flowchart LR
U["UI / API / 调度"] --> S["Prefect 服务端\n保存 Deployment 与运行记录"]
W["Worker"] -->|"轮询待执行运行"| S
W -->|"启动或提交"| R["Flow Run\n进程 / 容器 / Kubernetes Job"]
R -->|"状态与日志"| S
R -->|"读取与写入业务数据"| D["API / 文件 / 数据库"]
Worker and pool types correspond. A process worker launches processes, a Docker worker starts containers and a Kubernetes worker submits Jobs. The worker’s main responsibility here is placing each flow run in an appropriate environment. Workers
A task runner controls concurrency inside a flow. Keeping the two layers distinct makes deployment documentation easier to follow.
Prefect Cloud also already offered push and managed work pools, which do not require a user-maintained polling worker. Check the pool type. Work pools
For gradual adoption, start with a persistent process to understand flows, run records and scheduling. Introduce containers or clusters as isolation and resource requirements arise. A hands-on deployment deserves its own article based on a real environment.
What still needs design after retries and state tracking?
Orchestration makes runs manageable. Correct business results still depend on the data and code.
Retry scope and the nature of failure
Retrying order extraction after a temporary API timeout avoids restarting the entire flow. Prefect supports retries separately for flows and tasks, with configurable delays and retry conditions. Retries
Distinguish transient network trouble from persistent input errors. Repeating an invalid query or reading a changed schema rarely helps. For expensive successful steps, decide whether to persist the result and whether it is safe to reuse after a later failure.
What should the data look like after repeated execution?
A database write might commit just before the process exits without recording success. The next run may execute it again. A simple append could duplicate the order.
Depending on business semantics, choose unique keys and upserts, replace a date partition or use idempotency keys for external actions. Define the desired result when identical input repeats and when source data is corrected.
Design caching separately. Prefect 3 task caching uses persisted results and keys to decide reuse. Policy, storage and expiry affect behavior. Caching does not supply idempotency for an external API or database. Caching
Execution date and data date
The example passes business_date explicitly so each run identifies which date it processes.
A November 10 run may process November 9 orders. A November 15 manual backfill may also need November 9. A task that reads “today” internally can easily select the wrong range.
Plan for time zones, data intervals, late arrivals and backfill scope. Prefect schedules support intervals, cron, RRule and time zones. A schedule cannot define the business data interval for you. Schedules
Program success and data correctness
A task ending without an exception means it met its programmed success condition. An API could have returned an empty list, a table could contain the wrong date or the report could omit orders.
Add checks for missing required fields, duplicate keys, unusual volumes and correct dates. A failure should leave enough information to locate the problem. Workflow state then more closely reflects the business outcome.
How to approach Airflow, Dagster and Kestra
All three orchestrate workflows. First compare how they organize work, then examine deployment and team practices.
Airflow: use DAGs for tasks and dependencies
Airflow defines DAGs in Python to organize tasks, dependencies and schedules. Its UI and integrations mainly serve batch workflows with defined starts and ends. Airflow 3.1.2
Teams with many scheduled data jobs should examine data intervals, historical backfills, task reruns and existing providers. Airflow 3.1.2 backfills create runs across date ranges and control reprocessing and concurrency. Backfills
Versions matter in comparisons. Airflow supports dynamic task mapping from runtime data and scheduling triggered by asset updates. It is inaccurate to describe it as entirely predefined or exclusively time-triggered. Dynamic task mapping, asset scheduling
I would compare the same real flow: readability, parameters and data dates, diagnosing failures, and which components the team must maintain.
Dagster: start with the data assets to maintain
Software-defined assets are central to Dagster. Define a desired artifact, such as a clean orders table, daily aggregate or model, then identify the code creating it and the upstream assets it depends on. Dagster on assets
In our example, daily_sales depends on clean_orders, and clean_orders depends on raw orders. We care about asset relationships and what needs refreshing as well as whether a task succeeded.
Dagster merits separate treatment for warehouses, data models and cross-team dependencies. Its fit depends partly on whether a team wants to organize both code and daily work around assets.
Kestra: connect systems using declarative workflows
Kestra expresses tasks, triggers and flow structure in YAML, with a UI for editing and managing runs. Its 2025 introduction also emphasizes multilingual code and plugins for data, infrastructure and business automation. Kestra design
A flow containing SQL, shell, Python and external service calls is a good test of how Kestra combines different steps in one definition.
I would look at maintainability as YAML grows, shared logic, plugins, execution environments and how UI editing fits version control. Those tell me more about fit than comparing screenshots.
Comparing them side by side
Based on the sources above, here is where I would start reading and testing. Capabilities overlap, so use a concrete workflow for the final judgment.
| Tool | Organizing idea | Scenario to investigate first | What to observe |
|---|---|---|---|
| Prefect | Python flows, tasks and run state | Existing Python scripts that need scheduling and operations | Migration effort, retry boundaries, runtime setup |
| Airflow | DAGs, dependencies and scheduling | Many periodic batch jobs or an existing Airflow team | Data intervals, backfills, providers and operations |
| Dagster | Assets and upstream dependencies | Long-lived relationships between tables, models and data products | Asset modeling, dependency visibility, updates and partitions |
| Kestra | Declarative flows, plugins and multiple languages | Several languages and systems in one workflow | YAML maintenance, plugin coverage and code delivery |
This is how I would select a tool, not a performance ranking. Prefect can power complex platforms, Airflow can orchestrate ordinary scripts, and Dagster and Kestra offer multiple deployment modes. Compare how each expresses the same problem.
How I would trial it in my own project
Given a few Python processing scripts that now need reliable scheduling, I would convert one well-bounded workflow to Prefect.
Make the data date explicit and separate extraction, transformation and loading into observable steps. Inspect run history and logs. Introduce a recoverable failure and check the retry scope. Run the same batch twice and confirm the database ends up in the intended state.
Once that works, add a schedule and choose a persistent process or worker with containers. Explore multiple environments, image management, concurrency limits and historical backfills as actual needs emerge.
Use the same workflow to compare alternatives. Give each the same date, failure and backfill, then inspect the code, UI and routine operations. The result translates more readily into an estimate of maintenance cost.
Topics for later
This article introduces Prefect and data orchestration. With material from a real project, I would expand on:
- Prefect deployment: self-hosted Server,
serve(), workers, and shipping code and dependencies in containers. - Pipeline recovery: idempotent writes, caching, result persistence, resumption and backfills.
- A shared ETL comparison: implement one requirement in Prefect, Airflow, Dagster or Kestra and record differences in code and maintenance.
Revision history
| Date | Change |
|---|---|
| 2026-11-08 | Prepared the introductory draft, filed under 2025-11-10, using material available then to describe Prefect and alternatives. Code is illustrative and unverified. Deployment details and practical experience are reserved for later articles. |
References
Sources checked November 8, 2026. Prefect documentation is pinned to 3.4.25 and Airflow to 3.1.2. Dagster and Kestra articles were published in 2025. The technical discussion follows these historical sources without projecting later product changes back into 2025.
- Prefect Technologies. (2025, October 23). Prefect 3.4.25 release.
- Prefect Technologies. (2025). Introduction (3.4.25 documentation).
- Prefect Technologies. (2025). Flows (3.4.25 documentation).
- Prefect Technologies. (2025). Tasks (3.4.25 documentation).
- Prefect Technologies. (2025). Deployments (3.4.25 documentation).
- Prefect Technologies. (2025). Prefect server (3.4.25 documentation).
- Prefect Technologies. (2025). How to run flows in local processes (3.4.25 documentation).
- Prefect Technologies. (2025). Work pools (3.4.25 documentation).
- Prefect Technologies. (2025). Workers (3.4.25 documentation).
- Prefect Technologies. (2025). How to automatically rerun your workflow when it fails (3.4.25 documentation).
- Prefect Technologies. (2025). Caching (3.4.25 documentation).
- Prefect Technologies. (2025). How to create schedules (3.4.25 documentation).
- Apache Software Foundation. (2025). What is Airflow? (3.1.2 documentation).
- Apache Software Foundation. (2025). Backfill (3.1.2 documentation).
- Apache Software Foundation. (2025). Dynamic task mapping (3.1.2 documentation).
- Apache Software Foundation. (2025). Asset-aware scheduling (3.1.2 documentation).
- Hume, D. (2025, August 7). Software-defined assets explained. Dagster.
- Dehon, L. (2025, September 4). The road from Kestra 0.1 to 1.0. Kestra.
- Apache Software Foundation. (2025). Spark overview (4.0.0 documentation).