A useful hidden feature of NodeJS that might help in IoT

Hello All,

First of all I know that the title mentions only NodeJS, but this feature is not limited only to this environment. Other languages have this useful feature, that I’m going to mention below that is not used so much, but I believe it is very useful.

So

While working on a project I discovered by accident that NodeJS is a stateful environment, which means that your app will be compiled and loaded in memory, like any other compile language.

This means that you get access to RAM, and can store variable in memory even if you sit and refresh a page or hit an API call over and over again.

Since RAM is faster then Disk, and IoT generates massive amount of data. Knowing that you can use RAM to buffer, cash or just store data until your run out or your server will be reset, might be useful knowledge :smile:

If you would like to find out more about this feature, I have a nice and detailed technical article with simple code examples here https://github.com/davidgatti/Statefulness-aspect-of-NodeJS.

Let me know about your opinions, or share your experience if you use this feature already, and think it is awesome :smile:

3 Likes