开发者

Django for enterprise web application

开发者 https://www.devze.com 2023-01-15 21:56 出处:网络
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 i

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 Mappin开发者_高级运维g included inside Django is a good choice or should I implement them.

Thanks


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.


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""",

}


My company did just build such a system for a large scale enterprise based on Django including all mobile systems. With django the dev cost were low and runnability inside enterprise server stack was no problem. Even Django managed to let us pass the penetration and security test. with any other language we would not have been able to succeed with this project under extrem budget restrictions

0

精彩评论

暂无评论...
验证码 换一张
取 消