Symfony vs Flask vs Spring Boot – part 1 usability and speed of coding

S

Hi, 

While making an online course “Elasticsearch as you have never known it before” I’ve created 3 separate sections with practice examples on how to build an advanced search system based on the Elasticsearch engine. According to course video sections next tutorials also appeared accordingly at current blog:

I suppose it would be interesting to compare current tech stacks between themselves. In all cases the same functionality was created – microservice as a web application, that will expose API points for providing hotels search (similar to booking com). And in all cases completely the same architecture principles and programming patterns were used. In the current article I would like to share with you my practice experience at building search microservice using above mentioned frameworks and programming languages. I promise that it would be a fair and independent review, as I like all of the current technologies on its own and I am still extensively using all of them at my commercial practice as software developer.  I want to provide comparison at next angle from 1 to 10 points:

  1. Usability – how easy/difficult was to provide next actions:
  • configuring local environment 
  • creating base project skeleton
  • creating API points and full “swagger” documentation to them
  • integration with Elasticsearch engine: creating model data layer, indexing data
  • creating search service and query builders 
  • debugging errors
  1. Speed of coding at framework taking into consideration programming language peculiarities.
  1. Performance benchmark of search systems.

First 2 aspects would be broadly discussed in the current article. The 3d one would be described at article “Symfony vs Flask vs Spring Boot – part 2 performance benchmark

Before we will start I want to add a small notice – I will give links to the articles from tutorials below in the text. Current articles were written a year ago, so all versions of programming languages, packages, frameworks and any additional software are related to that time. In case you are interested in upgraded fresh variants and changes related to it – then, welcome to my course at udemy. Anyway, upgrades to the last version of programming languages/frameworks and all changes to it does not change the essence of comparison a lot. So, let’s go.

Usability – Symfony vs Flask vs Spring Boot

Configuring local environment

Local environment was realized using docker-compose. According to the architecture scheme provided below, web server, microservice application by itself and Elasticsearch had to be run as docker containers.

ElasticSearch tutorial environment
ElasticSearch tutorial environment

In case Elasticsearch – here all is the same – extended docker image with some cosmetic adjustments. So, there is nothing to compare here. But in the case of dockerrizing web server and application – the situation is not so obvious.

The winner here is the Flask application. It was very easy to find the tiangolo/uwsgi-nginx image and examples to it – that allowed me to get dockerized web server and flask application at one docker container very fast and without any additional complications.. The Docker file appeared to be extremely simple. (You may find detailed information here: “Part2: Python, Flask, Elasticsearch and docker environment” of Flask Elasticsearch tutorial) So, I am giving here 10 points out of 10 possible.

In the case of Symfony, web server was realized by installing Nginx server upon base Ubuntu image and adding custom configuration. I am really a big fan of Nginx, but still it requires some knowledge – nginx + php fpm configuration can be not so easy task for beginners. Containerizing Symfony application, from another side, from my point of view, is not a complicated task, but final size of Docker file appeared to the biggest one among all competitors. Installing of PHP extensions, file permissions – all that requires some base low level admin skills. So, I am giving here 8 points out of 10 possible. Final configuration files can be found here: “Part 2: Symfony, Elasticsearch and docker environment” of Symfony Elasticsearch tutorial

The worst situation, as for me, at Spring Boot side. And it is not caused by frameworks, but by Java language, which requires compilation. As result all code should be at 1st compiled, which complicates devops life. As for me, the entry threshold here is really high – building all required dependencies and dockerizing java spring boot applications is full of “magic” details and non convenient in usage. In addition it slows down the coding process a lot. To make life at least a little bit better, I had to create a custom bash script. You may find all details at “Part 2: Java Spring Boot, Elasticsearch and docker environment” of Java Elasticsearch tutorial. It is the price we have to pay for compiled code that should give advantage at performance. If it is true or not – we will check it at the performance benchmark part.  Anyway, looking from a usability perspective – I am giving here 5 points out of 10 possible.

Creating base project skeleton

From that angle all 3 frameworks appearted at the same high level – good documentation, there are a lot of examples on the internet – 10 out 10 points for everyone.

Creating API points and full “swagger” documentation to them

All 3 frameworks – Flask, Symfony, Spring Boot – propose a classical Front Controller pattern, which is easy to start from. The difference appears at creating swagger API documentation. And here I am giving 1st place for Spring Boot. The best support for Request/Response models, the most brief annotations at Controller by itself. At initial course version, while using Spring Boot 2, I used Spring Fox Library, which you can find at according article: “Part 3: Spring Boot – Front Controller and API documentation of Java Elasticsearch tutorial”. Within the last upgrade to Spring Boot 3d generation, I had to replace swagger library at OpenAPI, but still – both libraries are at the same high level and there are a lot of examples on the internet how to use them in most cases. So here – 10 from 10.

In the case of Symfony + PHP – too many annotations, as for me, are required in comparison to Flask and Spring Boot. The Request Model for GET option appeared to be missing – so I had to extend it with custom class. From good news – documentation was rather full. I am giving here 8 from 10. You may find according article and code implementation here: “Part 3: Symfony Elasticsearch – Front Controller and API documentation” of Symfony Elasticsearch tutorial.

In case Flask – what I like in Python it is “brevity – the sister of talent”- models are clean and short, there is no need to define setters and getters explicitly. But there was also a negative aspect – documentation of the flask apisec package was not clear as for me and it was not so easy to find what I wanted. In that case my personal estimation is 9 from 10. Article relate to final implementation can be found here: “Part 3: Python, Flask, Elasticsearch – Front Controller and API documentation” of Flask Elasticsearch tutorial.

Integration with Elasticsearch engine: creating model data layer, indexing data

The winner here is Python Flask, or better to say Python Elasticsearch DSL package. It was a really pleasant experience to create a model data layer. Creating a console command for indexiong test data was a simple and fast process – so 10 from 10. Below you may find article titles of Flask Elasticsearch tutorial:

  • “Part 5: Python Flask Elasticsearch – model data layer”
  • “Part 6: Python Flask Elasticsearch – indexer command”

The 2d place took Symfony with ONGR Elasticsearch bundle for integration. My experience here was similar to the Flask. I am giving here 9 only because in some cases it was difficult to find examples and documentation requires upgrade in many places. Here are the titles to according articles of Symfony Elasticsearch tutorial:

  • “Part 5: Symfony Elasticsearch – model data layer”
  • “Part 6: Symfony Elasticsearch – indexing command”

Although the Java Elasticsearch data package is a wonderful tool for integration with Elasticsearch, I found it to be less intuitive, then in case with Symfony or Flask. Though, maybe it is only the deal of taste. But it was not the main reason I placed Spring Boot at the last place. The main problem, which I really don’t like – it is the lack of possibility to write console indexing commands in an easy way. The workarounds have to be used – e.g separate Spring Boot console application or initial loader, which I finally used. That’s why I am giving here only 8 from 10. If you are interested about details – please, visit next articles from Java Elasticsearch tutorial:

  • “Part 5: Spring Boot Elasticsearch – model data layer”
  • “Part 6: Spring Boot Elasticsearch – initial loader, indexing test data”
Creating search service and query builders

As for me, query builders are done very well at all Elasticsearch packages for integration which I used. Suppose it is mostly the deal of taste. So, in that case I am forwarding mostly my personal feelings. The results are next: Spring Boot – 8, Symfony – 9, Flask – 8. Articles related to according implementations are provided below:

Debugging errors

Essential point for every developer – time spent on debugging at the code problems. I will estimate it via prism of my own nerves and time, that I have spent at every framework to debug different problems:

  • Symfony + PHP + Elasticsearch – 10 from 10. Very easy to find and fix any problems.
  • Flask + Python + Elasticsearch – 9 from 10. Here I spent more time, mostly because of uwsgi caching and problems related with commenting different annotations during coding.
  • Java + Spring Boot + Elasticsearch – the worst case. I’ve spent 3 times more at debugging relative to 1st 2 realizations. Compiling time, non intuitive Java exception communicates – as result 7 from 10.

Speed of coding – Symfony vs Flask vs Spring Boot

Generally, the current parameter is a consequence, in a much degree, of usability features we already have passed – speed of code depends a lot on clear documentation, number of available examples on the internet, debugging issues, the availability of good integration libraries. Of course, the experience of a developer is among the most essential things that influence coding speed :). But in that case all coding was performed by one person – me :). I have commercial experience in all above mentioned programming languages and frameworks. And from my personal experience it appears that coding Web API applications using Symfony or Flask is at least 2 times faster than in case using Spring Boot. Java + Spring is a great choice for building multiplatform desktop applications, but in the Web world, from my opinion, it is not the best solution. Below you may find a summary scoreboard, which you can agree or disagree with. For sure all people are different, and all of us have our own preferences.  

Summary

Parameter Symfony PHPFlask PythonSpring Java
configuring local environment8105
creating base project skeleton101010
creating API points with“swagger”8910
integration with Elasticsearch engine9108
creating search service and query builders 988
debugging errors1097
speed of coding9106
Summary636654

Hope to see you soon in the article “Symfony vs Flask vs Spring Boot – part 2 performance benchmark”. If you want to get updates automatically, you may sign up to my newsletter. In case you want to get experience using any of the above mentioned stack for building advanced search systems – then welcome to my course at udemy – click at big red button below. As a reader of the current article you also can find a discount coupon here. Best regards.


About the author

sergii-demianchuk

Software engineer with over 15 year’s experience. Everyday stack: PHP, Python, Java, Javascript, Symfony, Flask, Spring, Vue, Docker, AWS Cloud, Machine Learning, Ansible, Terraform, Jenkins, MariaDB, MySQL, Mongo, Redis, ElasticSeach

architecture AWS cluster devops devops-basics docker elasticsearch flask geo high availability java php programming languages python recommendation systems search systems spring boot symfony