Django & uWSGI best practices

165 views
Skip to first unread message

chuwy

unread,
May 11, 2012, 2:53:59 PM5/11/12
to django...@googlegroups.com
Hi.
I'm going to deploy a few (8-12) Django projects on my VDS with Ubuntu 12.04 and nginx. And I wonder how should configuration look like, to be explicit, simple and easy-to-understand for others (it will be maintained by another dude).
Should I use emperor-mode for such a small amount of sites? Should I add web specific-user, or it could be run as www-data (this is it's usecase, right?) and in /var/www? Should I use single uWSGI-instance from sudo apt-get install uwsgi or pip install for every project? Anyone use some sort of django conventions may be?
One more my wish is the easy-to-deployment (and easy-to update) sequence, because I planning to write a script for automatic deployment and apply it for my other servers, which would have the same anount of sites. In near future.
What would you advice?
Thanks.

Roberto De Ioris

unread,
May 11, 2012, 3:30:40 PM5/11/12
to django...@googlegroups.com

> Hi.
> I'm going to deploy a few (8-12) Django projects on my VDS with Ubuntu
> 12.04 and nginx. And I wonder how should configuration look like, to be
> explicit, simple and easy-to-understand for others (it will be maintained
> by another dude).
> Should I use emperor-mode for such a small amount of sites? Should I add
> web specific-user, or it could be run as www-data (this is it's usecase,
> right?) and in /var/www? Should I use single uWSGI-instance from sudo
> apt-get install uwsgi or pip install for every project? Anyone use some
> sort of django
> conventions<http://blog.zacharyvoase.com/2010/02/03/django-project-conventions/>may
> be?
> One more my wish is the easy-to-deployment (and easy-to update) sequence,
> because I planning to write a script for automatic deployment and apply it
> for my other servers, which would have the same anount of sites. In near
> future.
>

I suggest yout to always use the emperor.
Choose a directory for your app config files (like /etc/uwsgi/apps), and
put a config file for each uWSGI instance. Fill each config file with
comment for each directive (the other dude will thank you for that).

Use a different uid for each app (if you can)

Regarding application directory or virtualenv usage i have no particular
suggestion, for me it is a matter of taste.

What i very-strongly suggest you is NOT USING virtualhosting mode. I know
it is funny but it is very complex to manage and secure.

Finally give a look at --idle,--cheap and --cheaper options, they could
help you in maintaining resources low.

--
Roberto De Ioris
http://unbit.it

chuwy

unread,
May 13, 2012, 11:26:49 AM5/13/12
to django...@googlegroups.com, rob...@unbit.it
Yeah. But default Ubuntu's uwsgi init-script seems so pretty, featureful and complete, but without a word about emperor-mode, so I think this is not mainstream way of running applications.
Anyway, many thanks.
P.S. If you can give more "random" advices or links about deploying multiapp configuration, I will much appreciate it (because, most of those, that I see are about single app).
Reply all
Reply to author
Forward
0 new messages