> For the complete documentation index, see [llms.txt](https://listen-lavender.gitbook.io/prefect-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://listen-lavender.gitbook.io/prefect-docs/tutorial/scalingout.md).

# 水平扩展

> 跟随终端演示：
>
> ```bash
> cd examples/tutorial
> python 06_parallel_execution.py
> ```

让我们调整flow以将其task分配到[Dask](https://dask.org/)集群上并行执行。听起来可能要做很多，但实际上这是迄今为止最简单的调整：

```python
from prefect.engine.executors import DaskExecutor

# ...task definitions...

# ...flow definition...

flow.run(executor=DaskExecutor())
```

这将启动系统上的[Local Dask Cluster](https://distributed.dask.org/en/latest/local-cluster.html)以并行化task。如果你已经在其他地方部署Dask集群，则可以通过在**DaskExecutor**构造函数中指定地址参数来使用该集群：

```python
flow.run(
    executor=DaskExecutor(
        address='some-ip:port/to-your-dask-scheduler'
        )
    )
```

此外，只要提供的对象实现**Executor**接口（即Submit，Map和Wait函数，等同于Python的**current.futures.Executor**接口），可以定制化**Executor**以用于任何Prefect flow。这样可算是没有使用的天花板！

接下来，Prefect还能做什么呢？

* [Prefect官网](https://www.prefect.io/)
* [英版原文](https://docs.prefect.io/core/tutorial/06-parallel-execution.html)
* [联系译者](https://github.com/listen-lavender)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://listen-lavender.gitbook.io/prefect-docs/tutorial/scalingout.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
