Answer the question
In order to leave comments, you need to log in
How does SSR-Rendering work in NODEJS and why is it different from PHP?
Good afternoon.
I transferred the project from PHP to Nuxt ssr, the performance dipped a lot, judging by the ab tests.
Good people said that nuxt (node) renders content on the server differently than PHP does, and the performance loss is obvious and justified. In nodejs, a render function works for rendering, and in general this technology is much more complicated, and therefore slower.
I always thought that it works like this:
- PHP receives the request, executes the script, "collects" the markup and gives it to the browser.
- Nodejs does everything in much the same way. In the case of modern JS frameworks (react, vue), the choice of nodejs for server rendering is due to the fact that most of the JavaScript code will be executed on the server, and the code that cannot be executed on the server (DOM, Window, XHR etc) must be processed depending on where it is running.
Well, that is, instead of nodejs, PHP could also be used for server rendering, and then there would be no difference between server rendering and the usual (old fashioned) response generation on the server, when navigating through pages is always a new request to the server.
Can you please explain what is the difference between rendering in PHP and Nodejs and why the second one is much less productive?
Answer the question
In order to leave comments, you need to log in
SSR is the launch of a front-end js-framework on a node in advance (instead of working in a browser) and giving back to the client what happened, along with the framework, then it all continues to work on the client.
php doesn't have it.
correctly, the question sounds like this: "why is what I have written on nodejs slower than what I had on php" the answer, as you understand, depends on what exactly you have written there. In general, rendering on a node is no slower than rendering in php by itself. Maybe you have everything set up like that, maybe just ssr slows down
Because in PHP you use a fast template engine to the maximum.
Nuxt uses Vue for rendering, which is somewhat more complex.
If you want - use it, but you will lose the advantages that isomorphic code gives.
Comparing the performance of PHP and Node, in your case, is not correct. Since it's about the specific tools you use.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question