Creation of new Ray workers

Imagine the following code snippet.

import ray
ray.init(num_cpus=2)

@ray.remote
class Foo:
    pass

actor_list = [Foo.remote for _ in range(2)]

@ray.remote
def foo():
    return 1

o_ref = foo.remote()

We have two available workers. When creating actors they are places onto those two available workers. My question is that when foo gets submitted, does Ray create a new worker process and then kills it after foo completes in it?

@YarShev

On a very high level, Ray maintains a worker pool and will create new worker processes as needed to execute the task, and applies a timeout to reap idle processes.

@ClarenceNg

Thank you very much! That answers my question.

@ClarenceNg

I am wondering if you are aware of the timeout that Ray has by default?

The default is 1 second idle time

@ClarenceNg

Got it, thanks!