Use a single memoryLimit instead of memory and memorySwap

We will make the percent allocation dynamic depending on the system.

When we have servers with a large amount of RAM but little swap, we
seem to use a lot of swap because of 50% allocation strategy. In such
systems, we run out of swap and thus have OOM errors even though there
is a lot of RAM available!
This commit is contained in:
Girish Ramakrishnan
2021-01-19 19:05:35 -08:00
parent 24db6630ee
commit 025eb18411
5 changed files with 64 additions and 26 deletions
+11 -17
View File
@@ -407,11 +407,7 @@ function getService(id, callback) {
memoryPercent: 0,
error: null,
healthcheck: null,
config: {
// If a property is not set then we cannot change it through the api, see below
// memory: 0,
// memorySwap: 0
}
config: {}
};
containerStatusFunc(function (error, result) {
@@ -429,9 +425,8 @@ function getService(id, callback) {
const serviceConfig = servicesConfig[name];
tmp.config = Object.assign({}, serviceConfig);
if ((!tmp.config.memory || !tmp.config.memorySwap) && service.defaultMemoryLimit) {
tmp.config.memory = service.defaultMemoryLimit;
tmp.config.memorySwap = tmp.config.memory * 2;
if (!tmp.config.memoryLimit && service.defaultMemoryLimit) {
tmp.config.memoryLimit = service.defaultMemoryLimit * 2;
}
callback(null, tmp);
@@ -458,9 +453,8 @@ function configureService(id, data, callback) {
if (!servicesConfig[name]) servicesConfig[name] = {};
// if not specified we clear the entry and use defaults
if (!data.memory || !data.memorySwap) {
delete servicesConfig[name].memory;
delete servicesConfig[name].memorySwap;
if (!data.memoryLimit) {
delete servicesConfig[name].memoryLimit;
} else {
servicesConfig[name] = data;
}
@@ -814,9 +808,9 @@ function updateServiceConfig(platformConfig, callback) {
async.eachSeries([ 'mysql', 'postgresql', 'mail', 'mongodb', 'graphite' ], function iterator(serviceName, iteratorCallback) {
const containerConfig = platformConfig[serviceName];
let memory, memorySwap;
if (containerConfig && containerConfig.memory && containerConfig.memorySwap) {
memory = containerConfig.memory;
memorySwap = containerConfig.memorySwap;
if (containerConfig && containerConfig.memoryLimit) {
memory = containerConfig.memoryLimit / 2;
memorySwap = containerConfig.memoryLimit;
} else {
memory = SERVICES[serviceName].defaultMemoryLimit;
memorySwap = memory * 2;
@@ -841,9 +835,9 @@ function updateAppServiceConfig(name, instance, servicesConfig, callback) {
const serviceConfig = servicesConfig[name];
let memory, memorySwap;
if (serviceConfig && serviceConfig.memory && serviceConfig.memorySwap) {
memory = serviceConfig.memory;
memorySwap = serviceConfig.memorySwap;
if (serviceConfig && serviceConfig.memoryLimit) {
memory = serviceConfig.memoryLimit / 2;
memorySwap = serviceConfig.memoryLimit;
} else {
memory = APP_SERVICES[name].defaultMemoryLimit;
memorySwap = memory * 2;