I am currently working on a django project where I need a separate backend application to be able to initiate gRPC requests to my django frontend.
Simply put: I want the backend to be able to access and change objects.
Therefore I need my django project to also start my grpc server while starting up.
I did a lot of research and didn't really find any best practice on that.
As far as I would imagine, I could override the startup command of django to also start my grpc server on a seperate thread. But I am afraid that I will end up with a very bad practice solution.
Is there any recommendable way to do this?
I am excited about every hint :)
This is more a question for some general thing.
I've got a lighttpd running and want to connect it as a reverse proxy with Django 1.6. I've read a lot about wsgi, gunicorn ... well, not sure what's the current best way of doing this?
I have a running django-nonrel application and I would like to add a real time module using web sockets.
I would like to use django-socketio but it seems that gevent (which is used to serve the site) does not work properly with mongodb (link) which is the backend of the Django application.
Does anyone already try to set up django-socketio with mongodb as a backend ?
Dry
I found that using Tornado/Tornadio2 with Django is much easier than the gevent-based alternatives. If you need help setting that up I'd be happy to share my runserver_socketio.py script.
I would like to have django admin panel with tornado backends, which will process requests from online game. I dont know at the moment, is it a good idea to load django app in the next way:
wsgi_app = tornado.wsgi.WSGIContainer(
django.core.handlers.wsgi.WSGIHandler())
tornado_app = tornado.web.Application(
[
('/hello-tornado', HelloHandler),
('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app)),
])
server = tornado.httpserver.HTTPServer(tornado_app)
server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
HelloHandler is going to be a backend parser.
Will I loose some performance in combining wsgi + ioloop ?
If its a bad solution, its possible to run 2 apps: django admin and tornado web. Could you answer how can I use Django ORM with Tornado App?
Just take this equation and solve it.
You want to have non-blocking IO - X.
You want to have django ORM - Y.
You want to have django admin - Z.
Now, move point by point:
For X - tornado is enough itself.
For Z - django is enough itself. I don't think, you want to have
thousands of administrators, that manage your site at one time.
For Y it is harder. Django ORM is blocking itself.
Best way here - not to use Django ORM with tornado.
Second way - you can dive deeper and integrate it directly in tornado, if you are sure that it will not block whole application. Take solution from this answer.
Third way - you can convert your django application to service, that makes heavy work with ORM, and you can access this service with AsyncHTTPCLient from tornado.
Fourth way - integrate tornado web server into your django application. Actually, it will give you small performance boost.
Fifth way - use two tornado web servers. Sounds crazy, yes. Use one with Django ORM integrated, and second with AsyncHTTPClient.
I believe, that you can take best of 2 worlds.
Django is not asynchronous, so running Django in Tornado will remove most of the performance benefits you might get from Tornado.
If you want maximum async performance, you should use Tornado with a non-blocking database (I'm assuming you want Django admin for use with a SQL database).
If you want maximum ease of development, use Django, with it's ORM system and admin tools.
You can't just mix the best of both worlds, unfortunately.
So, yes, you will lose performance. In this situation I would probably use Tornado and give up on Django admin. If you're dead set on a compromise you could write two apps, sharing a database, but that will mean you need to maintain two data access layers.
I want to use MemcacheDB instead of Memcached because I don't have a lot of RAM for Memcached.
Will it work with django's cache framework?
Is there anything additional I would need to do?
Yes, I think this should just work. The whole idea of MemcacheDB is to give a BDB backend through existing and tested memcache client libraries. Django just sits on top of that.