diff --git a/lib/middleware/unicorn_oobgc.rb b/lib/middleware/unicorn_oobgc.rb index b0f7bc759..60c557afe 100644 --- a/lib/middleware/unicorn_oobgc.rb +++ b/lib/middleware/unicorn_oobgc.rb @@ -7,6 +7,9 @@ module Middleware::UnicornOobgc MIN_REQUESTS_PER_OOBGC = 3 + # TUNE ME, for Discourse this number is good + MIN_FREE_SLOTS = 80_000 + def verbose(msg=nil) @verbose ||= ENV["OOBGC_VERBOSE"] == "1" ? :true : :false if @verbose == :true @@ -66,6 +69,10 @@ module Middleware::UnicornOobgc @max_delta = [new_delta, delta].max end + if @max_delta < MIN_FREE_SLOTS + @max_delta = MIN_FREE_SLOTS + end + if @num_requests > MIN_REQUESTS_PER_OOBGC && @max_delta * 2 + new_live_num > @expect_gc_at t = Time.now GC.start