Speed Up Comfy Cold Starts with Memory Snapshot

Cover Image for Speed Up Comfy Cold Starts with Memory Snapshot

When running ComfyUI in the cloud, waiting while it starts up can be a drag, especially when it is used behind an API. That's why we're excited to introduce Memory Snapshot, a new feature that dramatically reduces ComfyUI cold start times, often to under 3 seconds.

In this post, we’ll explain what cold starts are, what kind of improvement you can expect, how Memory Snapshot works, and what its current limitations are.

What Is a Cold Start?

A cold start is the time it takes for Comfy to launch and load the models to the GPU when you start a new container (ei. when starting a new GPU). If you’re running workflows via an API or a ViewComfy app, this can be a problem. Every time a user sends a request that requires a new GPU to be turned on, they will experience a cold start. This is, unfortunately, the nature of the cloud.

Cold starts happen because Comfy has to do a lot of setup before it can start generating: import Python libraries, scan custom nodes, and initialize its server. Depending on the complexity of your workflow, this process usually takes between 30 seconds and 2 minutes, which can make for a bad user experience.

Speed improvement with Memory Snapshot

With Memory Snapshot enabled, most users see the time it takes to start Comfy drop to under 10 seconds, often to as low as 3 seconds. This is a 3–5x speedup.

To put some real numbers to this claim, we did some tests with two of our workflows.

Comfy startup time before and after memory snapshot implementation

Workflow - complexity Startup time before Startup time after Speed improvement
Flux Kontext - only Comfy core nodes 53 seconds 9 seconds 83%
Wan Phantom - some custom nodes 62 seconds 8 seconds 87%
Flux tools - very complex 77 seconds 10 seconds 87%

As you can see, this feature is especially impactful for more complex workflows that run many custom node or needs to import a lot of libraries.

How does it work?

Without going into too much detail, Memory Snapshot is a way to save the state of your container’s CPU and RAM right after ComfyUI has fully started, but before it starts loading models or running any workflows.

The first time you launch ComfyUI, it goes through its full startup process. Memory Snapshot captures everything at that moment. Then, the next time you start a container, it just loads that saved state to the, skipping the slow startup steps.

Current Limitations

Our implementation of Memory Snapshot is still new, and it only saves the state of the CPU and RAM right after startup, which implies a few limitations.

  • It does not affect model loading time, as this process happens after startup.
  • It is incompatible with custom nodes that need the GPU during startup.
  • The first few times you start Comfy after implementing this feature, it will take more time than normal as the memory snapshot is being built.
  • Because of the limitations, it is not enabled by default on ViewComfy. To activate it, please reach out to the team.

We’re working on improving this feature and will be adding better GPU support in the future. In the meantime, to further speed up startup time, you can use quantized models, which load faster and will provide further cold start improvements.

Conclusion

For use cases where you have users relying on the Comfy workflow to run an application, memory snapshot is a must-have. It leads to a much better user experience and helps optimize the infrastructure in a cost-effective way.

To try it out, please reach out to the ViewComfy team: team@viewcomfy.com