views:

9123

answers:

21
+86  Q: 

Does Django Scale?

Hello,

I'm building a web application with Django. The reasons I chose Django were:

  • I wanted to work with free/open-source tools
  • I like Python and feel it's a "long term" language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to learn.
  • I'm building a prototype for an idea and wasn't thinking too much about the future. Speed was the main factor, and I already knew Python. [Edit: To clarify - I mean development speed rather than optimized speed of execution]
  • I knew the migration to Google App Engine would be easier should I choose to do so in the future.
  • I heard Django was "nice"

Now that I'm getting closer to thinking about publishing my work, I start being concerned about scale. The only information I found about the scaling capabilities of Django is provided by the Django team (I'm not saying anything to disregard them, but this is clearly not objective information...).

My questions to you:

  • What's the "largest" site that's built on Django today? (I measure size mostly by user traffic)
  • Can Django deal with 100,000 users daily, each visiting the site for a couple of hours?
  • Could a site like Stack Overflow run on Django?

Thanks

+1  A: 

My experience with Django is minimal but I do remember in The Django Book they have a chapter where they interview people running some of the larger Django applications. Here is a link. I guess it could provide some insights.

It says curse.com is one of the largest Django applications with around 60-90 million page views in a month.

tomeedee
+11  A: 

The largest django site I know of is the Washington Post, which would certainly indicate that it can scale well.

Good design decisions probably have a bigger performance impact than anything else. Twitter is often cited as a site which embodies the performance issues with another dynamic interpreted language based web framework, Ruby on Rails - yet Twitter engineers have stated that the framework isn't as much an issue as some of the database design choices they made early on.

Django works very nicely with memcached and provides some classes for managing the cache, which is where you would resolve the majority of your performance issues. What you deliver on the wire is almost more important than your backend in reality - using a tool like yslow is critical for a high performance web application. You can always throw more hardware at your backend, but you can't change your users bandwidth.

Bayard Randel
Isn't only part of washingtonpost.com run on Django? The Django frontpage seems to indicate it's only http://projects.washingtonpost.com/congress/
Xiong Chiamiov
+6  A: 

I'm sure you're looking for a more solid answer, but the most obvious objective validation I can think of is that Google pushes Django for use with its App Engine framework. If anybody knows about and deals with scalability on a regular basis, it's Google. From what I've read, the most limiting factor seems to be the database back-end, which is why Google uses their own...

jess
+2  A: 

Yes it can. It could be Django with Python or Ruby on Rails. It will still scale.

There are few different techniques. First, caching is not scaling. You could have several application servers balanced with nginx as the front in addition to hardware balancer(s). To scale on the database side you can go pretty far with read slave in MySQL / PostgreSQL if you go the RDBMS way.

Some good examples of heavy traffic websites in Djano could be:

  • Pownce when they were still there.
  • Dscus (generic shared comments manager)
  • All the newspaper related websites: Washington Post and others.

You can feel safe.

coulix
+1  A: 

If you haven't already, I recommend reading the section on scaling in The Django Book:

http://www.djangobook.com/en/1.0/chapter20/

Or the newer version:

http://www.djangobook.com/en/2.0/chapter12/

monkut
I read it, thanks, but as I mentioned, I was looking for information not coming from Django or the Django-book.
Roee Adler
+2  A: 

Note that if you're expecting 100K users per day, that are active for hours at a time (meaning max of 20K+ concurrent users), you're going to need A LOT of servers. SO has ~15,000 registered users, and most of them are probably not active daily. While the bulk of traffic comes from unregistered users, I'm guessing that very few of them stay on the site more than a couple minutes (i.e. they follow google search results then leave).

For that volume, expect at least 30 servers ... which is still a rather heavy 1,000 concurrent users per server.

Jess
It appears from the podcast that SO uses just 3 servers. But SO is built using C#, not Python, so it rips.
S.Lott
Obviously the question will be: How much powerfull servers are they?
mamcx
+11  A: 

I was at the EuroDjangoCon conference the other week, and this was the subject of a couple of talks - including from the founders of what was the largest Django-based site, Pownce (slides from one talk here). The main message is that it's not Django you have to worry about, but things like proper caching, load balancing, database optimisation, etc.

Django actually has hooks for most of those things - caching, in particular, is made very easy.

Daniel Roseman
+29  A: 

Playing devil's advocate a little bit:

You should check the DjangoCon 2008 Keynote, delivered by Cal Henderson, titled "Why I hate Django" where he pretty much goes over everything Django is missing that you might want to do in a high traffic website. At the end of the day you have to take this all with an open mind because it is perfectly possible to write Django apps that scale, but I thought it was a good presentation and relevant to your question.

Paolo Bergantino
Also, Flickr wasn't built in a day.
Deniz Dogan
+55  A: 
  1. "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:

  2. "Can Django deal with 100,000 users daily, each visiting the site for a couple of hours?"

    Yes, see above.

  3. "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 :)

There are, of course, many more sites and bloggers of interest, but I have got to stop somewhere!

Dec 2009 UPDATE:

Blog post about Using Django to build high-traffic site michaelmoore.com described as a top 10,000 website. Quantcast stats and compete.com stats.

Van Gale
Curse moved to ASPNET for reasons I don't know.
Oli
Gah, thanks Oli, I hadn't seen any news about that :(
Van Gale
I seem to remember curse going through an acquisition about 6 months ago - that might have influenced their decision to change technologies. I wouldn't put it down to any inadequacy in django.
Bayard Randel
@Oli a quick google search didn't turn up anything about Curse moving to ASP.NET (all I can seem to find about their tech is related to Django). Do you have a link?
TM
Response headers seem to indicate ASP.NET $ curl -I http://curse.com/ HTTP/1.1 301 Moved Permanently Content-Type: text/html; charset=UTF-8 Location: http://www.curse.com/ Server: Microsoft-IIS/7.0 X-Powered-By: ASP.NET Date: Thu, 03 Dec 2009 22:16:05 GMT Content-Length: 144 Connection: close
unhillbilly
Also, Mahalo.com
Zack
many pbs.org sites use Django
Evgeny
why curse.com moved to asp.net????
vernomcrp
Disqus.com serves more traffic than any of the sites mentioned so far.
Andrew B.
vernomcrp: I've spoke with a curse.com django developper some month ago, and the rewrite of the website in asp.net was a decision of the leaders (Why ? I don't know..)
Kedare
Hunch.com is built on Django and has significant traffic
828
+43  A: 

We're doing load testing now. We think we can support 240 concurrent requests (a sustained rate of 120 hits per second 24x7) without any significant degradation in the server performance. That would be 432,000 hits per hour. Response times aren't small (our transactions are large) but there's no degradation from our baseline performance as the load increases.

We're using Apache front-ending Django and MySQL. The OS is Red Hat Enterprise Linux (RHEL). 64-bit. We use mod_wsgi in daemon mode for Django. We've done no cache or database optimization other than to accept the defaults.

We're all in one VM on a 64-bit Dell with (I think) 32Gb RAM.

Since performance is almost the same for 20 or 200 concurrent users, we don't need to spend huge amounts of time "tweaking". Instead we simply need to keep our base performance up through ordinary SSL performance improvements, ordinary database design and implementation (indexing, etc.), ordinary firewall performance improvements, etc.

What we do measure is our load test laptops struggling under the insane workload of 15 processes running 16 concurrent threads of requests.

S.Lott
+1: excellent!
Van Gale
just curious, is this a single server setup? what are the specs on the server(s)?
monkut
It's one VM on a 64-bit Dell with 32Gb RAM (AFAIK).
S.Lott
Also curious: is your DB running on the same machine, or a separate server?
Jarret Hardie
One VM with Apache, Django and MySQL. mod_wsgi. RHEL.
S.Lott
+2  A: 

Another example is rasp.yandex.ru, Russian transport timetable service. Its attendance satisfies your requirements.

Glader
+4  A: 

Scaling Web apps is not about web frameworks or languages, is about your architecture. It's about how you handle you browser cache, your database cache, how you use non-standard persistence providers (like CouchDB), how tuned is your database and a lot of other stuff...

Don't bother...

razenha
A downvote? Why?
razenha
+1 I didn't downvote, but maybe it's because of the don't bother?
Roee Adler
Web framework do matter! Look how fast tornado compared to other python webframework: http://www.tornadoweb.org/documentation#performance
jpartogi
+2  A: 

Could a site like Stack Overflow run on Django?

Chinese version of Stack Overflow is using Django:

http://stackoverflow.com/questions/694966/impressed-or-angry-at-http-www-cnprog-com

GvS
+2  A: 

You can definitely run a high-traffic site in Django. Check out this pre-Django 1.0 but still relevant post here: http://menendez.com/blog/launching-high-performance-django-site/

Ed Menendez
+2  A: 

If you have a site with some static content, then putting a Varnish server in front will dramatically increase your performance. Even a single box can then easily spit out 100 Mbit/s of traffic.

Note that with dynamic content, using something like Varnish becomes a lot more tricky.

Anders Rune Jensen
+3  A: 

I have been using Django for over a year now, and am very impressed with how it manages to combine modularity, scalability and speed of development. Like with any technology, it comes with a learning curve. However, this learning curve is made a lot less steep by the excellent documentation from the Django community. Django has been able to handle everything I have thrown at it really well. It looks like it will be able to scale well into the future.

BidRodeo Penny Auctions is a moderately sized Django powered website. It is a very dynamic website and does handle a good number of page views a day.

+24  A: 

What's the "largest" site that's built on Django today? (I measure size mostly by user traffic)

In the US, Mahalo. I'm told they handle roughly 10 million uniques a month.

Abroad, the Globo network (a network of news, sports, and entertainment sites in Brazil); Alexa ranks them in to top 100 globally (around 80th currently).

Other notable Django users include PBS, National Geographic, Discovery, NASA (actually a number of different divisions within NASA), and the Library of Congress.

Can Django deal with 100k users daily, each visiting the site for a couple of hours?

Yes -- but only if you've written your application right, and if you've got enough hardware. Django's not a magic bullet.

Could a site like StackOverflow run on Django?

Yes (but see above).

Technology-wise, easily: see soclone for one attempt. Traffic-wide, compete pegs StackOverflow at under 1 million uniques per month. I can name at least dozen Django sites with more traffic than SO.

jacobian
+2  A: 

Here's a list of some relatively high-profile things built in Django:

  1. The Guardian's "Investigate your MP's expenses" app

  2. Politifact.com (here's a Blog post talking about the (positive) experience. Site won a Pulitzer.

  3. NY Times' Represent app

  4. EveryBlock

  5. Peter Harkins, one of the programmers over at WaPo, lists all the stuff they’ve built with Django on his blog

  6. It's a little old, but someone from the LA Times gave a basic overview of why they went with Django.

  7. The Onion's AV Club was recently moved from (I think Drupal) to Django.

I imagine a number of these these sites probably gets well over 100k+ hits per day. Django can certainly do 100k hits/day and more. But YMMV in getting your particular site there depending on what you're building.

There are caching options at the Django level (for example caching querysets and views in memcached can work wonders) and beyond (upstream caches like Squid). Database Server specifications will also be a factor (and usually the place to splurge), as is how well you've tuned it. Don't assume, for example, that Django's going set up indexes properly. Don't assume that the default PostgreSQL or MySQL configuration is the right one.

Furthermore, you always have the option of having multiple application servers running Django if that is the slow point, with a software or hardware load balancer in front.

Finally, are you serving static content on the same server as Django? Are you using Apache or something like nginx or lighttpd? Can you afford to use a CDN for static content? These are things to think about, but it's all very speculative. 100k hits/day isn't the only variable: how much do you want to spend? How much expertise do you have managing all these components? How much time do you have to pull it all together?

mazelife
+2  A: 

Check out this micro news aggregator called EveryBlock.

It's entirely written in Django. In fact they are the people who developed the Django framework itself.

siddu
+1  A: 

If it means anything, Django is run on Python (platitude intended)

YouTube is built on Python.

YouTube has about 500 million hits per month and about 90 million users per month.

orokusaki
But youtube is not built with django. Python might be fast, but not so for django.
jpartogi
Yea, but the point was that as Django grows, it's sitting on a good foundation for speed re factoring and with Google out there working on projects like Unladen Swallow, it'll just get better.
orokusaki
+5  A: 

http://bitbucket.org is built using Django 1.2. Here's a write up on it: http://code.djangoproject.com/wiki/DjangoSuccessStoryBitbucket. It has approx. a million hits per month based on this info http://www.trafficestimate.com/bitbucket.org.

Also the disqus comment system is built using Django. It seems to be the "...Worlds largest Django Application". They have scaled Django to reach over 125 million unique visitors per month. They are giving a talk at Django con us about scaling. http://djangocon.us/schedule/sessions/1/

Neil