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
- Intel i7 8GB RAM
- Ubuntu 14.04
- Apache HTTP server benchmarking tool
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.1 | 0.356 | 28110 | 3.557 |
Play 2.4 + Scala 2.11 + Java 8 | 0.451 | 22245 | 4.495 |
Java 8 servlet | 0.463 | 21612 | 4.627 |
Springboot 1.3.1 + Java 8 | 0.485 | 20621 | 4.849 |
NodeJS 5.4 (cluster) | 0.748 | 13364 | 7.482 |
Phalcon 2.0 + PHP5 | 0.795 | 12584 | 7.947 |
NodeJS 5.4 (cluster) + Express 4 + Hogan 3 | 0.987 | 10133 | 9.868 |
NodeJS 5.4 (single thread) | 1.007 | 9926 | 10.074 |
Django 1.9 + Gunicorn 19.4 + Python 3.4 | 2.193 | 4560 | 21.929 |
NodeJS 5.4 (single thread) + Express 4 + Hogan 3 | 2.235 | 4474 | 22.351 |
Silex 1.3 + PHP7 | 2.425 | 4124 | 24.246 |
Ruby on Rails 4.2.5 + Passenger 5.0 | 5.425 | 1843 | 54.254 |
Laravel 5.2 + PHP7 | 8.212 | 1219 | 81.996 |
Symfony 3.0 + PHP7 | 9.805 | 1019 | 98.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: