Answer the question
In order to leave comments, you need to log in
How much Nodejs server should eat server memory?
Good day to all.
I came across the following situation and in my opinion this is not normal:
I have a MySQL database on the server, 2 sites with a small visitor (500-700 people per day) hang on it, and so this database eats up 500-600 MB of server memory and as they explained to me, this is too much and I need to optimize the database. Maybe the database is large, it processes requests and it is possible that calls to it are not particularly optimized, I don’t know, but it can be.
But here I have raised a Nodejs server with the most standard api with CRUD on board. I looked at how much memory was being eaten and was stunned, more than 1000 MB is occupied by the Nodejs server, which at the moment does not even process requests, it is just launched for personal use. Is this normal? Is the node server supposed to eat memory? Or do I most likely have a memory leak somewhere in the configuration of the server nodes?
Answer the question
In order to leave comments, you need to log in
By default, the Node.js process expects as much as 1.5 Gb of memory to be available to it.
The parameter --max_old_space_size
sets the maximum size of the so-called. Old Space - parts of the Heap where inactive and unnecessary data gets. This is, in practice, the area that occupies the most memory. It makes sense to limit it so that the Node process takes up less memory.
But less memory comes at a cost: Garbage colleciton , the process of clearing unused data from memory that is no longer referenced by global or active local variables, will run more frequently. This is a blocking process - Node completely stops while cleaning up memory, does not respond to requests and does not perform any actions.
: the entire Node will take slightly more.
You can set an environment variable WEB_MEMORY
which will set the amount of memory available to the node.js process in Mb: WEB_MEMORY=128 bash startup.sh
if you use the script proposed by the author of the article (in English) to launch the node application (in English, from where I just learned all this myself)
I have a MySQL database on the server, 2 sites with a small visitor hang on it (500-700 people per day), and so this database eats up 500-600 MB of server memory and, as they explained to me, this is too much and I need to optimize the database .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question