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
- 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
- Apache2, with mod_php-fpm, mod_wsgi and mod_rewrite enabled
- MySQL 8.0
- Python 3.10
- pipenv
- virtualenv
- PHP 8.2
- Composer
- Jmeter
- Create a database
mysqladmin -u root -p create django_symfony
- 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';
- Import the database
cd mysql_dumps
mysql -u django_symfony -p django_symfony < django_symfony.sql
# password: django_symfony
- Create a virtual environment
vitualenv -p python3.10 .venv
- Activate the virtual environment
pipenv shell
- Install the requirements
pipenv install
sudo chown -R www-data:www-data django_site
- adjust the apache_virtualhosts/django_app.conf file to your needs
- copy it to the apache configuration directory:
cd apache_virtualhosts
sudo cp django_app.conf /etc/apache2/sites-available/django_app.conf
- Enable the site
sude a2dissite 000-default.conf
sudo a2ensite django_app.conf
sudo systemctl reload apache2
- Install the dependencies
composer install --no-dev --optimize-autoloader
- 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
- adjust the apache_virtualhosts/symfony_app.conf file to your needs
- copy it to the apache configuration directory:
cd apache_virtualhosts
sudo cp symfony_app.conf /etc/apache2/sites-available/symfony_app.conf
- 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
- Install Jmeter
- Install the Jmeter plugins manager
- Install the Jmeter PerfMon plugin
- Lunch PerfMon Agent on the server
./jmeter/ServersAgent-2.2.3/startAgent.sh
# as default, the agent will listen on port 4444
- Adjust the Jmeter configuration to your needs from ./jmeter/TestPlan.jmx
Servers specifications:
- ec2 instances (t2.micro) 1 vCPU, 1GB RAM
- 20 concurrent users
- ramp-up period: 10 seconds
- duration: 15 seconds
- red: Django
- blue: Symfony
- 50 concurrent users
- ramp-up period: 10 seconds
- duration: 15 seconds
- red: Django
- blue: Symfony
How many concurrent users can the applications handle before reaching 90% of CPU usage?
The results are:
- Django: 10
- Symfony: 180
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.