Parallelism in Ray with Time Series Data

Executing embarassingly parallel workloads on Ray and Anyscale

The most basic use of ray is to parallelize workloads. You'll have to consider how to issue tasks to Ray depending on the size and speed of your workloads. This document has a few patterns for approaching parallelism -- how Python looks when written as a single thread, and then two approachs to delegating parallel tasks with Ray Core.

Naive Approach -- Single Threaded

Naive Parallelism

The code block below will generate a Prophet model and fit against the dataset 1 by 1, single threaded.

Connecing to Anyscale

The archtitectures repositoryarrow-up-right contains the code snippets on this page. To run them in Anyscale, this connection call makes sure to exclude the training data and also installs prophet as part of a runtime environment.

Firehose Approach

Firehose Approach

The code block below will launch Ray task for every fit_prophet invocation, and the task will be executed asynchronously on remote Ray workers. For-loop, also called the driver script, will be launching the tasks as fast as possible.

This approach delivers the highest throughput, shortest execution time from start to finish. But it is also the least efficient given that the cluster is trying to scale out a large number of worker nodes to meet the demand. Anyscale's hosted Ray cluster can scale out very fast, but it still take some time. In the scenario where each individual tasks are very short, it could be that when the new worker nodes is ready, there are some earlier tasks are finished and those Ray worker process can be reused for task execution, resulting the now worker nodes no longer needed.

Ray Task Launching with Back Pressure

Ray Task Launching with Back Pressure

The below code block will launch Ray tasks as fast as possible while trying to maintain the max number of tasks in-flight to be within a threshold. This is done via implemented the back pressure pattern. There is a specific check before the actual launch of the task, checking if the number of tasks in flight / not-yet-returned is greater than the threshold. If so, enter in a blocking execution to wait for the threshold to be satisfied and then proceed to launch new tasks.

Last updated

Was this helpful?