refactor: tune configuration of blaze according to system memory

This commit is contained in:
Torben Brenner 2024-03-11 09:58:30 +01:00
parent eeb17e7bfe
commit e1e523f1ac
2 changed files with 17 additions and 4 deletions

View File

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

View File

@ -155,13 +155,26 @@ setHostname() {
fi fi
} }
# blaze memory cap should be approximately a quarter of the system memory # This function optimizes the usage of memory through blaze, according to the official performance tuning guide:
# the memory cap will be applied to both the java heap size and db clock cache # https://github.com/samply/blaze/blob/master/docs/tuning-guide.md
setBlazeMemoryCap() { # Short summary of the adjustments made:
# - set blaze memory cap to a quarter of the system memory
# - set db block cache size to a quarter of the system memory
# - limit resource count allowed in blaze to 1,25M per 4GB available system memory
optimizeBlazeMemoryUsage() {
if [ -z "$BLAZE_MEMORY_CAP" ]; then if [ -z "$BLAZE_MEMORY_CAP" ]; then
system_memory_in_mb=$(free -m | grep 'Mem:' | awk '{print $2}'); system_memory_in_mb=$(free -m | grep 'Mem:' | awk '{print $2}');
export BLAZE_MEMORY_CAP=$(("$system_memory_in_mb"/4)); export BLAZE_MEMORY_CAP=$(("$system_memory_in_mb"/4));
fi fi
if [ -z "$BLAZE_RESOURCE_CACHE_CAP" ]; then
available_system_memory_chuncks=$((BLAZE_MEMORY_CAP / 1000))
if [ $available_system_memory_chuncks -eq 0 ]; then
log WARN "Only ${BLAZE_MEMORY_CAP} system memory available for Blaze. If your Blaze stores more than 128000 fhir ressources it will run significally slower."
export BLAZE_RESOURCE_CACHE_CAP=128000;
else
export BLAZE_RESOURCE_CACHE_CAP=$((available_system_memory_chuncks * 312500))
fi
fi
} }
# Takes 1) The Backup Directory Path 2) The name of the Service to be backuped # Takes 1) The Backup Directory Path 2) The name of the Service to be backuped