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.
Related
Is it reliable to build desktop applications using web frameworks like Django?
The idea is to
build the interface with HTML, CSS, and JavaScript
use Python and Django for backend operations (calculations, storage and databases, etc)
and then run a server locally so that
the interaction with the application is done through the browser
other local devices can access the application by connecting to the device on which the server is running.
If that is possible and yields a reliable experience, then
is the development server that comes with Django enough? If no, what servers are most suitable for our purpose? Is Nginx good for example?
what database should be used? PostgreSQL, MySQL, etc? The app will need to store a large number of entries.
I've never done this, but I can't see why not. You can use the Django REST Framework to create an API that your desktop application can talk to, in exactly the same way as you might with a JavaScript single page app.
But no, you should not use the dev server for production, even in a limited scenario like this. Apache/mod_wsgi or nginx/gunicorn are simple to set up and deploy.
For the database, it makes no difference. The Django core devs prefer postgres, but you should use whatever you are comfortable with.
You are asking for a webApp, so yes you can. Is not use the Django server, instead is very common use nginx for Django, and the best database is postgres for Django.
If you want to pass your project like a desktop app is better use Django server and SQLite for avoid create a new database server.
Database
I find this answer explaining why is postgres better for Django
I have a few views I want to expose to apps internal to the server cluster. How can I do this securely?
The apps that want to access these restricted views are also using python, so if I can arguably bypass the HTTP tunneling and call directly to them, that's even better. I think these would be better suited as commands if that's the case, but how can another process invoke a Django environment's commands?
Once you load the project's settings you can act as the project itself.
It sounds like you basically want to extract some data from your Django site and use it elsewhere. Perhaps a couple of management commands that periodically output their data in some directory which you can then read from the other python apps? Depends on your data needs whether that's an option.
I'm doing this suggestion as those other apps seem to be on the same server (how could you otherwise run your site's python code from those apps?).
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've built a web application with Django, I'm using Memcached in order to cache data.
A few views cache the whole HttpResponse objects, therefore there might be a better alternative for returning the Memcached data other than going through Django.
What could be faster alternatives for returning Memcached data on HTTP Requests ?
I'm trying to make the operation as fast and lightweight as possible.
Help would be much appreciated! :)
It sounds like you're looking for some sort of proxying server which can take the cached page and serve it without going through Django at all. You might take a look at Varnish.
I don't believe there's a faster way to "cache/retrieve a whole Python object" (given that memcached stores strings) than cPickle's loads and dumps methods with a second argument of -1 (which tells cPickle to use the fastest, tightest algorithm available).
That's if you're using memcached directly; if you're using it as the backend of Django's own cache system, you can use it per-view, etc, and Django will handle the serialization (and more) on your behalf.
If you use nginx as a proxy server in front of Apache, you can use its memcached module to serve cached HTML output directly from memcached. This data can be created and put into memcached by Django. I do think that the nginx memcached module only supports one memcached server instance though. Here are a couple of links that show the principles:
http://weichhold.com/2008/09/12/django-nginx-memcached-the-dynamic-trio/
http://bretthoerner.com/blog/2008/oct/27/using-nginx-memcached-module-django/
Do I need either to make Django easier to use on GAE? Anyone had good or bad experience of either or any equivalent? Is there much difference between these? Which is easier to use?
Regards
Geoff
I am assuming you want to run django on app engine (otherwise using appengine API directly is the best solution).
Altho' Google App engine supports django 1.0 out of the box, django admin, auth doesn't work on it, as they are dependent on the models.
Appengine patch patches django to make the admin work even on the Bigtable API.
Appengine patch also often makes sure to work on the latest release of django.
So, again, "You should use App engine patch"
Google App Engine Patch seems to have died sometime around August 2009.
http://code.google.com/p/app-engine-patch/issues/detail?id=253
I think it depends on what exactly you want to develop.
You should use app-engine-patch if you need the Django Admin interface, otherwise google-app-engine-django should be enough.
Use Django patch if you already have django application that you know that you want to use. Remember that GAE comes with its own API/applications.