S
S
seka22021-12-05 18:55:12
Node.js
seka2, 2021-12-05 18:55:12

Why node js + react js consume a lot of RAM?

Made the first project on node js + react js. The site is quite simple, the client part makes requests to the server via api and displays data using react js.
Locally it works stably and quickly. Laid out on the vds server, where 2 GB of RAM. The site works, but sometimes it crashes with an error 502.
I looked through the top command and saw that at the time of accessing the site, 10 GB of memory is being eaten (vert)
61ace04599531589551440.png

Which way to look? (I think it's pointless to throw the code, because few people want to poke around in it)

And one more thing, I launched the server part on a subdomain, and the client part on the main domain. But I didn’t buil via npm run buil, but I launched the client part via the server console via npm start - is this how they generally do it or is everyone bullying?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2021-12-05
@seka2

But I didn't buil via npm run buil

Well, for starters, it’s clear where the legs grow from.
Dev mode always eats much more RAM than the build.
In dev mode, webpack, babel (or ts), linters, loaders (scss, images, fonts, etc.) start working + a bunch of all sorts of auxiliary services (file watchers, for example, for rebuilding after changes) for the dev server to work, and npm packages that work only in dev mode, but not in prod, also a lot.
To roll out to the prod, you should always make builds, because. this is already pure code that the browser or server understands, which requires many times less resources to work. At least start with this.
PS It's not good to run processes under root, it's better to create a separate user who will have limited rights. But this is so, by the way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question