mirror of https://github.com/samply/bridgehead.git
Merge pull request #154 from samply/refactor/blazePerformanceTuning
Optimize memory usage of Blaze
This commit is contained in:
commit
a87e9b9284
|
@ -8,8 +8,9 @@ services:
|
||||||
container_name: bridgehead-bbmri-blaze
|
container_name: bridgehead-bbmri-blaze
|
||||||
environment:
|
environment:
|
||||||
BASE_URL: "http://bridgehead-bbmri-blaze:8080"
|
BASE_URL: "http://bridgehead-bbmri-blaze:8080"
|
||||||
JAVA_TOOL_OPTIONS: "-Xmx4g"
|
JAVA_TOOL_OPTIONS: "-Xmx${BLAZE_MEMORY_CAP:-4096}m"
|
||||||
LOG_LEVEL: "debug"
|
DB_RESOURCE_CACHE_SIZE: ${BLAZE_RESOURCE_CACHE_CAP:-2500000}
|
||||||
|
DB_BLOCK_CACHE_SIZE: $BLAZE_MEMORY_CAP
|
||||||
ENFORCE_REFERENTIAL_INTEGRITY: "false"
|
ENFORCE_REFERENTIAL_INTEGRITY: "false"
|
||||||
volumes:
|
volumes:
|
||||||
- "blaze-data:/app/data"
|
- "blaze-data:/app/data"
|
||||||
|
|
|
@ -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"
|
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"
|
||||||
|
optimizeBlazeMemoryUsage
|
||||||
[ -e ./$PROJECT/vars ] && source ./$PROJECT/vars
|
[ -e ./$PROJECT/vars ] && source ./$PROJECT/vars
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@ services:
|
||||||
container_name: bridgehead-ccp-blaze
|
container_name: bridgehead-ccp-blaze
|
||||||
environment:
|
environment:
|
||||||
BASE_URL: "http://bridgehead-ccp-blaze:8080"
|
BASE_URL: "http://bridgehead-ccp-blaze:8080"
|
||||||
JAVA_TOOL_OPTIONS: "-Xmx4g"
|
JAVA_TOOL_OPTIONS: "-Xmx${BLAZE_MEMORY_CAP:-4096}m"
|
||||||
|
DB_RESOURCE_CACHE_SIZE: ${BLAZE_RESOURCE_CACHE_CAP:-2500000}
|
||||||
|
DB_BLOCK_CACHE_SIZE: $BLAZE_MEMORY_CAP
|
||||||
ENFORCE_REFERENTIAL_INTEGRITY: "false"
|
ENFORCE_REFERENTIAL_INTEGRITY: "false"
|
||||||
volumes:
|
volumes:
|
||||||
- "blaze-data:/app/data"
|
- "blaze-data:/app/data"
|
||||||
|
|
|
@ -155,6 +155,28 @@ setHostname() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function optimizes the usage of memory through blaze, according to the official performance tuning guide:
|
||||||
|
# https://github.com/samply/blaze/blob/master/docs/tuning-guide.md
|
||||||
|
# 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
|
||||||
|
system_memory_in_mb=$(free -m | grep 'Mem:' | awk '{print $2}');
|
||||||
|
export BLAZE_MEMORY_CAP=$(("$system_memory_in_mb"/4));
|
||||||
|
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
|
||||||
# Creates 3 Backups: 1) For the past seven days 2) For the current month and 3) for each calendar week
|
# Creates 3 Backups: 1) For the past seven days 2) For the current month and 3) for each calendar week
|
||||||
createEncryptedPostgresBackup(){
|
createEncryptedPostgresBackup(){
|
||||||
|
|
Loading…
Reference in New Issue