New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some way to serve many WSGI apps via the same gunicorn instance. #35
Comments
I think this kind of behavior is best solved by the end user. There's a distinct difference in the way gunicorn works with "multiple sites" compared to a conventional web server. |
I have to agree wtih jbergstroem that this doesn't belong in core. But I did go ahead and add an example outlining how you can accomplish this with Routes: http://github.com/benoitc/gunicorn/blob/master/examples/multiapp.py |
instead of havint a specific mount point per apps, would it be possible to have an example with virtual host by name? |
Yes, it is totally possible. You can write a trivial mapping of environ['HTTP_HOST'] to apps. |
I think this could be built in gunicorn, what do you think? |
This could be some optional part of gunicorn, like contrib stuff, yes. I think it would be best as a standalone multiplexor application with separate config. Django/Paste specialization must also go there. Like this:
Here, gunicorn runs only one application wsgi_multi, other arguments are passed to it via some special API. Or via config or somehow else. |
I spent a lot of time trying to write something like what is suggested in this ticket. First I tried having code that switched virtualenv based on HTTP_HOST. Turns out you really can't deactivate virtualenvs in pure python, so that was a wash. Then I thought: maybe we can just have a requirement that it's one single virtualenv, so I wrote the code to switch to different WSGI apps based on HTTP_HOST only to discover that you can't run two django apps side by side because django keeps a truly astonishing number of global variables everywhere. So basically, what I'm saying is it's not all as easy or even feasible as suggested above. Maybe it's more feasible to do some kind of load balancing thing where workers run in different virtualenvs depending on the app and a central gunicorn master makes sure that the apps that needs more workers get them? Probably not easy or fun to write :( I'd really like for django to be cleaned up to make this kind of thing possible... |
Do you think it's a good idea if we have some way to run lots of applications via the same gunicorn instance, so that they use the same python interpreter(s).
At least for me, this will be very useful, because it'll save lots of RAM, as I have many small applications (with very low load) that run on the same machine.
The text was updated successfully, but these errors were encountered: