Node - how variables and spawning works

129
July 14, 2018, at 04:30 AM

When i write my web application, i have declared some variables. The declaration happens once.

For example (pseudocode): var specifics_of_a_visitor = [name, browser, country]; Of course this would never happen in real life, just as an example.

Now lets say two or more users use my web application on the same time. Each one of them uses the variable declared above (as an example).

How that happens in the server? Mupliple variables with the same name are created in memory? This is impossible. So how does Node works internally? If the visitors are too many, can your variables overload the RAM of your server?

Another question, lets say for the sake of your application, you use an external program via Node's spawn().

How does this gets handled in memory? Multiple applications, with each a different PID are started? One for each visitor?

Answer 1

How that happens in the server? Multiple variables with the same name are created in memory?

yes but each alocated in it's own contained space, which doesn't override the other process's space.

This is impossible.

There is nothing impossible. Thinking something is "Impossible" just means someone is ignorant about some subject.

So how does Node works internally? If the visitors are too many, can your variables overload the RAM of your server?

Hardly. Maybe in a massive DDOS. But the numbers are HUGE until this starts to happen. Node Servers deal with very large traffic/processing every day.

Another question, lets say for the sake of your application, you use an external program via Node's spawn(). How does this gets handled in memory? Multiple applications, with each a different PID are started? One for each visitor?

Oh... you want to know huh ? Read the source Luke:

https://github.com/nodejs/node

You don't have time to read understand the whole source code ? Well relax... node will take care of the processes for you. Just develop your sense of trust :D

Rent Charter Buses Company
READ ALSO
How to write google cloud vision api in AWS lambda function [on hold]

How to write google cloud vision api in AWS lambda function [on hold]

I want to use Google cloud vision api for extract the labels from imageSo i want to use google cloud vision api in AWS LAMBDA FUNCTION

147
MongoDB geoNear Optimizing

MongoDB geoNear Optimizing

In MongoDB there are multiple way to get record location base searchmy query takes 0

135