From 0847c38196713d371f6175f23bdd6d2dd937600d Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 28 Oct 2020 09:22:44 -0400 Subject: [PATCH] [deploy] Enable Puma's nakayoshi_fork feature (#11121) * Run GC.compact before fork * Change to nakayoshi_fork --- config/puma.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/puma.rb b/config/puma.rb index 3d0a6c3c4..4dbb059f3 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -26,6 +26,10 @@ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } # workers ENV.fetch("WEB_CONCURRENCY", 2) +# calls GC a handful of times and compacts the heap on Ruby 2.7+ before forking. +# This may reduce memory usage of Puma on MRI. +nakayoshi_fork + # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write