T
T
testopikachu2019-03-25 17:11:07
PHP
testopikachu, 2019-03-25 17:11:07

How much performance degradation does node.js have when running it through php's exec() function?

Hello, I want to organize server rendering on laravel +
vue.js every boot launches

<?php $result = exec('/usr/local/bin/node file.js')
that is, node.js does not hang as a server, but restarts each time.
Tell me, how much performance can suffer from this? What pitfalls can I expect? Is it worth getting involved with?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Belyaev, 2019-03-25
@testopikachu

time node -p '(process.memoryUsage().heapUsed/1048576).toFixed(2)+"M"'
we run it on our server and admire the overhead from running a bare node...
I have (node ​​v10.15.3) like this:
3.71M

real	0m0,076s
user	0m0,064s
sys	0m0,012s

now let's add the work of vue-ssr here, which recommends to fasten the cache for a reason...
in general, think for yourself how much you need to wait 100-200ms for an overhead and spend ~ 5MB per request

A
Anton Shvets, 2019-03-25
@Xuxicheta

exec starts an external program. The performance of the node does not change in any way.
It depends on how to start rendering, but in general the node should not hang as a server, it renders everything once and ends, it's just a script.
Although if you re-render the entire project for every sneeze, then this is clearly not the best solution.
But rendering when the source data changes is normal.

B
bro-dev, 2019-03-26
@xPomaHx

+0.1s on average, due to the long launch of v8, which is a lot.

D
Dmitry Evgrafovich, 2019-03-26
@Tantacula

Are you sure that this process is launched every time a request is made to the server, and is not compiled once after changes, like Laravel views?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question