简体   繁体   English

适用于企业Web应用程序的Django

[英]Django for enterprise web application

I wanted to know is Django a good choice for a big web applicatin(Social Network)? 我想知道Django是大型Web应用程序(社交网络)的不错选择吗? 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. 更具体地说,当数据库事务数量增加并且我想知道Django内含的嵌入式OR映射是一个不错的选择还是我应该实现它们时,我需要一些关于性能的建议。

Thanks 谢谢

performace when number of DB transactions increases. 数据库事务数量增加时的性能。

Not a Django problem, really. 确实不是Django问题。

You can have a lot of concurrent Django sessions via Apache and mod_wsgi. 您可以通过Apache和mod_wsgi进行很多并发的Django会话。 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. 您应该能够配置足以淹没数据库的Apache / Django会话。

OR Mapping included inside Django is a good choice or should I implement them. 或Django中包含的映射是一个不错的选择,或者我应该实现它们。

Yes. 是。 It's a really good choice. 这是一个非常好的选择。

Until you can prove that the ORM is your bottleneck, use it. 在您可以证明 ORM是您的瓶颈之前,请使用它。

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. 由于ORM具有缓存(数据库也具有缓存),所以这里很少遇到性能问题。

You can. 您可以。

But most of your performance problems will be downloading static media files through Apache. 但是大多数性能问题将是通过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 (ie what queries it can express). 我应该补充一点,企业应用程序在使用Django ORM时可能会遇到的一个大问题是,它的功能(即它可以表达什么查询)在某种程度上受到限制。 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). 力求尽可能多地在Django ORM中表达查询(如果没有经验,在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. 如果查询真的在Django中是不可能的(如果您真的不确定,也可以询问IRC #django频道或django-users组),请将查询存储在dba可以管理或查看的querys.py文件中。 (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: 作为第2点的示例,没有理由不能编写用于以下方式的查询存储管理器:假设您有一个名为Blogs的应用程序,其模型名为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. 我公司只是为基于Django的大型企业(包括所有移动系统)构建了这样的系统。 With django the dev cost were low and runnability inside enterprise server stack was no problem. 使用django,开发成本很低,企业服务器堆栈内部的可运行性也没有问题。 Even Django managed to let us pass the penetration and security test. 甚至Django也设法让我们通过了渗透性和安全性测试。 with any other language we would not have been able to succeed with this project under extrem budget restrictions 在极端预算限制下,使用任何其他语言,我们将无法成功完成该项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM