Racing day: web frameworks

Overview

Speed is not everything when speaking about web frameworks, especially if you consider high availability production environments, cloud computing, CDNs, reverse proxies, caches, etc... Anyway, just for curiosity, what's the fastest one? I've tested different web frameworks based on several languages to find it out. What happened?

Setup

Frameworks

Template engines have been used whenever it was possible. Twig (Symfony), Blade (Laravel), Volt (Phalcon), Thymeleaf (Springboot), Hogan (Node + Express), Django templates, Play scala templates, Action view (Ruby On Rails). But Silex, Node stand-alone, Java 8 Servlet and Golang was only implemented to accept requests and respond a string.

I've tried to use latest versions. PHP7 for PHP based frameworks (Phalcon does not support it).

All PHP frameworks was deployed on Nginx Socket for php and Nginx Passenger for Ruby on Rails. NodeJS tested as cluster and as a single thread.

Procedure

No database access or complex features implemented. I think that wasn't the purpose, so the test was damn simple. It consisted in a local host server responding "hello world" to concurrent requests performed with Apache benchmarking tool and keeping the best result after at least 10 attempts. See apache AB test command line:

ab -n 10000 -c 100 [HOST]  

Number of requests: 10000, concurrency level: 100 (no keep alive)

Results

Chart below shows percentage of the requests served within a certain time for each framework

Requests performance

Time per request

Below you can find more detailed info about all frameworks behavior

Framework Test time [sec] Requests per second [#/sec] (mean) Request time [ms] (mean)
Golang 1.2.10.356281103.557
Play 2.4 + Scala 2.11 + Java 80.451222454.495
Java 8 servlet0.463216124.627
Springboot 1.3.1 + Java 80.485206214.849
NodeJS 5.4 (cluster)0.748133647.482
Phalcon 2.0 + PHP50.795125847.947
NodeJS 5.4 (cluster) + Express 4 + Hogan 30.987101339.868
NodeJS 5.4 (single thread)1.007992610.074
Django 1.9 + Gunicorn 19.4 + Python 3.42.193456021.929
NodeJS 5.4 (single thread) + Express 4 + Hogan 32.235447422.351
Silex 1.3 + PHP72.425412424.246
Ruby on Rails 4.2.5 + Passenger 5.05.425184354.254
Laravel 5.2 + PHP78.212121981.996
Symfony 3.0 + PHP79.805101998.046

Zoom in results

Best performance

Golang narrowly won the race, but keep in mind that springboot and play framework are full rich frameworks compared to a java 8 servlet and a simple golang server, so their performance is remarkable. Phalcon on PHP5 is really fast. Guess Phalcon running on PHP7...

Good performance

Express + Hogan slow down Node, but they offer good support for many features. NodeJS working as cluster is obviously faster than as a single thread

Worst performance

Symfony tends to be a bit slower as it evolves, but it's one of the most important web frameworks without a doubt.

Conclusion

Results speak for themselves. I think there is no more to add. Everything worked out as expected but Phalcon speed was a nice surprise. As I said, speed is not everything. Community support and development costs are fundamental as well as many other factors. So think about what you need before thinking about what you want.

Pieces of Code

See some pieces of code: