Django memory requirements

1,246 views
Skip to first unread message

Tereno

unread,
Jul 19, 2010, 9:41:29 AM7/19/10
to Django users
Hi there,

I have a few questions about Django deployment on production so
hopefully you can help me sort it out.

Firstly, what's the minimum memory requirements for a Django + Apache
+ mod_wsgi setup? It seems like my server ran out of memory when I
tried it and I think I may only have 256MB RAM. If Apache's the cause,
would it help if I switched to use other webservers or would it be
better for me to increase my RAM?

Secondly, if I have multiple sites, let's say 2 static html sites and
2 Django-powered sites, should I use separate Django instances for
each of the Django-powered sites? I don't want to have to bring both
sites down when I restart Django for making a configuration change to
one of the sites. I guess I'm not too sure how mod_wsgi works. Will
each site be treated as a separate process or will they be one wsgi
process?

I find that all this configuration and memory monitoring for Django is
abit tiring and I am no expert so I am wondering if there any hosts
that you would recommend? I am considering Google App Engine.

Thanks!

Franklin Einspruch

unread,
Jul 19, 2010, 9:55:31 AM7/19/10
to django...@googlegroups.com
Regarding the hosting question, I recommend Webfaction. They have
install-by-clicking Django instances and they're fans of Python.

Franklin

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.com

Venkatraman S

unread,
Jul 19, 2010, 10:03:08 AM7/19/10
to django...@googlegroups.com
On Mon, Jul 19, 2010 at 7:11 PM, Tereno <ter...@gmail.com> wrote:

I find that all this configuration and memory monitoring for Django is
abit tiring and I am no expert so I am wondering if there any hosts
that you would recommend? I am considering Google App Engine.

I would recommend GAE if you want to deploy your app at the cheapest rates. I run my app http://www.mapatree.org/ on GAE and the only expense for me was getting the domain. The way you develop apps for GAE is 'slightly' different, but is NOT at all tough and can be done with the same easiness; but has certain technical nuances that are specific to GAE.

I also recommend webfaction, if you think you can't waste your time quickly learning the GAE nuances. I use it for few of my clients and havent faced any problems till now.

Let me know if you want any help.

-V-
http://twitter.com/venkasub
 

David De La Harpe Golden

unread,
Jul 19, 2010, 10:11:02 AM7/19/10
to django...@googlegroups.com
On 19/07/10 14:41, Tereno wrote:
> Hi there,
>
> I have a few questions about Django deployment on production so
> hopefully you can help me sort it out.
>
> Firstly, what's the minimum memory requirements for a Django + Apache
> + mod_wsgi setup? It seems like my server ran out of memory when I
> tried it and I think I may only have 256MB RAM.

Well, that does depend on what your app is doing. There's some basic
overheads that probably can add up to several tens of megs, then stuff
you actually do is on top of that...

256MiB is a little cramped by modern bloaty standards, but just in case:
by any chance did you still have settings.DEBUG on during your test?
[1]. That usually causes disconcertingly large and rapidly increasing
memory usage as it logs every sql query to an in-memory list for
debugging purposes.

You can periodically empty django.db.connection.queries to keep it down
when settings.DEBUG is on, but then of course you lose the log in
question. For production, of course DEBUG should be off.

[1] http://docs.djangoproject.com/en/1.2/ref/settings/#debug

Tereno

unread,
Jul 19, 2010, 1:01:57 PM7/19/10
to Django users
Web Faction does look like an interesting option. However, looking at
the memory specs, how would I be able to tell if it's sufficient for
at least 2 Django applications? For example, if I got with Shared 1, I
get 80MB (180MB VPS) - I'm assuming that's not going to be enough
right? Of course it does depend on the application itself but in
general, do you reckon it can support 2 Django apps?

On Jul 19, 10:03 am, Venkatraman S <venka...@gmail.com> wrote:
> On Mon, Jul 19, 2010 at 7:11 PM, Tereno <ter...@gmail.com> wrote:
>
> > I find that all this configuration and memory monitoring for Django is
> > abit tiring and I am no expert so I am wondering if there any hosts
> > that you would recommend? I am considering Google App Engine.
>
> I would recommend GAE if you want to deploy your app at the cheapest rates.
> I run my apphttp://www.mapatree.org/on GAE and the only expense for me was

Venkatraman S

unread,
Jul 19, 2010, 2:35:12 PM7/19/10
to django...@googlegroups.com


On Mon, Jul 19, 2010 at 10:31 PM, Tereno <ter...@gmail.com> wrote:
Web Faction does look like an interesting option. However, looking at
the memory specs, how would I be able to tell if it's sufficient for
at least 2 Django applications? For example, if I got with Shared 1, I
get 80MB (180MB VPS) - I'm assuming that's not going to be enough
right? Of course it does depend on the application itself but in
general, do you reckon it can support 2 Django apps?

If your applications are not very intensive, then this should be fine. I am running a Pinax Social app and a custom website on ONE account without any problems.

-V

Nick Arnett

unread,
Jul 19, 2010, 3:07:34 PM7/19/10
to django...@googlegroups.com
On Mon, Jul 19, 2010 at 10:01 AM, Tereno <ter...@gmail.com> wrote:
Web Faction does look like an interesting option. However, looking at
the memory specs, how would I be able to tell if it's sufficient for
at least 2 Django applications? For example, if I got with Shared 1, I
get 80MB (180MB VPS) - I'm assuming that's not going to be enough
right? Of course it does depend on the application itself but in
general, do you reckon it can support 2 Django apps?

The only honest answer is "it depends."  But the good news about Webfaction, which I've been using for about six months, is that you can start with the cheapest option and then upgrade at any time.  And downgrade.  They make it easy.

You'll get warnings from them immediately if you exceed the allocated memory.

I was able to run a database-intensive app under Shared 1 for a long time.  It was only when I started doing some heavier analysis that I had to bump up to Shared 2.

Nick

Graham Dumpleton

unread,
Jul 19, 2010, 6:57:45 PM7/19/10
to Django users


On Jul 19, 11:41 pm, Tereno <ter...@gmail.com> wrote:
> Hi there,
>
> I have a few questions about Django deployment on production so
> hopefully you can help me sort it out.
>
> Firstly, what's the minimum memory requirements for a Django + Apache
> + mod_wsgi setup? It seems like my server ran out of memory when I
> tried it and I think I may only have 256MB RAM. If Apache's the cause,
> would it help if I switched to use other webservers or would it be
> better for me to increase my RAM?

You are likely using mod_wsgi embedded mode and possibly even with
prefork MPM. This is a very bad combination, see:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

> Secondly, if I have multiple sites, let's say 2 static html sites and
> 2 Django-powered sites, should I use separate Django instances for
> each of the Django-powered sites?

That is preferred and the model that supports this is much more kind
to memory constrained systems anyway as it gives you better control of
memory usage.

So, see daemon mode in mod_wsgi and delegate each Django instance to a
separate daemon process group. See:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

> I don't want to have to bring both
> sites down when I restart Django for making a configuration change to
> one of the sites. I guess I'm not too sure how mod_wsgi works. Will
> each site be treated as a separate process or will they be one wsgi
> process?

Use daemon mode and they are separate and there are ways of
controlling restart of them individually separate from restarting
whole of Apache. See:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

> I find that all this configuration and memory monitoring for Django is
> abit tiring and I am no expert

Sorry, this isn't PHP and Python requires you to be a bit more mindful
of these things. If you aren't you can quite easily hit problems.

Graham
Reply all
Reply to author
Forward
0 new messages