translation/translated/documents/course/04-workflows/14-understanding-parallel-e...

39 lines
918 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 理解并行执行
学习如何同时运行多个工作流步骤以提高性能,当步骤彼此不依赖时。
## 何时使用并行执行
当您有不依赖彼此的步骤时使用并行执行:
- **不依赖彼此**:可以独立运行
- **耗时的**网络请求、AI调用或重型计算
- **处理相同输入**:对相同数据的多次分析
## 示例场景
想象您想要以三种不同方式分析内容:
1. SEO分析
2. 可读性分析
3. 情感分析
这些都可以同时运行,因为它们不依赖彼此!
## 创建并行步骤
工作流上的 `.parallel()` 方法并行执行多个步骤。
```typescript
workflow.parallel([stepOne, stepTwo]);
```
## 性能优势
并行运行步骤:
- **更快的执行**:步骤同时运行而不是等待
- **改善的用户体验**:更短的等待时间
接下来,您将创建其他并行步骤并了解如何将它们组合!