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:
Girish Ramakrishnan
2024-04-10 17:38:49 +02:00
parent 2afaf1f36d
commit b4e4f26361
15 changed files with 265 additions and 91 deletions

View File

@@ -27,7 +27,7 @@ exports = module.exports = {
setTurn,
setRedis,
setMemoryLimit,
setCpuShares,
setCpuQuota,
setAutomaticBackup,
setAutomaticUpdate,
setReverseProxyConfig,
@@ -281,13 +281,13 @@ async function setMemoryLimit(req, res, next) {
next(new HttpSuccess(202, { taskId: result.taskId }));
}
function setCpuShares(req, res, next) {
function setCpuQuota(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');
if (typeof req.body.cpuShares !== 'number') return next(new HttpError(400, 'cpuShares is not a number'));
if (typeof req.body.cpuQuota !== 'number') return next(new HttpError(400, 'cpuQuota is not a number'));
apps.setCpuShares(req.app, req.body.cpuShares, AuditSource.fromRequest(req), function (error, result) {
apps.setCpuQuota(req.app, req.body.cpuQuota, AuditSource.fromRequest(req), function (error, result) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId: result.taskId }));