Use jemalloc1 on Puma and Sidekiq to lower the memory usage

More details:
https://www.speedshop.co/2017/12/04/malloc-doubles-ruby-memory.html
This commit is contained in:
Greg 2018-03-20 16:07:55 +01:00
parent b8853a1b5d
commit 8653a8fa97
3 changed files with 3 additions and 1 deletions

View File

@ -42,7 +42,7 @@ user "mastodon" do
end
package %w(imagemagick ffmpeg libxml2-dev libxslt1-dev file git curl pkg-config
libprotobuf-dev protobuf-compiler libidn11 libidn11-dev)
libprotobuf-dev protobuf-compiler libidn11 libidn11-dev libjemalloc1)
node_package "yarn" do
version "1.3.2"

View File

@ -9,6 +9,7 @@ User=<%= @user %>
WorkingDirectory=<%= @app_dir %>
Environment="RAILS_ENV=production"
Environment="DB_POOL=50"
Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1"
ExecStart=<%= @bundle_path %> exec sidekiq -c 5 -q default -q mailers -q pull -q push
TimeoutSec=15
Restart=always

View File

@ -12,6 +12,7 @@ PIDFile=<%= @app_dir %>/tmp/puma.pid
WorkingDirectory=<%= @app_dir %>
Environment="RAILS_ENV=production"
Environment="PORT=3000"
Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1"
ExecStart=<%= @bundle_path %> exec puma -C config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid
ExecStop=<%= @bundle_path %> exec puma -C config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid stop
ExecReload=<%= @bundle_path %> exec pumactl -F config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid phased-restart