Git Product home page Git Product logo

django_vs_symfony's Introduction

Symfony vs Django

Table of contents

Description

This repository contains two simple applications written in Symfony and Django. The goal is to compare the performance of both frameworks. Both applications has the same functionality: displaying a list of questions and related choices, and has the bare minimum requirements of an MVC application:

  • Models: ORM and Connecting to a database
  • Views: using a template engine
  • Controllers: Business logic and routing mechanism

Project structure

  • apache_virtualhosts: contains the apache virtual hosts configuration files
  • django_site: contains the django application
  • mysql_dumps: contains the mysql database dump
  • symfony_app: contains the symfony application
  • jmeter: contains the jmeter configuration files

Requirements

  • Apache2, with mod_php-fpm, mod_wsgi and mod_rewrite enabled
  • MySQL 8.0
  • Python 3.10
  • pipenv
  • virtualenv
  • PHP 8.2
  • Composer
  • Jmeter

Installation

Database

  1. Create a database
mysqladmin -u root -p create django_symfony
  1. Create a user
mysql -u root -p
mysql> CREATE USER 'django_symfony'@'localhost' IDENTIFIED BY 'django_symfony';
mysql> GRANT ALL PRIVILEGES ON django_symfony.* TO 'django_symfony'@'localhost';
  1. Import the database
cd mysql_dumps
mysql -u django_symfony -p django_symfony < django_symfony.sql
# password: django_symfony

Django

Installation

  1. Create a virtual environment
vitualenv -p python3.10 .venv
  1. Activate the virtual environment
pipenv shell
  1. Install the requirements
pipenv install
sudo chown -R www-data:www-data django_site

Server configuration

  1. adjust the apache_virtualhosts/django_app.conf file to your needs
  2. copy it to the apache configuration directory:
cd apache_virtualhosts
sudo cp django_app.conf /etc/apache2/sites-available/django_app.conf
  1. Enable the site
sude a2dissite 000-default.conf
sudo a2ensite django_app.conf
sudo systemctl reload apache2

Symfony

Installation

  1. Install the dependencies
composer install --no-dev --optimize-autoloader
  1. Clear/Generate the cache
APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
# insure permissions are correct
sudo chown -R www-data:www-data var # or sudo chmod -R 777 var

Server configuration

  1. adjust the apache_virtualhosts/symfony_app.conf file to your needs
  2. copy it to the apache configuration directory:
cd apache_virtualhosts
sudo cp symfony_app.conf /etc/apache2/sites-available/symfony_app.conf
  1. Enable the site
sudo a2ensite symfony_app.conf
# disable python app
sudo a2dissite django_app.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2

Benchmarking with Jmeter

  1. Install Jmeter
  2. Install the Jmeter plugins manager
  3. Install the Jmeter PerfMon plugin
  4. Lunch PerfMon Agent on the server
./jmeter/ServersAgent-2.2.3/startAgent.sh
# as default, the agent will listen on port 4444
  1. Adjust the Jmeter configuration to your needs from ./jmeter/TestPlan.jmx

Django vs Symfony Shock Unexpected

Results:

Servers specifications:

  • ec2 instances (t2.micro) 1 vCPU, 1GB RAM

Settings

  • 20 concurrent users
  • ramp-up period: 10 seconds
  • duration: 15 seconds

Response time over time:

response_time_over_time

Perfmom metrics:

perfmom_metrics

  • red: Django
  • blue: Symfony

Settings

  • 50 concurrent users
  • ramp-up period: 10 seconds
  • duration: 15 seconds

Response time over time:

response_time_over_time

Perfmom metrics:

perfmom_metrics

  • red: Django
  • blue: Symfony

Settings

How many concurrent users can the applications handle before reaching 90% of CPU usage?

The results are:

  • Django: 10
  • Symfony: 180

Conclusion

as Objective as I can be, and based on my tests, I can say: Symfony/Php is to much faster, and efficient than Django/Python.

django_vs_symfony's People

Contributors

moh-snoussi avatar

Watchers

 avatar

Forkers

humpangle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.