S
S
SEOD2019-11-23 13:46:35
PHP
SEOD, 2019-11-23 13:46:35

How to do web server load testing to compare PHP+Nginx vs Node.js?

I'm developing a simple web service, I don't know yet what rails to put it on. PHP and Node.js will do just fine with this task. The latter, perhaps, will be a little more difficult to sculpt, as long as there is less experience in working with HTTP servers + Node.js. But the syntax of the node is more familiar than that of PHP.
Therefore, I think, how to load the local server in order to understand which of these technologies returns static and generates HTML code faster (+ connecting to MySQL)? The latest PHP (+nginx) seems to work very fast, it's interesting to know what is lower in load, responds faster, will the difference be noticeable at all ... :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Belyaev, 2019-11-23
@bingo347

In terms of returning statics, it is unlikely that your code, even in php, even on node, will be able to compete in speed with Nginx, otherwise you would not ask such questions. In any case, it is worth putting nginx before any backend, even php, even node. In addition to distributing statics, you will also get normal work with tls and balancing.
By dynamics:
php - works only in the mode 1 request = 1 process, so there will be more processes in memory, which means more memory will be required and more CPU time will be spent on switch-context. Also, the queue of pending requests will be larger because php works synchronously, which means that while waiting for io (files / db) your process is idle. The fastest option right now is with php-fpm, which runs on the fastcgi protocol and keeps a pool of pre-running php threads. It is also possible to work on http with apache, but this option is obviously slower and heavier than php-fpm.
node - can process many requests in 1 process due to the asynchronous execution model, so you may need a small number of processes for a very large load. You can work with nginx both over the http protocol (available out of the box) and fastcgi (while still having 1 process)
Now for load testing, you need to be well versed in both tested technologies, be aware of possible optimizations and how to get around them. And even with all this, you will not get adequate results on synthetic examples ... You can compare the solution to a specific problem, but for this you will have to develop a solution based on both technologies, but do you need it? Most of the delays in most web services fall on the database, which is not particularly dependent on the chosen PL, although the asynchronous model is preferable here ...
So write what you can

A
Araya, 2019-11-23
@Araya

Download https://jmeter.apache.org/ and indulge in health

D
Dimonchik, 2019-11-23
@dimonchik2013

look at any benchmarks of frameworks
for adults, you can use Yandex tank
, but you can do it in a simple way - wrk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question