Skip to content

[Feature] Add Resource Limits for Container - #1012

Open
antonio-amjr wants to merge 2 commits into
project-chip:v2.15.1-beta1+summer2026from
antonio-amjr:feature/add_resouce_limits_for_rasp
Open

[Feature] Add Resource Limits for Container#1012
antonio-amjr wants to merge 2 commits into
project-chip:v2.15.1-beta1+summer2026from
antonio-amjr:feature/add_resouce_limits_for_rasp

Conversation

@antonio-amjr

@antonio-amjr antonio-amjr commented May 28, 2026

Copy link
Copy Markdown
Contributor

Fix: #911
In combination with: project-chip/certification-tool-backend#327

Description

Add backend resource limits for Raspberry Pi 4 deployment

Changes

Backend CPU and memory limits (docker-compose.yml)
Added deploy.resources.limits to the backend service:

  • cpus: '2.5' — caps the backend at 2.5 of the 4 available cores, preventing
    test execution from starving the OS, Docker daemon, and other services during
    heavy SDK test runs.
  • memory: 1500M — prevents the backend from consuming all available RAM and
    forcing the OS to swap to SD card, which causes severe performance degradation
    on Raspberry Pi 4.

@antonio-amjr
antonio-amjr requested review from oxesoft and rquidute May 28, 2026 18:45
@antonio-amjr antonio-amjr self-assigned this May 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds CPU and memory resource limits to the backend service in the docker-compose configuration. The review feedback highlights potential issues with hard-coding these limits, particularly on Raspberry Pi 4 devices with varying RAM capacities, and recommends making the limits configurable via environment variables to prevent OOM kills or restrictive caps.

Comment thread docker-compose.yml Outdated
@mergify

mergify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@oxesoft oxesoft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small things worth double-checking before merge — nothing blocking, the core fix is sound and I confirmed docker compose config resolves the new deploy.resources.limits block correctly.

Comment thread docker-compose.yml
resources:
limits:
cpus: '${BACKEND_CPU_LIMIT:-2.5}' # If no environment variables is provided, cap at 2.5 cores
memory: '${BACKEND_MEMORY_LIMIT:-2000M}' # If no environment variables is provided, cap at 2.0 GB

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says memory is capped at 1500M, but the default here is 2000M (it was bumped in 718d282 when the hardcoded value became overridable via BACKEND_MEMORY_LIMIT). Could you confirm which value is actually intended and update the description to match? On the minimum supported spec (4GB RPi4 per docs/Raspberry Pi-Setup.md), the extra 500M meaningfully changes how much headroom is left for the OS + db/frontend/proxy containers.

Comment thread docker-compose.yml
deploy:
resources:
limits:
cpus: '${BACKEND_CPU_LIMIT:-2.5}' # If no environment variables is provided, cap at 2.5 cores

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BACKEND_CPU_LIMIT / BACKEND_MEMORY_LIMIT aren't documented anywhere (not in default.env, not in the Raspberry Pi setup doc). Since the point of making these configurable is to let users tune the caps for their own hardware, it'd help discoverability to add them to default.env — even commented out with the defaults shown — the way the other configurable vars in that file are presented.

Comment thread docker-compose.yml
privileged: true
build:
context: ./backend
deploy:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only backend gets resource limits; db, frontend, and proxy stay unbounded. If the goal is avoiding OS/swap pressure on the Pi, is backend-only scope intentional (i.e. it's the only service that spikes during SDK test runs), or worth a follow-up for the others too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants