我正在用Django构建一个web应用程序。我选择Django的原因是:

我想使用免费/开源工具。 我喜欢Python,觉得它是一种长期的语言,而对于Ruby,我不确定,而PHP似乎是一个巨大的麻烦。 我正在为一个想法构建一个原型,并没有过多地考虑未来。开发速度是主要因素,而且我已经了解Python。 我知道迁移到谷歌应用程序引擎将更容易,如果我选择这样做在未来。 我听说Django很“不错”。

现在我越来越接近于考虑出版我的作品,我开始担心规模问题。我找到的关于Django伸缩能力的唯一信息是Django团队提供的(我不是说什么要忽略它们,但这显然不是客观的信息…)

我的问题:

目前在Django上构建的“最大”站点是什么?(我主要通过用户流量来衡量规模) Django能每天处理10万名用户,每个用户访问站点几个小时吗? 像Stack Overflow这样的站点可以在Django上运行吗?


当前回答

YouTube的开发者倡导者在PyCon 2012上做了一个关于扩展Python的演讲,这也与扩展Django有关。

YouTube拥有超过10亿用户,而YouTube是建立在Python之上的。

其他回答

"What are the largest sites built on Django today?" There isn't any single place that collects information about traffic on Django built sites, so I'll have to take a stab at it using data from various locations. First, we have a list of Django sites on the front page of the main Django project page and then a list of Django built sites at djangosites.org. Going through the lists and picking some that I know have decent traffic we see: Instagram: What Powers Instagram: Hundreds of Instances, Dozens of Technologies. Pinterest: Alexa rank 37 (21.4.2015) and 70 Million users in 2013 Bitbucket: 200TB of Code and 2.500.000 Users Disqus: Serving 400 million people with Python. curse.com: 600k daily visits. tabblo.com: 44k daily visits, see Ned Batchelder's posts Infrastructure for modern web sites. chesspark.com: Alexa rank about 179k. pownce.com (no longer active): alexa rank about 65k. Mike Malone of Pownce, in his EuroDjangoCon presentation on Scaling Django Web Apps says "hundreds of hits per second". This is a very good presentation on how to scale Django, and makes some good points including (current) shortcomings in Django scalability. HP had a site built with Django 1.5: ePrint center. However, as for novemer/2015 the entire website was migrated and this link is just a redirect. This website was a world-wide service attending subscription to Instant Ink and related services HP offered (*). "Can Django deal with 100,000 users daily, each visiting the site for a couple of hours?" Yes, see above. "Could a site like Stack Overflow run on Django?" My gut feeling is yes but, as others answered and Mike Malone mentions in his presentation, database design is critical. Strong proof might also be found at www.cnprog.com if we can find any reliable traffic stats. Anyway, it's not just something that will happen by throwing together a bunch of Django models :)

当然,还有更多感兴趣的网站和博主,但我必须在某个地方停下来!


一篇关于使用Django构建高流量网站michaelmoore.com的博文,将其描述为排名前10,000的网站。Quantcast数据和compete.com数据。


(*)编辑的作者,包括这些引用,曾经在该项目中作为外包开发人员工作。

我所知道的最大的django网站是华盛顿邮报,这肯定表明它可以很好地扩展。

好的设计决策对性能的影响可能比其他任何东西都要大。Twitter经常被认为是另一个基于动态解释语言的web框架——Ruby on Rails——体现了性能问题的站点——但Twitter工程师表示,该框架并不像他们早期所做的一些数据库设计选择那样是个大问题。

Django可以很好地使用memcached,并提供了一些管理缓存的类,这可以解决大部分性能问题。在现实中,你在网络上交付的东西几乎比你的后端更重要——使用像yslow这样的工具对于高性能web应用程序来说是至关重要的。你可以在后台添加更多硬件,但你不能改变你的用户带宽。

我用Django为爱尔兰国家广播公司开发高流量网站。这对我们来说很有效。开发一个高性能的网站不仅仅是选择一个框架。框架只是系统的一部分,它的强大程度取决于它最薄弱的环节。如果问题是数据库查询缓慢或服务器或网络配置糟糕,使用最新的框架'X'将无法解决您的性能问题。

如果你想使用开源,那么你有很多选择。但是python是其中最好的,因为它有很多库和一个超级棒的社区。 下面这些原因可能会改变你的想法:

Python is very good but it is a interpreted language which makes it slow. But many accelerator and caching services are there which partly solve this problem. If you are thinking about rapid development then Ruby on Rails is best among all. The main motto of this(ROR) framework is to give a comfortable experience to the developers. If you compare Ruby and Python both have nearly the same syntax. Google App Engine is very good service but it will bind you in its scope, you don't get chance to experiment new things. Instead of it you can use Digital Ocean cloud which will only take $5/Month charge for its simplest droplet. Heroku is another free service where you can deploy your product. Yes! Yes! What you heard is totally correct but here are some examples which are using other technologies Rails: Github, Twitter(previously), Shopify, Airbnb, Slideshare, Heroku etc. PHP: Facebook, Wikipedia, Flickr, Yahoo, Tumbler, Mailchimp etc.

结论是一个框架或语言不会为你做所有的事情。一个更好的架构,设计和策略会给你一个可扩展的网站。Instagram是最大的例子,这个小团队管理着如此庞大的数据。这里有一个关于它的架构的博客,一定要读。

目前在Django上构建的“最大”站点是什么?(我主要通过用户流量来衡量规模)

在美国,是Mahalo。我听说他们一个月要处理大约1000万份。现在,在2019年,Mahalo由Ruby on Rails支持。

在国外,Globo网络(巴西的新闻、体育和娱乐网站网络);Alexa将它们排在全球前100名(目前大约排在第80位)。

其他著名的Django用户包括PBS、国家地理、探索、NASA(实际上是NASA内部的许多不同部门)和国会图书馆。

Django能处理每天10万用户,每个用户访问站点几个小时吗?

是的——但前提是您编写了正确的应用程序,并且有足够的硬件。Django不是灵丹妙药。

像StackOverflow这样的网站可以在Django上运行吗?

是的(但请参见上文)。

在技术方面,很容易:请参阅soclone。在流量方面,compete将StackOverflow固定在每月100万次以下。我能说出至少十几个流量超过SO的Django站点。