ryandotsmith / nginx-buildpack

Run NGINX in front of your app server on Heroku
457 stars 248 forks source link

Managing Nginx Memory Usage #64

Closed mojowen closed 7 years ago

mojowen commented 7 years ago

image

I've got this running alongside Gunicorn and Django on a Heroku 2X dyno and I'm seeing a bunch of memory warnings and what not. Didn't change anything except add the buildpack and the Procfile.

Anyway to manage the nginx memory usage? Thanks

asnelzin commented 7 years ago

@mojowen What settings are you using for gunicorn?

Try set "max_requests" http://docs.gunicorn.org/en/stable/settings.html

mojowen commented 7 years ago

We ended up removing Nginx and moving our assets into a CDN. But for anyone else encountering this issue - here's what my gunicorn.conf looked like:

import multiprocessing

def pre_fork(server, worker):
    f = '/tmp/app-initialized'
    open(f, 'w').close()

bind = 'unix:///tmp/nginx.socket'
workers = multiprocessing.cpu_count() * 2 + 1

And my Procfile:

web: bin/start-nginx gunicorn -c gunicorn.conf app_name.wsgi