cli icon indicating copy to clipboard operation
cli copied to clipboard

Managed local stack: CPU and memory limits per service, kept across stop and start

Open luizfneves404 opened this issue 3 weeks ago • 0 comments

Existing issues

  • [x] I have searched the existing issues.

Affected area

Docker

Problem to solve

We reproduce a hosted instance's CPU and memory size locally for load testing. The managed local stack has no way to set those limits, and a limit applied by hand is lost when the CLI recreates the container.

Observed on Supabase CLI 3.1.0, Linux, Docker 29.9.2:

  1. docker update --memory 768m --memory-swap 768m <database container> set the container's HostConfig.Memory to 805306368 bytes.
  2. supabase --experimental stack stop --stack-id <stack id> removed the database container. supabase start --stack-id <stack id> -x rest,auth,realtime,storage,functions,studio,mail,analytics,pooler --runtime docker created a new database container, with a new container ID and creation time. Its HostConfig.Memory was 0.
  3. The database data and the migration history survived the relaunch.

So a limit set with docker update does not persist across stack stop and stack start, because the CLI recreates the container each time. The CLI 3.1.0 has no setting for container CPU or memory; a search of its sources for container resource options found none.

Proposed solution

Per-service memory and cpus keys in the managed stack's config, passed to the container when the CLI creates it, as the runtime's --memory and --cpus options. Unset keys keep the current behaviour, which is no limit.

Alternatives considered

Raising the Docker Desktop memory limit for the whole VM. This applies to every container, not one stack, and it does not set CPU.

Additional context

The CLI's out-of-memory guidance points to Docker Desktop's global memory setting (apps/cli/src/command-internal/docker-suggest.ts, lines 12–13), which is the only remedy it gives.

luizfneves404 avatar Nov 10 '26 22:11 luizfneves404