Skip to content

Add per-container io.max throttling support (cgroups v2) - #509

Merged
winkingturtle-vmw merged 5 commits into
cloudfoundry:mainfrom
vpetrinski:feature/io-max-throttling
Jul 30, 2026
Merged

Add per-container io.max throttling support (cgroups v2)#509
winkingturtle-vmw merged 5 commits into
cloudfoundry:mainfrom
vpetrinski:feature/io-max-throttling

Conversation

@vpetrinski

Copy link
Copy Markdown
Contributor

Generated with AI assistance.

  • Add IOMaxReadBps/WriteBps/ReadIOPS/WriteIOPS to Limits struct
  • Apply throttle on all real block devices when cgroups v2 is active
  • getAllBlockDevices() reads /sys/block, filters loop/ram/dm
  • New CLI flags: container-io-max-{read,write}-{bps,iops}
  • Zero values = disabled (backward compatible)

Companion PR in garden-runc-release: https://github.com/vpetrinski/garden-runc-release/tree/feature/io-max-throttling

  • Read the Contributing document.

    Summary

    Adds per-container disk I/O rate limiting via cgroups v2 io.max. When configured, each new container receives IOPS and throughput limits on all real block devices at creation time.

    Motivation: A single container can saturate the shared data disk on a Diego cell, starving all other containers of I/O and causing health check timeouts / false app crashes.

    Changes:

    • rundmc/bundlerules/limits.go: Extended Limits struct with IOMaxReadBps, IOMaxWriteBps, IOMaxReadIOPS, IOMaxWriteIOPS. When any value > 0 and cgroups v2 is active, applies throttle devices to the OCI
      bundle for all real block devices.
    • guardiancmd/command.go: Added 4 new CLI flags (--container-io-max-{read,write}-{bps,iops})
    • getAllBlockDevices(): Reads /sys/block, filters virtual devices (loop, ram, dm), returns major:minor for real devices.

    Tested: Custom dev release deployed on Noble cell (Ubuntu 24.04, cgroups v2). Throttled: 60 MB/s vs Unthrottled: 272 MB/s (4.5× protection). App starts and runs normally with limits active.

    Companion PR in garden-runc-release: cloudfoundry/garden-runc-release@develop...vpetrinski:garden-runc-release:feature/io-max-throttling

    Generated with AI assistance.

    Backward Compatibility

    Breaking Change? No

    • All new flags default to 0 (unlimited) — no behavioral change unless operator explicitly sets values > 0
    • On cgroups v1 (Jammy) and Windows: silently skipped via IsCgroup2UnifiedMode() check
    • Existing containers and configurations are completely unaffected
    • Feature is opt-in only

- Add IOMaxReadBps/WriteBps/ReadIOPS/WriteIOPS to Limits struct
- Apply throttle on all real block devices when cgroups v2 is active
- getAllBlockDevices() reads /sys/block, filters loop/ram/dm
- New CLI flags: container-io-max-{read,write}-{bps,iops}
- Zero values = disabled (backward compatible)

Companion PR in garden-runc-release: https://github.com/vpetrinski/garden-runc-release/tree/feature/io-max-throttling

Generated with AI assistance.

Signed-off-by: Viktor Petrinski <v.petrinski@sap.com>
@github-project-automation github-project-automation Bot moved this from Inbox to Pending Merge | Prioritized in Application Runtime Platform Working Group Jul 30, 2026
@winkingturtle-vmw
winkingturtle-vmw merged commit 294b146 into cloudfoundry:main Jul 30, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Done in Application Runtime Platform Working Group Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants