CPU & memory boundaries

Apply resource limits consciously

Lesson 17 of 20 · 12 min · Module 6: Operate a complete stack

Bound resource use so one workload cannot consume everything available.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • State a resource budget
  • Choose restart behavior

The idea

Container operations change instances and their attached configuration. Inspect the resulting state as well as the command sequence.

01State a resource budget

Memory and CPU controls set boundaries rather than promising that every workload will fit. A real limit should follow measured behavior and realistic load tests.

02Choose restart behavior

on-failure restarts a process after a failing exit. It does not diagnose why the failure occurred or ensure that the app becomes useful again.

03Watch the effects of constraints

Memory pressure can end a process, while CPU limits can increase latency. Monitor these effects rather than treating limits as a one-time checkbox.

Your turn

Start notes:1.0 as api with --memory 128m, --cpus 1, and --restart on-failure. Run detached.

What the checks look for

  • Applies both budgets
  • Chooses failure-based restart
Try it in the editor →

Take this with you

Use resource limits together with observation and capacity planning.

Go a little further

Explain which metric would reveal that a CPU limit is affecting latency.

Learn Docker & Containers for free

20 short lessons with real code and instant checks.

See the whole course →