Python / Django test and benchmark

Initializing

First initialize the mysql database from a previous dump as we did on the PERL virtual box.

Install the framework

Check for python version. And if needed install python setuptools. After it install django is very easy and can be done in 5 minutes.

Piece of cake. Definitely one point to Django.

First steps

Django will take care of everything if we put the following rows in command line.

Again, very easy and straightforward.

Now we have the basic site in out www directory. Let’s run the server to see it’w working. Sometimes the development server failed to server a request. In this case a refresh helped.

Import models from database to Django.

We need to setup the MySQL connection. It can be set in sandbox/settings.py. But first of all we have to install mySqlDb to python.

It is possible that we have to rearrange the order of models in the file according to the foreign keys because the referred class has to be before the referrer class.

Now we have all the models we need. Let’s create the test application.

Create the first application

In the gumi/urls.py file which we can set the to urls we need for the test.

Django was developed in a  very “DRY-driven” method which means you can always use the simplest solution for almost everything. In this example we don’t even need a controller (or how django calls it view) to be able to create this two pages. We just import some generic views ( DetailView and ListView) to the config file and write the templates.

Nginx and FastCGI

Again I think there’s no need to go in to details about this. It’s really some copy pasting some default nginx configuration file to be able to do this.

By the way. Test was run with threaded model fastcgi server started from init.d script with manage.py. With this solution there was no failing requests as we had before with the development server built in Django.

Results

The results look very good. Especially if we look on the memory and CPU usage. Shocking how small amount of CPU was used even with 50 concurrent thread. I thought PERL will be much faster with a little more cpu consumption but this results really surprised me. I’ve tested it three times but the numbers didn’t change.

Index Show
AB 5 conc 123,42 158,78
AB 20 conc 118,64 167,52
AB 50 conc 116,92 160,34
Memory usage 7,80% 6,10%
CPU usage 3,10% 2,20%

PHP Symfony benchmark »

You might like these too

Framework comparison summary To be able to size up an objective summing image I started to build an e-commerce website in all frameworks on the same model. These are my experience...
Framework comparison (PHP, PERL, Python) My first "program" was a BASIC script on Commode 64. It was able to print some text on the screen twenty times. The text was "Hello world". I copied i...
PHP / Symfony 1.2 with Propel test and benchmark Initializing Initialize the mysql database from a previous dump as I did earlier. Install PHP and Symfony 1.2 Unlike previous test subjects php...