> ## Documentation Index
> Fetch the complete documentation index at: https://comfydeploy.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Scaling

When your workflows are in production, how do you want your GPUs to scale? This section will help you understand how the settings you choose effect your scaling. As well as the cost and performance trade-offs.

You can change these settings underneath "Auto Scaling" while editing your machine.

## Settings

### Max Parallel GPU

<Frame>
  <img src="https://mintcdn.com/comfydeploy/o5fOxSEVTG8z9WUO/images/machine/max-p-gpu.png?fit=max&auto=format&n=o5fOxSEVTG8z9WUO&q=85&s=faa8dd32e7fae31937aa7d3b3aafc872" width="500" data-path="images/machine/max-p-gpu.png" />
</Frame>

This determines how many GPUs can be spun up at the same time.

<Note>
  If you need more then 10 GPUs concurrently, contact us at `founders@comfydeploy.com`.
</Note>

### Workflow timeout

The maximum amount of time you want a workflow to run for. If a workflow run exceeds this time, the run will be cancelled.

<Note>
  We can increase this to up to 24 hours, contact us at `founders@comfydeploy.com`.
</Note>

### Warm time

After your workflow has finished running on a GPU, you have the option to keep it warm for a certain amount of time, to reduce cold starts for your next request.

<Note>
  Warm time is still charged, this is a trade-off between cost and performance.
</Note>

### Keep warm

For the highest performance workloads. You can keep your GPUs warm to reduce cold starts to zero.

## Example situations

This are some examples to show what happens with different request patterns with the same settings.

In this example

* `max parallel gpu` set to 2
* `warm time` set to 1 minute
* `always warm GPUs` set to 0

### Example 1: Basic

We have only 1 request.

1. `r1` comes in, a GPU spins up.
2. `r1` finishes.
3. The GPU is kept warm for 1 minute before spinning down.

<Frame>
  <img src="https://mintcdn.com/comfydeploy/o5fOxSEVTG8z9WUO/images/machine/scaling/eg1.png?fit=max&auto=format&n=o5fOxSEVTG8z9WUO&q=85&s=4e374d6b433dfcbb8840a17d4fecfe01" width="500" data-path="images/machine/scaling/eg1.png" />
</Frame>

### Example 2: Taking advantage of warm GPUs

This time we have 2 requests, where the 2nd request uses a warm GPU.

1. `r1` comes in, a GPU spins up.
2. `r1` finishes.
3. `r2` is before `r1_f + warm time`, so we reuse the same GPU
4. `r2` is faster than `r1` because the GPU was warm.
5. The GPU is kept warm for 1 minute before spinning down.

<Frame>
  <img src="https://mintcdn.com/comfydeploy/o5fOxSEVTG8z9WUO/images/machine/scaling/eg2.png?fit=max&auto=format&n=o5fOxSEVTG8z9WUO&q=85&s=cfda19da0accc83e6dac85d42865b3f7" width="500" data-path="images/machine/scaling/eg2.png" />
</Frame>

### Example 3: Scaling up and hitting max GPUs

We have 2 requests, and we'll spin up 2 GPUs.

1. `r1` comes in, a GPU spins up.
2. `r2` comes in before `r1` finishes, a new GPU spins up.
3. `r1` finishes.
4. `r1` GPU spins down after staying warm for 1 min.
5. `r2` finishes
6. `r2` GPU spins down after staying warm for 1 min.

<Frame>
  <img src="https://mintcdn.com/comfydeploy/o5fOxSEVTG8z9WUO/images/machine/scaling/eg3.png?fit=max&auto=format&n=o5fOxSEVTG8z9WUO&q=85&s=af517714cdfa945fba30899dba8cc939" width="500" data-path="images/machine/scaling/eg3.png" />
</Frame>

If we had a 3rd request `r3` while our 2 requests were running (between `r2` and `r1_f`).

The third request would have to wait for one of the GPUs to finish before it can start as we've hit our max GPU limit.
`r3 starts`.

<Frame>
  <img src="https://mintcdn.com/comfydeploy/o5fOxSEVTG8z9WUO/images/machine/scaling/eg3b.png?fit=max&auto=format&n=o5fOxSEVTG8z9WUO&q=85&s=71f0962c7ac278fdc5dc2ce471660c25" width="500" data-path="images/machine/scaling/eg3b.png" />
</Frame>
