Dadok recommends or compares different ways to deploy Django applications

    imageMore and more of our customers use the wonderful Django web framework in their projects and it is not surprising. After all, this framework allows you to create dynamic sites very quickly and at the same time has great flexibility. He has in his arsenal many ready-made solutions for almost all occasions, and in fact, is a low-level site builder. And its main advantage is its flexibility, due to which it is possible to create absolutely any web applications of any complexity in a short time.

    This framework has a convenient built-in web server on which you can debug your application without any problems, but it is naturally not suitable for real combat use.

    Recently, we have received many requests from clients regarding his deployment to a working server. In this regard, we decided to conduct a small test of several of the most popular bundles for performance and ease of use, to recommend our customers the best option.
    For tests, we took a typical Dedicated Server .

    Some server information:
    - Linux alex.tests 2.6.33.2 # 1 SMP Wed Apr 7 10:36:28 MSD 2010 i686 GNU / Linux
    Debian GNU / Linux 5.0 \ n \ l
    Intel® Core (TM) 2 Duo CPU E8400 @ 3.00GHz
    cpu cores: 2

    alex: ~ # free -m
    total used free shared buffers cached
    Mem: 3291 224 3067 0 10 187
    - / + buffers / cache: 26 3264
    Swap: 2055 0 2055

    - Three bundles participated in this test:
    1) apache2 + mod_wsgi
    This is the most common and recommended solution to date. This module can use two operating modes: embedded-mode (where Apache works similarly to mod_python) and the so-called daemon-mode, similar in principle to the operation of FastCGI / SCGI.

    2) nginx + flup
    Flup is essentially a set of different WSGI modules. It is the recommended method for starting django applications in FastCGI mode.

    3) nginx + superfcgi
    According to the author of the project, this is “The only one true way to run WSGI apps through fastcgi”. Its author is barbuza . This solution is not as common as the rest.

    In order to exclude artificial operating system limits on file descriptors, we set the following parameters on the server:
    ulimit -n 10240 (maximum size of recorded files by this shell)
    sysctl -w net.core.somaxconn = 150000 (maximum number of connections)
    sysctl -w fs .file-max = 100000 (number of open files)

    As a client, we used regular VDS on XEN, located on the server in the same rack. The load was created using httperf . This utility is specifically designed for this kind of research, it artificially creates a load on a remote server and has many settings.
    The test was a simple Django application that, by a specific url, called a specific view and loaded a small html-template. Thus, the test involved the main components of the framework. At this URL, 20,000 requests were made with increasing speed.

    In order to exclude all magic, after each bundle, the operating system on the server was reinstalled again, and the client rebooted.

    We were most interested in the reply rate and response time values. The memory consumption was also interesting.

    As a result, the results were as follows:

    image
    image

    The absolute leader is the nginx + superfcgi bundle, which, along with the ease of installation, makes it the best production option. And we can recommend it to our clients. It is interesting to note that even with 6000 requests in the case of this bundle (unlike others), there was no tendency to reduce the time and number of responses. As for the maximum memory consumption, it was 318Mb for Apache and about 290Mb in the case of nginx.

    And now an interesting suggestion: to all the readers of the hubr who bought a dedicated server, we can not only install and configure this bundle for free (for this, write a ticket and ask to send it to the Scripting Guru department), but we will also provide a 30% discount for the first month of renting a server . In order to activate the discount, you need to specify the promotional code: habradedic when ordering.

    Also popular now: