How to run Ruby GC after a memory expensive request with Unicorn
Unicorn server has a module that you can import in your config.ru
,
it's called Unicorn::OobGC, you can just import in your config.ru
and call use
:
require 'unicorn/oob_gc'
# GC ever two requests that hit /expensive/foo or /more_expensive/foo
# in your app. By default, this will GC once every 5 requests
# for all endpoints in your app
use Unicorn::OobGC, 2, %r{\A/(?:expensive/foo|more_expensive/foo)}
It's in the official Unicorn documentation but most users don't pay attention.
Written by Estevão Mascarenhas
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#