Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

server: autoscale JVM heap options #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
$inputbuffer_ring_size = $graylog2::server::params::inputbuffer_ring_size,
$inputbuffer_wait_strategy = $graylog2::server::params::inputbuffer_wait_strategy,
$is_master = $graylog2::server::params::is_master,
$max_heap = "${graylog2::server::params::max_heap}m",
$perm_size = "${graylog2::server::params::perm_size}m",
$java_opts = $graylog2::server::params::java_opts,
$java_opts_extra = $graylog2::server::params::java_opts_extra,
$lb_recognition_period_seconds = $graylog2::server::params::lb_recognition_period_seconds,
$ldap_connection_timeout = $graylog2::server::params::ldap_connection_timeout,
$message_journal_dir = $graylog2::server::params::message_journal_dir,
Expand Down Expand Up @@ -206,7 +209,10 @@
inputbuffer_ring_size => $inputbuffer_ring_size,
inputbuffer_wait_strategy => $inputbuffer_wait_strategy,
is_master => $is_master,
max_heap => $max_heap,
perm_size => $perm_size,
java_opts => $java_opts,
java_opts_extra => $java_opts_extra,
lb_recognition_period_seconds => $lb_recognition_period_seconds,
ldap_connection_timeout => $ldap_connection_timeout,
message_journal_dir => $message_journal_dir,
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
$inputbuffer_ring_size,
$inputbuffer_wait_strategy,
$is_master,
$max_heap,
$perm_size,
$java_opts,
$java_opts_extra,
$lb_recognition_period_seconds,
$ldap_connection_timeout,
$message_journal_dir,
Expand Down
5 changes: 4 additions & 1 deletion manifests/server/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@
$inputbuffer_ring_size = '65536'
$inputbuffer_wait_strategy = 'blocking'
$is_master = true
$java_opts = '-Xms1g -Xmx1g -XX:NewRatio=1 -XX:PermSize=128m -XX:MaxPermSize=256m -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow'
$max_heap = clamp(1024, $::memorysize_mb / 2, 32000)
$perm_size = clamp(256, $max_heap / 20, 1024)
$java_opts = '-server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow'
$java_opts_extra = ''
$lb_recognition_period_seconds = '3'
$ldap_connection_timeout = '2000'
$message_journal_dir = '/var/lib/graylog-server/journal'
Expand Down
18 changes: 17 additions & 1 deletion spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
let(:default_facts) do
{
:osfamily => dist,
:memorysize_mb => 12000,
}
end

Expand All @@ -40,7 +41,7 @@
should contain_package('graylog-server').with_ensure('installed')
}
it {
should contain_file(defaults_path).with_content(/^GRAYLOG_SERVER_JAVA_OPTS="-Xms1g -Xmx1g -XX:NewRatio=1 -XX:PermSize=128m -XX:MaxPermSize=256m -server -XX:\+ResizeTLAB -XX:\+UseConcMarkSweepGC -XX:\+CMSConcurrentMTEnabled -XX:\+CMSClassUnloadingEnabled -XX:\+UseParNewGC -XX:-OmitStackTraceInFastThrow"/)
should contain_file(defaults_path).with_content(/^GRAYLOG_SERVER_JAVA_OPTS="-Xms6000m -Xmx6000m -XX:NewRatio=1 -XX:PermSize=300m -XX:MaxPermSize=300m -server -XX:\+ResizeTLAB -XX:\+UseConcMarkSweepGC -XX:\+CMSConcurrentMTEnabled -XX:\+CMSClassUnloadingEnabled -XX:\+UseParNewGC -XX:-OmitStackTraceInFastThrow"/)
}
end

Expand All @@ -60,4 +61,19 @@
end
end

context 'should allow to set Xms and Xmx through max_heap, and PermSize through perm_size' do
let(:facts) do
{
}.merge default_facts
end
let(:params) do
{
:max_heap => '3g',
:perm_size => '300m',
}.merge default_params
end
it {
should contain_file(defaults_path).with_content(/^GRAYLOG_SERVER_JAVA_OPTS="-Xms3g -Xmx3g -XX:NewRatio=1 -XX:PermSize=300m -XX:MaxPermSize=300m -server -XX:\+ResizeTLAB -XX:\+UseConcMarkSweepGC -XX:\+CMSConcurrentMTEnabled -XX:\+CMSClassUnloadingEnabled -XX:\+UseParNewGC -XX:-OmitStackTraceInFastThrow"/)
}
end
end
8 changes: 7 additions & 1 deletion templates/server.default.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
# Path to the java executable.
JAVA=/usr/bin/java

<%- if @java_opts.include? '-Xms' -%>
# Default Java options for heap and garbage collection.
GRAYLOG_SERVER_JAVA_OPTS="<%= @java_opts %>"
GRAYLOG_SERVER_JAVA_OPTS="<%= @java_opts %><%= @java_opts_extra %>"
<%- else -%>
# Default Java options for heap and garbage collection.
<%- jvm_memory="-Xms#{@max_heap} -Xmx#{@max_heap} -XX:NewRatio=1 -XX:PermSize=#{@perm_size} -XX:MaxPermSize=#{@perm_size}" -%>
GRAYLOG_SERVER_JAVA_OPTS="<%= jvm_memory %> <%= @java_opts %><%= @java_opts_extra %>"
<%- end -%>

# Pass some extra args to graylog-server. (i.e. "-d" to enable debug mode)
GRAYLOG_SERVER_ARGS="<%= @extra_args %>"
Expand Down
8 changes: 7 additions & 1 deletion templates/server.sysconfig.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
# Path to the java executable.
JAVA=/usr/bin/java

<%- if @java_opts.include? '-Xms' -%>
# Might be used to adjust the Java heap size. (i.e. "-Xms1024m -Xmx2048m")
GRAYLOG_SERVER_JAVA_OPTS="<%= @java_opts %>"
GRAYLOG_SERVER_JAVA_OPTS="<%= @java_opts %><%= @java_opts_extra %>"
<%- else -%>
# Might be used to adjust the Java heap size. (i.e. "-Xms1024m -Xmx2048m")
<%- jvm_memory="-Xms#{@max_heap} -Xmx#{@max_heap} -XX:NewRatio=1 -XX:PermSize=#{@perm_size} -XX:MaxPermSize=#{@perm_size}" -%>
GRAYLOG_SERVER_JAVA_OPTS="<%= jvm_memory %> <%= @java_opts %><%= @java_opts_extra %>"
<%- end -%>

# Pass some extra args to graylog-server. (i.e. "-d" to enable debug mode)
GRAYLOG_SERVER_ARGS="<%= @extra_args %>"
Expand Down