Skip to content
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

Closed
loxs opened this issue Mar 29, 2010 · 7 comments
Closed

Some way to serve many WSGI apps via the same gunicorn instance. #35

loxs opened this issue Mar 29, 2010 · 7 comments

Comments

@loxs
Copy link

loxs commented Mar 29, 2010

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.

@jbergstroem
Copy link
Contributor

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 would suggest using some simple python library such as werkzeug and make your two apps respond on different routes.

@davisp
Copy link
Collaborator

davisp commented Apr 9, 2010

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

@sebest
Copy link

sebest commented Jun 18, 2010

instead of havint a specific mount point per apps, would it be possible to have an example with virtual host by name?

@temoto
Copy link
Contributor

temoto commented Jun 24, 2010

Yes, it is totally possible. You can write a trivial mapping of environ['HTTP_HOST'] to apps.

@sebest
Copy link

sebest commented Jun 24, 2010

I think this could be built in gunicorn, what do you think?

@temoto
Copy link
Contributor

temoto commented Jun 24, 2010

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:

$ gunicorn wsgi_multi django:project1 myblog.wsgi:wsgi_app anotherapp.foo

Here, gunicorn runs only one application wsgi_multi, other arguments are passed to it via some special API. Or via config or somehow else.

@boxed
Copy link

boxed commented Nov 24, 2014

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...

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants