Rework cpuShares into cpuQuota
cpuShares is the relative weight wrt other apps. This is used when there is contention for CPU. If we want this, maybe we implement a UI where we show all the apps and let the user re-order them. As it stands, it is confusing. cpuQuota is a more straightforward "hard limit" of the CPU% that you want the app to consume. Can be tested with : stress -c 8 -t 20s
This commit is contained in:
@@ -42,6 +42,7 @@ const apps = require('./apps.js'),
|
||||
debug = require('debug')('box:docker'),
|
||||
Docker = require('dockerode'),
|
||||
fs = require('fs'),
|
||||
os = require('os'),
|
||||
paths = require('./paths.js'),
|
||||
promiseRetry = require('./promise-retry.js'),
|
||||
services = require('./services.js'),
|
||||
@@ -357,7 +358,9 @@ async function createSubcontainer(app, name, cmd, options) {
|
||||
'Name': isAppContainer ? 'unless-stopped' : 'no',
|
||||
'MaximumRetryCount': 0
|
||||
},
|
||||
CpuShares: app.cpuShares,
|
||||
// CpuPeriod (100000 microseconds) and CpuQuota(app.cpuQuota% of CpuPeriod)
|
||||
// 1000000000 is one core https://github.com/moby/moby/issues/24713#issuecomment-233167619 and https://stackoverflow.com/questions/52391877/set-the-number-of-cpu-cores-of-a-container-using-docker-engine-api
|
||||
NanoCPUs: app.cpuQuota === 100 ? 0 : (os.cpus().length * app.cpuQuota/100).toFixed(2) * 1000000000,
|
||||
VolumesFrom: isAppContainer ? null : [ app.containerId + ':rw' ],
|
||||
SecurityOpt: [ 'apparmor=docker-cloudron-app' ],
|
||||
CapAdd: [],
|
||||
|
||||
Reference in New Issue
Block a user