Going for speed ? Then, use PHP (21/11/2017)

Please Ignore this article, as a "Hello world" test doesn't necessarily depict a real world usage scenario.


Ran some tests last night (21/11/2017 9:00 PM IST), simple "Hello World" prints.

Lighttpd + FastCGI + PHP5 gave the result in 1ms on the Firefox 57 Browser.

Nodejs + with its HTTP server + JS code gave the result in 5ms ff57 Browser.

Both tests were done on Ubuntu 14.04 VM running on loopback interface.

Lighttpd version 1.33.xx
PHP 5.5.xx

Nodejs 8.xx.xx

Not happy with what you see ? Try it out yourself !

So, right now, if your option is to run a web backend or mobile backend and you are looking at speed. The answer is plain and simple, use PHP5. From what I hear, PHP7 is supposed to be faster (need to verify this though).

So, what about webpython ?

The problem with PHP however is, people tend to write HTML code within it, makes Merging of two branches on source control a lot harder.

The problem with JS in nodejs is that its event based meaning its like writing callback functions. So, there is no flow of control making the code hard to debug. Atleast this is my opinion.

The problem with Python is... its slow... sigh!. While Python's native web server gives results of static pages in 20ms, Lighttpd gives results in 1ms for 180kb file. So what I am saying with a heavy heart(because I like it of the 3) is that Python is slow. [READ CORRECTION BELOW]
 
python -m http.server 8000 (is how it was made to run)
 
Need to test out the dynamic page's results between python3's native webserver and Lighttpd+FastCGI+Webpython.

Will have to speed up Python as well. The idea is to bring 30ms down to < 10ms as in give it a 3X speed improvement. I see this as a challenge. Even bigger challenge is to convince the community to accept my changes even if I ever manage to do that. :)

So, any ideas on speed improvement code changes ?

Corrections to the Article
Python3 20ms was on the first attempt when the web server just started up. FF57 gave 2-4ms on avg on subsequent requests. I wasn't able to reproduce it after restarting the web server though. And, yes cache is disabled. 

However, Chromium 62 gave worser performance with cache disabled. 2ms - 30ms on repeated attempts. 

Did FF57 just kick Chromium out of the Top spot ?

Comments

Popular Posts