# Dynamically create/terminate serve deployments based on available capacity

**URL:** <https://discuss.ray.io/t/dynamically-create-terminate-serve-deployments-based-on-available-capacity/5989>\
**Category:** Ray Serve\
**Created:** [May 2, 2022, 6:14am UTC](https://discuss.ray.io/t/dynamically-create-terminate-serve-deployments-based-on-available-capacity/5989 "2022-05-02T06:14:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prabalakanti](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@prabalakanti](https://discuss.ray.io/u/prabalakanti)\
**Post date:** [May 2, 2022, 6:14am UTC](https://discuss.ray.io/t/dynamically-create-terminate-serve-deployments-based-on-available-capacity/5989/1 "2022-05-02T06:14:14Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- None: Just asking a question out of curiosity

Hi,

I have a use case where models get dynamically created and need to be served in the available memory of a cluster.

**Example:**  
My cluster has 32 GB RAM available which is sufficient to serve approx. 10 models. So I can create 10 Ray serve deployments around them. If a new model needs to be served, I first need to remove one of the existing 10 deployments and then deploy the newly arrived model.

I was wondering if the “tree of actors” pattern can be used to tackle this. Can I create a supervisor deployment/actor which exposes functions that actually dynamically create/upscale/downscale/delete deployments in a running cluster? Are there any side effects to creating deployments from within another actor?

Is there a standard pattern to achieve this in Ray Serve which I am missing?

---

<div class="post-metadata">

**Author:** ![architkulkarni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/architkulkarni/32/10_2.png) [@architkulkarni](https://discuss.ray.io/u/architkulkarni)\
**Post date:** [June 6, 2022, 10:23pm UTC](https://discuss.ray.io/t/dynamically-create-terminate-serve-deployments-based-on-available-capacity/5989/2 "2022-06-06T22:23:08Z")

</div>

Hi @prabalakanti, you can certainly manage deployments from within another actor or deployment!

---

<div class="post-metadata">

**Author:** ![architkulkarni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/architkulkarni/32/10_2.png) [@architkulkarni](https://discuss.ray.io/u/architkulkarni)\
**Post date:** [June 14, 2022, 7:46pm UTC](https://discuss.ray.io/t/dynamically-create-terminate-serve-deployments-based-on-available-capacity/5989/3 "2022-06-14T19:46:54Z")

</div>

To give more details, there are no side effects from creating deployments within another actor. For your supervisor actor, if you don’t plan to scale it up using `num_replicas`, it might be simpler to just create it as a Ray Actor instead of a Deployment.
