October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Limit CPU Usage on a Linux VPS (systemd, Docker, and cgroups)

A practical guide to capping Linux VPS CPU usage for systemd services, Docker containers, one-off commands, and game servers—plus verification and cgroup troubleshooting.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The most reliable way to cap a long-running process on a Linux VPS is to place it in the correct control group and apply a CPU bandwidth limit. For a systemd service, create a drop-in with CPUQuota=50%; for a Docker container, use --cpus="0.5". These quotas are measured against one CPU, so 50% is half of one core and 200% is two cores. Use weights when you want fair sharing rather than a ceiling, and CPU affinity when you need to restrict execution to particular cores.

The procedure below covers game servers and other VPS workloads managed by systemd, Docker, a one-off command, or a cgroup. It also shows how to verify the effective limit and diagnose throttling caused by parent cgroups or the VPS provider.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the control boundary first

A CPU limit only behaves predictably when it is applied to the boundary that owns the workload. Identify that boundary before changing settings:

Workload Best control What it does Persistence
systemd service CPUQuota= Hard CPU-time ceiling for the service cgroup Persistent drop-in
Docker container --cpus or --cpu-period/--cpu-quota Hard ceiling for the container cgroup Container configuration or recreate command
One-off command systemd-run --scope -p CPUQuota=... Temporary cgroup around that command Until the scope exits
Several related processes A dedicated systemd slice or cgroup One limit shared by every member Depends on the slice definition
Core placement AllowedCPUs= or --cpuset-cpus Restricts which CPUs may run the workload Persistent when stored with the unit or container

A quota limits total CPU time. A CPU set limits placement. A weight changes the share received when multiple workloads compete. They solve different problems and can be combined, but none of them increases the CPU capacity assigned by your VPS plan.

#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

How CPU percentages work on a VPS

systemd defines CPUQuota= as a percentage of one CPU. 20% allows one-fifth of a single CPU; 100% allows one full CPU; 200% allows two CPUs worth of execution. Docker’s --cpus uses the same idea as a number of CPUs, so --cpus="0.5" allows half a CPU.

On a multi-vCPU VPS, 100% does not mean “100% of the whole machine.” A service capped at 100% can consume one core while leaving other cores available. A service capped at 50% can still show 100% in a monitor whose denominator is the process’s single-core capacity, depending on how that monitor reports percentages. Check the monitor’s definition before interpreting graphs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set a limit below the VPS’s practical capacity when the operating system, SSH access, storage work, database, or other game services must remain responsive. A quota is a maximum, not a reservation: unused quota is not automatically transferred to another service by the quota controller.

Limit a systemd service with CPUQuota

Use a systemd drop-in for a service that should retain the limit after reboot and package upgrades. Replace example.service with the actual unit name.

  1. Confirm the unit and its current state:

    systemctl status example.service
    systemctl show example.service -p FragmentPath -p ControlGroup
  2. Create the drop-in directory and file:

    sudo mkdir -p /etc/systemd/system/example.service.d
    sudo editor /etc/systemd/system/example.service.d/cpu.conf

    Enter:

    [Service]
    CPUQuota=50%
  3. Reload unit definitions and restart the service:

    sudo systemctl daemon-reload
    sudo systemctl restart example.service
  4. Inspect the effective quota rather than assuming the file won:

    systemctl show example.service -p CPUQuotaPerSecUSec
    systemctl status example.service
  5. Generate realistic load and watch a CPU monitor. A quota throttles execution after the cgroup consumes its configured bandwidth; it does not terminate the process.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CPUQuotaPerSecUSec is the normalized property systemd exposes for the active unit. If it is empty or differs from the intended value, another drop-in, a parent slice, or a unit generated by the service manager may be controlling the workload.

Rank #2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
  • Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

Pick a quota for a game server

Start with the server’s normal peak rather than its idle usage. For example, a latency-sensitive game server might receive a quota that leaves measurable headroom for the kernel and network stack. Apply the limit during a busy match or scheduled event, then check tick time, frame or simulation latency, and log warnings. If the server becomes regularly throttled, lower player or simulation load, move another workload, or raise the quota; a hard cap cannot preserve latency when demand exceeds the allowance.

Use CPUWeight for proportional sharing

A quota is appropriate when a workload must never exceed a ceiling. If instead several services should share spare CPU and one should receive more of the available time during contention, use a weight.

[Service]
CPUWeight=200

In cgroup v2, the default cpu.weight is 100. A weight of 200 gives that cgroup twice the scheduler weight of a competing cgroup with weight 100, assuming they are siblings under the same parent and are both runnable. Weight does not reserve two CPUs, and it does not stop a service from using all available CPU when no sibling is competing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use CPUWeight= for background jobs, build tasks, or noncritical game services that should yield to an interactive or latency-sensitive service. You can also use the familiar nice-style interface through cpu.weight.nice, whose range is -20 through 19. These are scheduler preferences, not deterministic ceilings.

Restrict a service to selected CPUs with AllowedCPUs

CPU affinity is useful when you want a workload confined to particular vCPUs, for example to keep a game server away from a CPU handling storage or networking interrupts.

[Service]
AllowedCPUs=0,1

After adding the setting to the drop-in, run sudo systemctl daemon-reload and restart the unit. Affinity changes where tasks may run; it does not, by itself, limit the total CPU time they can consume. A service pinned to two CPUs can still consume both completely unless a quota is also configured.

CPU numbering is the numbering visible inside the VPS. A provider may schedule those virtual CPUs on different physical cores over time, so pinning does not guarantee physical-core isolation.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit

Limit a one-off command with a transient systemd scope

For a test, maintenance job, or temporary game-server process, place the command in a transient scope instead of editing a permanent unit:

sudo systemd-run --scope -p CPUQuota=50% command --argument value

systemd prints the transient unit name. Use that name with systemctl status or systemctl show while the command runs. This requires a host that delegates the needed resource controller to the user or service starting the scope. If the command runs outside the expected cgroup, or systemd rejects the property, confirm cgroup delegation and privileges before relying on the scope in automation.

Limit a Docker container

Docker exposes a convenient CPU count and an explicit period/quota form. The following starts a container with half of one CPU:

docker run --cpus="0.5" image

Docker documents this as equivalent to:

docker run --cpu-period=100000 --cpu-quota=50000 image

The period and quota are expressed in microseconds. The container may run during each period until its quota is consumed, then it is throttled until the next period.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restrict container placement

To allow execution only on CPU 0:

docker run --cpus="0.5" --cpuset-cpus="0" image

Use a list or range that matches the CPUs visible in the VPS, such as --cpuset-cpus="0,2" or --cpuset-cpus="0-1". The CPU set and quota are independent: the example is limited to half a CPU of total time and may run only on CPU 0.

Apply limits to an existing container

For a running container, update the resource settings and then verify them:

docker update --cpus="0.5" --cpuset-cpus="0" container_name
docker inspect container_name

Whether a particular update is accepted depends on the Docker version and runtime configuration. If the update is refused, recreate the container with the desired flags or update the Compose or orchestration definition that owns it, otherwise the next deployment can remove your manual change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
SANOOV Raspberry Pi 5 4GB Kit, 4GB RAM Single Board Computer with Active Cooler and ABS Case, Complete Raspberry Pi 5 Starter Kit for IoT Robotics Retro Gaming
  • All-in-One Complete Kit: This SANOOV RPi 5 bundle comes with Raspberry Pi 5 4GB RAM single board, active cooler, durable ABS case and screwdriver. No extra parts needed, ready to use right out of the box for beginners and hobbyists
  • Powerful Single Board Computer: Equipped with 4GB RAM and high-performance processor, delivers fast running speed for 4K playback, AI projects, programming and daily computing tasks. SANOOV for raspberry pi 5 4GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience
  • Efficient Active Cooler: Effectively lowers operating temperature and prevents performance throttling. Runs quietly even under long-time heavy load, ensures stable operation all day long. SANOOV RPi 5 4GB kit offer an active cooler, which combines an aluminium heatsink with a high-performance PWM fan. Active cooler is fully compatible with the Pi OS, which can effectively reduce the temperature of RPi5 and ensure its good performance during long-term high load operation
  • Sturdy ABS Protective Case: Well-fitted for Raspberry Pi 5 board, can be secured with 4 screws to effectively protect the Pi 5 motherboard from damage, reserves full access to all ports and buttons. SANOOV uses ABS material to produce the case, which has a softer texture and feel. Meanwhile, SANOOV case adopts a layered design for easy disassembly and installation. (Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
  • Wide Application & Full Compatibility: Seamlessly compatible with official OS and mainstream peripheral accessories for Raspberry Pi 5. Whether you are a beginner, student, electronics hobbyist or professional developer, this all-in-one kit meets your diverse needs. It excels in IoT projects, robotics design, retro gaming devices, home media servers and other DIY creations. Backed by a large global community, you can easily find guides, technical support and shared projects online

Container persistence

A limit supplied only to an interactive docker run command is not a host-wide policy. Store it in the command used by your deployment system, a Compose service definition, or another declarative configuration. If an orchestrator recreates the container, verify that the replacement has the same CPU settings.

Inspect cgroup v2 directly

Modern Linux systems commonly use cgroup v2. Find the workload’s cgroup from the service or process, then inspect the controller files in that directory. The key files are:

  • cpu.max: quota and period. A quota value paired with a period expresses the maximum bandwidth; the word max means no quota.
  • cpu.weight: proportional scheduling weight, with a default of 100.
  • cpu.stat: CPU usage and throttling counters for the cgroup hierarchy.
  • cpu.stat.local: throttling incurred on the cgroup’s own runqueues. The kernel notes that this can include throttling inherited from ancestor bandwidth limits.

For a systemd service, first obtain its cgroup path:

systemctl show example.service -p ControlGroup

Then inspect the corresponding files beneath the mounted cgroup v2 hierarchy, commonly under /sys/fs/cgroup:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo cat /sys/fs/cgroup/.../cpu.max
sudo cat /sys/fs/cgroup/.../cpu.weight
sudo cat /sys/fs/cgroup/.../cpu.stat
sudo cat /sys/fs/cgroup/.../cpu.stat.local

Use the actual path returned by systemd; do not copy the ellipsis literally. Direct writes to controller files are easy to lose when systemd or Docker manages the cgroup. Prefer the owning manager’s configuration for permanent changes, and use direct inspection primarily to verify what the manager installed.

Hard quota, weight, affinity, or nice: which should you use?

Goal Setting Ceiling? Behavior under contention
Never exceed a defined CPU allowance CPUQuota=, Docker --cpus, or quota/period Yes Tasks are throttled after bandwidth is consumed
Give one service more of the spare CPU CPUWeight= or cpu.weight No Relative share changes only while competitors are runnable
Keep a workload on selected vCPUs AllowedCPUs= or --cpuset-cpus No Tasks cannot run outside the selected CPU set
Make a process nicer to other fair-class tasks nice or cpu.weight.nice No Scheduler preference changes; usage can still reach available capacity

Combining controls is valid when the goals differ: for example, pin a game server to CPUs 0–1 with AllowedCPUs=0,1 and cap it at CPUQuota=150%. The quota still represents one and a half CPUs total, shared across all processes in the service cgroup.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify that the limit is really active

Always verify after changing a unit, container, or cgroup. Configuration files can be syntactically correct while a different fragment or parent controller determines the effective limit.

Best Value
RasTech Raspberry Pi 5 8GB Kit with Active Cooler and Pi5 Case
  • 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
  • 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
  • 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
  • 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
  • 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.
  1. Check the manager’s effective property:

    systemctl show example.service -p CPUQuotaPerSecUSec -p CPUWeight -p AllowedCPUs
  2. Confirm the process is in the expected cgroup:

    systemctl show example.service -p ControlGroup
    cat /proc/PID/cgroup
  3. For Docker, inspect the container’s resource configuration:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    docker inspect container_name
  4. Observe behavior under sustained load with a CPU monitor and the service’s own latency metrics. A short idle test cannot prove a quota is effective.

  5. Read cgroup counters before and after the load test. Rising throttling counters show that the cgroup has exhausted its allowed bandwidth.

A quota may not make the host’s aggregate CPU graph fall by the same percentage if another process uses the freed capacity. Measure the limited cgroup or service, not only the VPS-wide total.

Troubleshoot unexpected throttling or no visible limit

The drop-in was ignored

Run systemctl daemon-reload, restart the unit, and inspect CPUQuotaPerSecUSec. Check every drop-in and the unit’s parent slice for a conflicting value. A generated unit or an administrator’s later fragment can override the file you edited.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Throttling occurs below the local quota

Inspect cpu.stat and cpu.stat.local, then examine parent slices. The kernel documents that local throttling can include bandwidth limits inherited from an ancestor cgroup. A VPS host or provider-level policy can also impose a limit that is invisible inside the guest. If the guest’s settings are correct but available CPU remains constrained, ask the provider which host-level CPU policy applies to the plan.

The service is slow but no quota counter rises

CPU may not be the bottleneck. Check disk wait, memory pressure, network delay, locks, and the service’s own tick or frame metrics. A CPU set can also create a bottleneck by confining a multithreaded process to too few vCPUs even when its quota is high.

Nice did not enforce a maximum

nice and cpu.weight.nice influence scheduler preference for fair-class processes. They do not provide the deterministic ceiling supplied by a CFS quota. Replace them with a quota when the requirement is “never exceed this amount.”

LimitCPU stopped the wrong thing

Per-process LimitCPU= is a process resource limit, not the service-wide cgroup control described here. Systemd notes that process limits can be accounted independently after forks. For a daemon with worker processes, use service-level controls such as CPUQuota= so the entire service cgroup shares one policy.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operational safeguards for VPS game servers

  • Leave headroom: reserve capacity for SSH, monitoring, log rotation, networking, and storage-related kernel work.
  • Apply limits at deployment time: keep systemd drop-ins, container flags, or Compose settings under configuration management so a restart does not remove them.
  • Test peak behavior: evaluate a busy match, map load, backup, or scheduled job rather than an idle menu.
  • Watch latency as well as utilization: CPU percentage alone does not reveal simulation stalls or scheduler delay.
  • Document the boundary: record the unit, container, slice, or cgroup path that owns the process; otherwise a later administrator may cap a wrapper while the actual workers run elsewhere.
  • Recheck after platform changes: kernel upgrades, a switch between cgroup v1 and v2, Docker runtime changes, or VPS migrations can alter which controller files and delegation rules are available.

A practical decision sequence

  1. Identify whether the workload is a systemd service, container, transient command, or process group.
  2. Choose a hard quota when exceeding a limit is unacceptable; choose a weight when the workload should yield proportionally; choose a CPU set when placement matters.
  3. Set the value using the manager that owns the workload.
  4. Reload or recreate the workload, then inspect the effective property and cgroup membership.
  5. Run a representative load test and read throttling counters.
  6. If results do not match the setting, inspect ancestor cgroups and provider-level policies before changing the quota again.

This sequence prevents the most common mistake: changing a scheduler preference or a wrapper process when the actual requirement is a persistent, service-wide CPU ceiling.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$419.99
Bestseller No. 3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit
$189.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.