Skip to content

Set ES JVM HEAP Xms equal to Xmx #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions elasticsearch/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if [[ "${INSTANCE_RAM:-}" =~ $regex ]]; then
fi

#determine if req is less then max recommended by ES
echo "Comparing the specificed RAM to the maximum recommended for ElasticSearch..."
echo "Comparing the specified RAM to the maximum recommended for Elasticsearch..."
if [ ${MAX_ES_MEMORY_BYTES} -lt ${num} ]; then
((num = ${MAX_ES_MEMORY_BYTES}))
echo "Downgrading the INSTANCE_RAM to $(($num / BYTES_PER_MEG))m because ${INSTANCE_RAM} will result in a larger heap then recommended."
Expand All @@ -55,15 +55,18 @@ if [[ "${INSTANCE_RAM:-}" =~ $regex ]]; then
echo "Setting the maximum allowable RAM to $(($num / BYTES_PER_MEG))m which is the largest amount available"
fi
else
echo "Unable to determine the maximum allowable RAM for this host in order to configure ElasticSearch"
echo "Unable to determine the maximum allowable RAM for this host in order to configure Elasticsearch"
exit 1
fi

if [[ $num -lt $MIN_ES_MEMORY_BYTES ]]; then
echo "A minimum of $(($MIN_ES_MEMORY_BYTES/$BYTES_PER_MEG))m is required but only $(($num/$BYTES_PER_MEG))m is available or was specified"
exit 1
fi
export ES_JAVA_OPTS="${ES_JAVA_OPTS:-} -Xms128M -Xmx$(($num/2/BYTES_PER_MEG))m"

# Set JVM HEAP size to half of available space
num=$(($num/2/BYTES_PER_MEG))
export ES_JAVA_OPTS="${ES_JAVA_OPTS:-} -Xms${num}m -Xmx${num}m"
echo "ES_JAVA_OPTS: '${ES_JAVA_OPTS}'"
else
echo "INSTANCE_RAM env var is invalid: ${INSTANCE_RAM:-}"
Expand Down