Google Groups Home
Help | Sign in
Performance of a django website
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 30 - Collapse all   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Richard Coleman  
View profile
(1 user)  More options Dec 11 2007, 12:53 pm
From: Richard Coleman <rcole...@criticalmagic.com>
Date: Tue, 11 Dec 2007 12:53:31 -0500
Local: Tues, Dec 11 2007 12:53 pm
Subject: Performance of a django website
At work, we are developing a commercial website based on Django.  It's a
fairly dynamic site (think social networking).  I am doing the initial
load testing to estimate the number of servers we will need for the
production site.  The production site will be load balanced using a pair
of BigIP boxes.

When I stress test the dynamic part of the site, I am only getting about
300 requests per second on my test setup.  This is using two Dell 1950's
(one for web, one for mysql database).  These are very powerful machines
(3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)

I've done all the standard performance tuning I find when reading
through various websites about django tuning.  Is this the performance I
should expect.

When I'm running the load test, the CPU on the web server gets
completely buried (even with 8 cores).  The mysql server doesn't seem
loaded at all.  Any suggestions on how to find the bottlenecks?

I'm running Ubuntu 7.10 (server, 64 bit version).  Django from a very
recent trunk.

Thanks for any advice.

Richard Coleman
rcole...@criticalmagic.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
l5x  
View profile
 More options Dec 11 2007, 1:08 pm
From: l5x <mail.loo...@gmail.com>
Date: Tue, 11 Dec 2007 10:08:16 -0800 (PST)
Local: Tues, Dec 11 2007 1:08 pm
Subject: Re: Performance of a django website
I think that some info about your web-server could be important.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rajesh Dhawan  
View profile
(1 user)  More options Dec 11 2007, 1:08 pm
From: Rajesh Dhawan <rajesh.dha...@gmail.com>
Date: Tue, 11 Dec 2007 10:08:48 -0800 (PST)
Local: Tues, Dec 11 2007 1:08 pm
Subject: Re: Performance of a django website
Hi Richard,

> When I stress test the dynamic part of the site, I am only getting about
> 300 requests per second on my test setup.  This is using two Dell 1950's
> (one for web, one for mysql database).  These are very powerful machines
> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)

- How are you running your Django app? Mod_python? FastCGI?
- What web server are you using?
- What's the nature of the dynamic Django request you are measuring?
How many DB queries does it make? Is DEBUG mode off?
- What kind of numbers do you get when you serve a simple and small
HTML file statically from your Web server without Django?
- What kind of numbers do you get when the Django view you are
benchmarking goes directly to a simple template (i.e. no DB queries)?
- Are you using memcache?

-Rajesh D


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joseph Heck  
View profile
 More options Dec 11 2007, 1:13 pm
From: "Joseph Heck" <joseph.h...@gmail.com>
Date: Tue, 11 Dec 2007 10:13:00 -0800
Subject: Re: Performance of a django website
Add on to Rajesh's list -

what pages are you requesting and have you profiled them to understand
what's taking long?

-joe

On Dec 11, 2007 10:08 AM, Rajesh Dhawan <rajesh.dha...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe  
View profile
(1 user)  More options Dec 11 2007, 1:18 pm
From: Joe <joerad...@gmail.com>
Date: Tue, 11 Dec 2007 10:18:54 -0800 (PST)
Local: Tues, Dec 11 2007 1:18 pm
Subject: Re: Performance of a django website
I've found the largest memory hog to be the native way related tables
are setup.

Check class definitions with related tables and edit as such:

class ...(models.Mode):
relatedtable    = models.ForeignKey(RelatedTable, core=True,
raw_id_admin=True)

The raw_id_admin=True prevents django from pulling up all related
records when the object is loaded etc. While I would have expected
this to only affect the admin side, it had a huge impact on the public
side of our site. Memory consumption went from +500mb to 20-30mb.

Joe

On Dec 11, 12:53 pm, Richard Coleman <rcole...@criticalmagic.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Dunck  
View profile
 More options Dec 11 2007, 1:26 pm
From: "Jeremy Dunck" <jdu...@gmail.com>
Date: Tue, 11 Dec 2007 12:26:38 -0600
Local: Tues, Dec 11 2007 1:26 pm
Subject: Re: Performance of a django website
On Dec 11, 2007 12:18 PM, Joe <joerad...@gmail.com> wrote:

> I've found the largest memory hog to be the native way related tables
> are setup.

> Check class definitions with related tables and edit as such:

> class ...(models.Mode):
> relatedtable    = models.ForeignKey(RelatedTable, core=True,
> raw_id_admin=True)

> The raw_id_admin=True prevents django from pulling up all related
> records when the object is loaded etc. While I would have expected
> this to only affect the admin side, it had a huge impact on the public
> side of our site. Memory consumption went from +500mb to 20-30mb.

You must be using manipulators in oldforms.  Try newforms.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Coleman  
View profile
 More options Dec 11 2007, 1:37 pm
From: Richard Coleman <rcole...@criticalmagic.com>
Date: Tue, 11 Dec 2007 13:37:36 -0500
Local: Tues, Dec 11 2007 1:37 pm
Subject: Re: Performance of a django website

1. mod_python
2. apache 2.2.4
3. I'm using funkload and ab to measure the requests per second of one
of the base pages within the dynamic part of the website
4. When I hit a static page in the same way (using ab), I get 6500
requests per second.
5. This is without memcached, or any other caching.

Richard Coleman
rcole...@criticalmagic.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Coleman  
View profile
 More options Dec 11 2007, 1:41 pm
From: Richard Coleman <rcole...@criticalmagic.com>
Date: Tue, 11 Dec 2007 13:41:03 -0500
Local: Tues, Dec 11 2007 1:41 pm
Subject: Re: Performance of a django website

I forgot to mention these:

6. django debug turned off
7. mod_python debug turn off
8. django template debugging turned off
9. apache maxclient cranked up to 1000 (although it never gets close to
that many processes).

Richard Coleman
rcole...@criticalmagic.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Morton  
View profile
 More options Dec 11 2007, 1:41 pm
From: Brian Morton <rokclim...@gmail.com>
Date: Tue, 11 Dec 2007 10:41:34 -0800 (PST)
Local: Tues, Dec 11 2007 1:41 pm
Subject: Re: Performance of a django website
Are you serving static content from the same apache instance?  Also,
what kind of network connectivity do you have between your web and
mysql servers?  It sounds like apache might need some tuning in terms
of thread parameters.  Have you enabled caching yet?  Turn on the
cache framework site-wide and set your expiration period to 1 minute
or something like that.  You can go back and only enable it for views
that you want cached later.

On Dec 11, 12:53 pm, Richard Coleman <rcole...@criticalmagic.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Walstad  
View profile
 More options Dec 11 2007, 1:41 pm
From: Eric Walstad <e...@ericwalstad.com>
Date: Tue, 11 Dec 2007 10:41:42 -0800
Local: Tues, Dec 11 2007 1:41 pm
Subject: Re: Performance of a django website
If you don't already use them:

Firebug:
http://www.getfirebug.com/
will show you how long each component of the page takes from request to
response and shows you what components are returned in parallel (among
other really cool features).  This can help identify your bottleneck.
For example, if your images are taking longer than expected while the
page itself returns quickly then you may want to serve images with a
dedicated web server, like lighttpd.

Yahoo's 'yslow' tool gives your page a 'grade' and offers advice on how
to improve your grade.  It also has other handy bits (JSLint, Empty vs.
Primed cache comparisons).
http://developer.yahoo.com/yslow/

The grades are based on their 'Rules for High Performance Websites':
http://developer.yahoo.com/performance/index.html#rules

Hm, funny, their yslow page scores a 'D' :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Coleman  
View profile
 More options Dec 11 2007, 1:49 pm
From: Richard Coleman <rcole...@criticalmagic.com>
Date: Tue, 11 Dec 2007 13:49:30 -0500
Local: Tues, Dec 11 2007 1:49 pm
Subject: Re: Performance of a django website
Brian Morton wrote:
> Are you serving static content from the same apache instance?  Also,
> what kind of network connectivity do you have between your web and
> mysql servers?  It sounds like apache might need some tuning in terms
> of thread parameters.  Have you enabled caching yet?  Turn on the
> cache framework site-wide and set your expiration period to 1 minute
> or something like that.  You can go back and only enable it for views
> that you want cached later.

1. Static content and dynamic are on the same server (that will change
on production).  But they are on different apache virtual.  Mod_python
is turned off for the static stuff.  Hitting only a static page is very
fast (6500 requests per second).  Hitting the dynamic side is slow (300
requests per second).

2. It's gigE between the web server and mysql server, on a dedicated
switch.  The database is working pretty hard (7000 selects per second),
but doesn't seem to be the bottleneck.  The webserver is hammered
(typing any command takes a long time).
3. I'm using prefork MPM on apache with maxclients set to 1000.

We are starting to experiment with caching, but I want to improve the
raw performance of the site as well.

Richard Coleman
rcole...@criticalmagic.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joseph Heck  
View profile