[GH-ISSUE #204] How to specify the number of cpus and memory available to each App launched by wolf. #137

Open
opened 2026-10-15 12:57:02 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @DRFR33MAN24 on GitHub (May 22, 2025).
Original GitHub issue: https://github.com/games-on-whales/wolf/issues/204

Hi and thanks for this great project, I was just wondering: since wolf is designed to handle multiple streaming sessions in isolated docker containers, how can I set the maximum cpus and memory for these apps, the scenario let's say multiple client are streaming video games on the same machine and one of them is causing a bottleneck, this would certainly reflect on others.

it would be cool if I can set max cpus in config.toml and wolf would bypass these as docker run arguments, now in 4 cpu machine I can fix each client with two cpus and avoid unbalanced usage.
something like:

docker run --cpus="2" firefox
docker run --cpus="2" retrostream

Originally created by @DRFR33MAN24 on GitHub (May 22, 2025). Original GitHub issue: https://github.com/games-on-whales/wolf/issues/204 Hi and thanks for this great project, I was just wondering: since wolf is designed to handle multiple streaming sessions in isolated docker containers, how can I set the maximum cpus and memory for these apps, the scenario let's say multiple client are streaming video games on the same machine and one of them is causing a bottleneck, this would certainly reflect on others. it would be cool if I can set max cpus in config.toml and wolf would bypass these as docker run arguments, now in 4 cpu machine I can fix each client with two cpus and avoid unbalanced usage. something like: docker run --cpus="2" firefox docker run --cpus="2" retrostream
Author
Owner

@ABeltramo commented on GitHub (May 22, 2025):

You can tweak all sorts of low level Docker details by editing the base_create_json property in the config.toml. That JSON config comes from the Docker APIs for creating a container and will be merged with all the other parameters that Wolf needs.

Now, specifically for CPU limiting there are a few different options in Docker like: CpuPeriod, CpuQuota, CpusetCpus (you can see them if you open up the HostConfig object definition in the link that I've posted above

Image

The easiest option for you seems to be NanoCpus which should be equivalent to set --cpus (just in nano seconds notation). So to set 2 like in your example you'll have to set 2000000000 IIUC.

To recap: given the Firefox default base_create_json config, you'll have to edit it to be:

{
  "HostConfig": {
    "NanoCpus": 2000000000,
    "IpcMode": "host",
    "Privileged": false,
    "CapAdd": ["NET_RAW", "MKNOD", "NET_ADMIN"],
    "DeviceCgroupRules": ["c 13:* rmw", "c 244:* rmw"]
  }
}

And this will be equivalent to start the container with --cpus="2".
Let me know if that works!

<!-- gh-comment-id:2900444176 --> @ABeltramo commented on GitHub (May 22, 2025): You can tweak all sorts of low level Docker details by editing the `base_create_json` property in the `config.toml`. That JSON config comes from the [Docker APIs for creating a container](https://docs.docker.com/reference/api/engine/version/v1.40/#tag/Container/operation/ContainerCreate) and will be merged with all the other parameters that Wolf needs. Now, specifically for CPU limiting there are a few different options in Docker like: `CpuPeriod`, `CpuQuota`, `CpusetCpus` (you can see them if you open up the `HostConfig` object definition in the link that I've posted above ![Image](https://github.com/user-attachments/assets/9004ed98-454f-4e5d-bd2f-0af0a3392503) The easiest option for you seems to be `NanoCpus` which should be equivalent to set `--cpus` (just in nano seconds notation). So to set `2` like in your example you'll have to set `2000000000` IIUC. To recap: given the Firefox default `base_create_json` config, you'll have to edit it to be: ```json { "HostConfig": { "NanoCpus": 2000000000, "IpcMode": "host", "Privileged": false, "CapAdd": ["NET_RAW", "MKNOD", "NET_ADMIN"], "DeviceCgroupRules": ["c 13:* rmw", "c 244:* rmw"] } } ``` And this will be equivalent to start the container with `--cpus="2"`. Let me know if that works!
Author
Owner

@DRFR33MAN24 commented on GitHub (May 22, 2025):

Great thank you, because the other day I was running two apps with PCSX2 image and I tried god of war 2 on one of them, it made the other app stutter significantly.

However does this option mean 2 ghz clock speed or 2 cores?

<!-- gh-comment-id:2901548120 --> @DRFR33MAN24 commented on GitHub (May 22, 2025): Great thank you, because the other day I was running two apps with PCSX2 image and I tried god of war 2 on one of them, it made the other app stutter significantly. However does this option mean 2 ghz clock speed or 2 cores?
Author
Owner

@ABeltramo commented on GitHub (May 22, 2025):

It should mean 2 cores, same as --cpus, but I haven't tested this myself..

<!-- gh-comment-id:2901913178 --> @ABeltramo commented on GitHub (May 22, 2025): It should mean 2 cores, same as `--cpus`, but I haven't tested this myself..
Author
Owner

@salty2011 commented on GitHub (Jun 13, 2025):

Some of the basic functionality as @ABeltramo stated is covered through the container launch options you can specify in the App configuration.

Im chiming in here cause I think some of this capability to configure could live in WolfManager to make doing some of these settings more easy.

Have created an issue in WolfManager for basic app management... to this idea isnt lost

<!-- gh-comment-id:2969405259 --> @salty2011 commented on GitHub (Jun 13, 2025): Some of the basic functionality as @ABeltramo stated is covered through the container launch options you can specify in the App configuration. Im chiming in here cause I think some of this capability to configure could live in WolfManager to make doing some of these settings more easy. Have created an issue in WolfManager for basic app management... to this idea isnt lost
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/wolf#137
No description provided.