views:

119

answers:

2

Hey all I wanted to know is Django a good choice for a big web applicatin(Social Network)? More specifically, I need some suggestion on performace when number of DB transactions increases and I want to know is the embedded OR Mapping included inside Django is a good choice or should I implement them.

Thanks

+3  A: 

performace when number of DB transactions increases.

Not a Django problem, really.

You can have a lot of concurrent Django sessions via Apache and mod_wsgi. All of them will share a common database.

Therefore, this is entirely a database problem. You should be able to configure enough Apache/Django sessions that your database is swamped.

OR Mapping included inside Django is a good choice or should I implement them.

Yes. It's a really good choice.

Until you can prove that the ORM is your bottleneck, use it.

As you scale up, you will rework your database, your cache, and other architectural features. Since the ORM has a cache (as does your database), you rarely have performance issues here.

You can.

But most of your performance problems will be downloading static media files through Apache.

S.Lott
So, would you suggest using another server for static files, like nginx or lighttpd, or perhaps offloading it to a CDN?
Alex JL
Not another server. Another piece of your existing server. Configure your server to send Django requests through mod_wsgi to Django. Configure static media requests to be handled directly. The Django docs cover this configuration in detail.
S.Lott
Well I host the static content under another domain in orther to prevent sending cookie and some other headers for each request. Thanks for the response
n4cr
"prevent sending cookie and some other headers for each request"? Seems like too much work for too little benefit. Can you **prove** that this helps?
S.Lott
Definitely it helps when you are processing a lot of requests. So you need to reduce the request the request size by as much as you can.
n4cr
http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain
n4cr
A: 

I should add that one big issue that enterprise applications may have when using the Django ORM is that it is somewhat limited in its capability (i.e. what queries it can express). I think this is manageable if you do two things:

  1. Strive to express queries in the Django ORM as much as possible (without experience it may be too easy to dismiss a query as not possible in Django).
  2. If the query is really impossible in Django (you can also ask the IRC #django channel or the django-users group if you are really unsure), store the query in a queries.py file that your dba's can manage or look at. (It can be a flat dictionary referenced by your models file.)

As an example of point 2: There's no reason you can't write a query storage manager that's used in the following way: Suppose you had an app named blogs with a model called Entry:

# models.py
class Entry(models.Model):
    objects = project.QueryStorageManager()
    author = models.ForeignKey(User)
    body = models.TextField()
    slug = models.CharField(max_length=512)
    published_date = models.DateField()

    @project.StoredQuery("getEntryMonthHistogram")
    def getEntryMonthHistogram(self, sql, author):
        return objects.runQuery(sql, author)

# queries.py
{
"getEntryMonthHistogram": """SELECT EXTRACT(MONTH FROM published_date),
                                    REPEAT('*', count(*)) histogram
                             FROM   blogs_entry
                             WHERE  author_id = %s""",

}

Mike Axiak