Ray: A Distributed Framework for Emerging AI Applications

Philipp Moritz, Robert Nishihara, Stephanie Wang, Alexey Tumanov, Richard Liaw, Eric Liang, William Paul, Michael I. Jordan, Ion Stoica

TL;DR

Ray is a high-performance distributed framework designed to unify the three core pillars of modern AI: training, simulation, and serving. By decoupling control state into a sharded global store and employing a unique bottom-up distributed scheduler, Ray achieves massive scalability—exceeding 1.8 million tasks per second—while providing a flexible API that supports both stateless tasks and stateful actors.

What Problem Does This Paper Address?

The authors identify a major gap in the distributed computing landscape. Existing frameworks are often specialized for a single type of workload: Spark excels at batch processing, TensorFlow and PyTorch dominate deep learning training, and systems like Clipper focus on model serving.

However, emerging AI applications—particularly Reinforcement Learning (RL)—require all these capabilities to be tightly coupled. As shown in Figure 1, an RL agent must constantly cycle between simulating environments (generating data), training policies (improving the agent), and serving those policies (taking actions).

Figure 1: Example of an RL system.

These workloads have conflicting requirements: simulations are often fine-grained and heterogeneous (lasting milliseconds to minutes), while training requires stateful, high-bandwidth communication. Existing systems struggle to handle this diversity at the millisecond latencies required for real-time interaction.

Methods

Ray’s architecture is built on two fundamental abstractions:

  1. Tasks (Stateless): Remote functions that execute on stateless workers. They are ideal for fine-grained simulations and data processing, offering easy load balancing and low recovery overhead.
  2. Actors (Stateful): Remote classes that maintain internal state. These are perfect for implementing parameter servers or wrapping third-party simulators that don't expose their state.

To make this work at scale, Ray introduces a novel System Layer (Figure 5):

  • Global Control Store (GCS): A sharded metadata store (using Redis) that maintains the entire system's control state, including the computation lineage and object directory. This allows all other components (schedulers, object stores) to be stateless, simplifying fault tolerance and horizontal scaling.
  • Bottom-Up Distributed Scheduler: Unlike centralized schedulers that become bottlenecks, Ray uses a two-level hierarchy. Tasks are first submitted to a local scheduler on the node. If the node is overloaded, the task is forwarded to a global scheduler. This allows Ray to handle millions of tasks per second with millisecond-level latency.
  • In-Memory Distributed Object Store: Built on Apache Arrow, this allows for zero-copy data sharing between tasks on the same node via shared memory, significantly reducing serialization overhead.
Figure 5: Ray’s architecture consists of two parts: an applica- tion layer and a system layer. The application layer implements the API and the computation model described in Section 3, the system layer implements task scheduling and data management to satisfy the performance and fault-tolerance requirements.

Datasets

Ray is a general-purpose framework, so its evaluation focuses on performance benchmarks and RL environments rather than static datasets:

  • OpenAI Gym: Specifically the Pendulum-v0 and Humanoid-v1 environments for testing simulation throughput and end-to-end RL performance.
  • Deep Learning Models: ResNet-101 was used to benchmark distributed training performance against Horovod and Distributed TensorFlow.
  • Microbenchmarks: Synthetic workloads were used to measure task throughput, object store IOPS, and scheduler latency.

Key Insights and Ideas

  • Decoupling State is Key: By moving all control state into the GCS, the authors turned a complex distributed systems problem into a database problem. This architectural choice is what enables Ray's extreme scalability and robust fault tolerance.
  • The "Bottom-Up" Advantage: Centralized schedulers (like those in Spark or CIEL) typically have latencies in the tens of milliseconds. Ray’s bottom-up approach (Figure 6) keeps the common case (local execution) extremely fast, which is critical for RL simulations.
  • Unified Abstraction: Ray proves that you don't need separate systems for tasks and actors. By treating actor method calls as stateful edges in a dynamic task graph, Ray provides a single execution engine that handles both paradigms seamlessly.
Figure 6: Bottom-up distributed scheduler. Tasks are submitted bottom-up, from drivers and workers to a local scheduler and forwarded to the global scheduler only if needed (Section 4.2.2). The thickness of each arrow is proportional to its request rate.

Key Results

  • Massive Scalability: Ray demonstrates near-linear scalability, reaching over 1.8 million tasks per second on 100 nodes.
  • Superior RL Performance:
    • For Evolution Strategies (ES), Ray solved the Humanoid-v1 task in 3.7 minutes using 8192 cores—more than twice as fast as the previously best-published result.
  • For Proximal Policy Optimization (PPO), Ray outperformed specialized MPI-based implementations while using a fraction of the GPUs, largely due to its ability to handle resource heterogeneity (scheduling CPU-only tasks on cheaper instances).
  • Low Latency Serving: Ray achieved an order of magnitude higher throughput than Clipper for small policy models by leveraging shared memory and low-overhead serialization.
  • Locality Awareness: As shown in Figure 8a, Ray's locality-aware scheduling keeps task latency independent of input size, whereas unaware schedulers see a 1-2 order of magnitude increase for large objects.
Figure 8a: Ray locality scheduling performance.

Limitations and Future Work

  • Scheduling Complexity: Because Ray makes scheduling decisions without full knowledge of the future computation graph, it may require more complex runtime profiling to optimize long-running jobs.
  • GCS Garbage Collection: Storing the lineage for every task in the GCS can lead to high storage costs. The authors note that implementing efficient garbage collection policies for the GCS is an area of active development.
  • Distributed Objects: Currently, the object store requires each object to fit on a single node. Handling distributed objects (like massive matrices spread across nodes) is currently left to the application layer.

Summary updated

BibTeX
@misc{moritz2017ray,
  author = {Philipp Moritz and Robert Nishihara and Stephanie Wang and Alexey Tumanov and Richard Liaw and Eric Liang and William Paul and Michael I. Jordan and Ion Stoica},
  title = {{Ray: A Distributed Framework for Emerging AI Applications}},
  year = {2017},
  eprint = {1712.05889},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1712.05889},
}
Figure