idanzalz
idanzalz

Reputation: 1760

concurrent requests on dotcloud with django

I have a django app I want to migrate to dotcloud. Many actions in Django internals and in my app are not asynchronous, i.e. they block the thread until they finish. When I was using Apache, that didn't pose a problem since a different thread is opened on every request. But it doesn't seem to be the case in nginx/uwsgi that dotcloud use. Seemingly, uwsgi has a --enable-threads and --threads options that can be used for multithreading, but:

  1. It is not clear what version of uwsgi dotcloud use, and if they support these features
  2. Since I have no one else asking about this, I was wondering if this is really the right way to get the concurrent requests running (using threads)

Upvotes: 1

Views: 419

Answers (3)

t1m0
t1m0

Reputation: 735

I came here looking for some leads, which I found, thanks! There was a fair amount of leg work left to actually get stuff working, though.

Here is an example app on github that uses gunicorn, gevent, and socketio on dotcloud:

https://github.com/t1m0thy/django-tictactoe/tree/dotcloud

Upvotes: 1

jpetazzo
jpetazzo

Reputation: 15511

You could run Django with Gunicorn. Gunicorn, in turn, supports multiple worker classes, and people reported success running gunicorn+gevents+django together[1][2].

To use that on dotCloud, you will probably have to use dotCloud's custom service. If that's something that you want to try, I would personally start with dotCloud's reimplementation of python service using the custom service, and replace uwsgi with gunicorn in it.

Upvotes: 1

Alexander A.Sosnovskiy
Alexander A.Sosnovskiy

Reputation: 807

Threads is a problem in python - GIL doesn't allow them to run simultaneously. So multiprocessing is an answer.

Or you may take a look at gevent. Actually gevent is a kind of a hack (monkey patching of python stack) and so on, but it allows to launch green threads. I'm not sure if gevent can be combined with django, but google knows ;)

Upvotes: -1

Related Questions