This is how long it takes to:
- Send request
- Execute query
- Receive data
- Send data to sever
This is the case using nodejs:
Then, exactly the same database, query, data, but using PHP to send the response:
As you can see, the combination php + firebirdSQL (Apache2, all SSL), was considerably faster than the NodeJs approach.
I need to say that my nodejs server does not compress the data, so the tool reports 35K data received for the PHP response and 175K for the nodejs response.
However, why is it taking so much longer in all of the following tasks?
- DNS Lookup (same site)
- Initial connection 174 vs 237
- SSL 90 vs 164
- Waiting PHP: 223.94 ms vs. Nodejs: 291.72 (PHP did compress, Nodejs, did not; query is identical).
- Content download: PHP: 87.34 ms vs. Nodejs: 221.39 ms almost 3 times longer
I need think about a reason for the fuss behind NodeJS. Perhaps if my server had 300 simultaneous connections, then I would see an advantage in NodeJS, where, maybe the increase in time would not be linear, as would be the case with PHP+Apache2+ssl.
It took two full days and half of their nights to figure out how to put this to work. Now I have a NodeJs server that connects seamlessly to my FirebirdSQL database, executes queries, (select, insert, update, delete) and gives back a decent response of the results. This is the part I like.
Look at the code in NodeJs:
pdo.sql can contain any sql statement without parameters.
The code is really nice, but there is no speed advantage whatsoever.
I think this is a valid test, since the only element that changes is precisely the middle software (PHP+Apache2+SSL+FirebirdSQL) vs (NodeJs+SSL+FirebirdSQL).
So, where do we go from here?