# Creation of new Ray workers

**URL:** <https://discuss.ray.io/t/creation-of-new-ray-workers/8654>\
**Category:** Ray Core\
**Created:** [December 14, 2022, 3:46pm UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654 "2022-12-14T15:46:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [December 14, 2022, 3:46pm UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654/1 "2022-12-14T15:46:10Z")

</div>

Imagine the following code snippet.

```python
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?

---

<div class="post-metadata">

**Author:** ![ClarenceNg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/clarenceng/32/3108_2.png) [@ClarenceNg](https://discuss.ray.io/u/ClarenceNg)\
**Post date:** [December 15, 2022, 12:50am UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654/2 "2022-12-15T00:50:20Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [December 15, 2022, 9:06am UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654/3 "2022-12-15T09:06:51Z")

</div>

@ClarenceNg

Thank you very much! That answers my question.

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [December 15, 2022, 9:08am UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654/4 "2022-12-15T09:08:12Z")

</div>

@ClarenceNg

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

---

<div class="post-metadata">

**Author:** ![ClarenceNg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/clarenceng/32/3108_2.png) [@ClarenceNg](https://discuss.ray.io/u/ClarenceNg)\
**Post date:** [December 15, 2022, 9:20am UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654/5 "2022-12-15T09:20:28Z")

</div>

The default is 1 second idle time

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [December 15, 2022, 9:31am UTC](https://discuss.ray.io/t/creation-of-new-ray-workers/8654/6 "2022-12-15T09:31:18Z")

</div>

@ClarenceNg

Got it, thanks!
