Task Design Patterns¶
This section is a collection of common design patterns (and anti-patterns) for Ray tasks. It is meant as a handbook for both:
New users trying to understand how to get started with Ray, and
Advanced users trying to optimize their use of Ray tasks
You may also be interested in visiting the design patterns section for actors.
- Pattern: Tree of tasks
- Pattern: Map and reduce
- Pattern: Using ray.wait to limit the number of in-flight tasks
- Antipattern: Closure capture of large / unserializable object
- Antipattern: Too fine-grained tasks
- Antipattern: Unnecessary call of ray.get in a task
- Antipattern: Calling ray.get in a loop
- Antipattern: Processing results in submission order using ray.get
- Antipattern: Fetching too many results at once with ray.get
- Antipattern: Redefining task or actor in loop
- Antipattern: Accessing Global Variable in Tasks/Actors