refactor: optimize memory usage of blaze

This commit is contained in:
Torben Brenner 2024-02-20 15:15:49 +01:00
parent 8854670f4d
commit 7d07c0623d
4 changed files with 15 additions and 3 deletions

View File

@ -8,8 +8,8 @@ services:
container_name: bridgehead-bbmri-blaze
environment:
BASE_URL: "http://bridgehead-bbmri-blaze:8080"
JAVA_TOOL_OPTIONS: "-Xmx4g"
LOG_LEVEL: "debug"
JAVA_TOOL_OPTIONS: "-Xmx${BLAZE_MEMORY_CAP}m"
DB_BLOCK_CACHE_SIZE: $BLAZE_MEMORY_CAP
ENFORCE_REFERENTIAL_INTEGRITY: "false"
volumes:
- "blaze-data:/app/data"

View File

@ -50,6 +50,7 @@ loadVars() {
source /etc/bridgehead/$PROJECT.local.conf || fail_and_report 1 "Found /etc/bridgehead/$PROJECT.local.conf but failed to import"
fi
fetchVarsFromVaultByFile /etc/bridgehead/$PROJECT.conf || fail_and_report 1 "Unable to fetchVarsFromVaultByFile"
setBlazeMemoryCap
[ -e ./$PROJECT/vars ] && source ./$PROJECT/vars
set +a

View File

@ -6,7 +6,8 @@ services:
container_name: bridgehead-ccp-blaze
environment:
BASE_URL: "http://bridgehead-ccp-blaze:8080"
JAVA_TOOL_OPTIONS: "-Xmx4g"
JAVA_TOOL_OPTIONS: "-Xmx${BLAZE_MEMORY_CAP}m"
DB_BLOCK_CACHE_SIZE: $BLAZE_MEMORY_CAP
ENFORCE_REFERENTIAL_INTEGRITY: "false"
volumes:
- "blaze-data:/app/data"

View File

@ -155,6 +155,16 @@ setHostname() {
fi
}
# blaze memory cap should be approximately a quarter of the system memory
# the memory cap will be applied to both the java heap size and db clock cache
setBlazeMemoryCap() {
if [ -z "$BLAZE_MEMORY_CAP" ]; then
system_memory=$(grep MemTotal /proc/meminfo | grep -Po '\d+');
system_memory_in_mb=$(("$system_memory"/1024));
export BLAZE_MEMORY_CAP=$(("$system_memory_in_mb"/4));
fi
}
# Takes 1) The Backup Directory Path 2) The name of the Service to be backuped
# Creates 3 Backups: 1) For the past seven days 2) For the current month and 3) for each calendar week
createEncryptedPostgresBackup(){