Reputation: 36631
I've got a web app deployed on Dotcloud where the data on each page can be quite expensive to calculate (many seconds). I want to make initial page loads as speedy as possible by returning cached information and then hitting the server with a bunch of AJAX requests that cause the full calculations to occur. But I don't want these AJAX reqeusts to jam up initial page loads for other users, so I want them queuing separately.
I'm thinking the same Django app should be used for both servers, especially because the data model is shared. So the dotcloud.yml
file would like kind of like:
www:
type: python
www-ajax:
type: python
(...)
But how can I route different URLs to each class of instances? Also, I've read about Gunicorn for long requests. These AJAX requests are long, but they don't depend on external resources, besides the DB. Is this a situation for Gunicorn, and if so, is there an easy way to integrate it into the config?
Upvotes: 0
Views: 86
Reputation: 77405
If you set it up the way you are describing in your example dotcloud.yml
file, you will have two different services, with two different urls. So if you want to send stuff to the ajax service, you use the ajax url, if you want the regular one you can use the www url.
To run gunicorn you could use the python-worker user and allocate an http port for the python worker, and then have gunicorn listed on the http port. It is important to note that the python-worker doesn't have nginx in front of it like the python service, so gunicorn will need to be the one listening for the traffic directly.
So to put it together it would look something like this.
www:
type: python
approot: myapp
www-ajax:
type: python-worker
approot: myapp
ports:
www: tcp
process: gunicorn -b 0.0.0.0:$PORT_WWW yourapp:app
Your process string will most likely look different but you get the picture.
You also don't need the approot, just put it there as an example.
Upvotes: 1