Monday, September 5, 2011

Performance Comparison between django-cms and drupal

Recently, I run a benchmark to compare the performance of a django-cms vs drupal installation. The results were pretty interesting. Let me start by pointing you first to this article I found online, which was the most comprehensive comparison between drupal and django I've seen overall.

I'll summarize here the points of that article, but I'd strongly recommend you to read it, to get the big picture. There are eight different sections in which the author of that article focuses and these are:

  • Templating system
  • OOP
  • MVC/MTV
  • ORM
  • Learning Curve
  • Community Resources
  • Security
  • Performance

Lets take a look at each one briefly.

Templating system

Django is using a clean inheritance-based templating system which makes it easy to nest templates within templates, use different templates for different parts of the site and to completely eliminate redundancy in template code. In contrast, with Drupal it can be difficult to customize templates.

OOP

Python, by its nature, is an object oriented language and thus is django. PHP in general is not object oriented.

MVC/MTV

Django is using the model-view-controller architecture (which is know as MTV within the django community). MVC is the most widely accepted architecture to build webapps. Drupal follows the PAC (Presentation-Abstraction-Control) model rather than MVC.

ORM

In Django, you have to define your data models that describe the site. All models have datatypes and those are interdependent. From defined data model, database tables are auto-generated, and the system becomes internally “aware” of data relationships. To query your db you use Object Relational Mapper (ORM). So, rather than writing SQL queries, for django one has to write “querysets” like: customPage = CustomPages.objects.filter(author='foo') This way we avoid long error prone SQL queries (both security and development effort advantages). Drupal does not have an ORM. In this case I'll have to also note that using ORM is not always ideal. Keep in mind that when we use ORM based query, we are not aware of the actual SQL queries that run behind the scenes. So in simple, flat queries ORM is fine, although moving towards more complicated queries, ORM may become a performance headache.

Learning Curve / Language

Drupal is often accused for having a steep learning curve. I would argue that learning django/python is way easier, but probably I am biased towards python, since I am familiar with this language.

Security

It’s true that Drupal has a history of security issues, whereas similar issues in django are extremely rare.

Performance

In this section the article was kind of falling short. So I tried to clear out which is the winner in this case and below are the results of what I found.

Performance Comparison

I run a benchmark of a django-cms vs drupal installation on my laptop. Benchmark used is FunkLoad. Results on the following table are after testing on my laptop, which has 8 cores (2GHz Intel i7), 8G memory. For these tests mod_wsgi is configured to spawn 20 processes. Be aware: by default mod_wsgi is using just one process. Both drupal and django pages tested are pretty simple html pages with minimal content (one 12K css file, no js). Have to note here that the django-cms page included one plugin, which was loading a news item.

Installation Concurrent Users RPS (Requests per second) Response Time
Django-cms 50 99 0.25
Drupal 50 111 0.23

Below you can find more detailed graphs.

Drupal

Concurrent Users

Requests per sec

Django-cms

Concurrent Users

Requests per sec

Results

As you can see from the results, the difference in the performance between those two installations is negligible. Django-cms loads the page with 0.02sec delay, although this is probably related to the fact that the django-cms page included one plugin and on the other hand drupal's page was pretty much empty ("plugin free"). Bottom line is that there is no major difference between the two frameworks performance-wise. So at the end of the day its up to the developer/decision-maker to pick the language of his/her preference and build a CMS with one of the two frameworks. Performance shouldn't be a concern.





References
  1. Django documentation
  2. Drupal documentation
  3. PAC
  4. MTV
  5. Drupal or Django?

4 comments:

  1. Drupal works fast on fresh install only. It's impossible to run production site with configured users, content types and modules without advanced caching solutions.

    ReplyDelete
  2. What about joomla v 1.6 or 1.7? I don't ask about 1.5 because it really sucks...But I still don't know about the performance of the latest versions...

    ReplyDelete
  3. Nice blog post!

    Unless I am misreading the graphs, it seems that django suffers from increased response time variance under heavier loads. I would suggest increasing the load to test out that theory but it looks like both configurations peak relatively early (assuming no network or disk I/O) with only ~100 reqs/sec. IMHO that is indicative of some external bottleneck on the system. Are all your cores maxed out during the test? Maybe you are running out of memory and paging too much?

    ReplyDelete
  4. @papercruncher I used loads of 20/40/50 users which is not linear. Thats why graph may look like its slowing down. I could test with more reqs/sec as you suggest and see what happens. Still though testing the limits of each framework wasn't my goal. I just wanted to compare the response times of those two frameworks in "same environments".

    ReplyDelete