Jump to content

[Solved] Unexplained Nodejs mem usage


Rant

Recommended Posts

Hi, I set up an account yesterday and it was suspended overnight because of excessive mem usage. It's a simple nodejs app that was getting no traffic but mem usage kept growing. Since account was reinstated a little while ago the mem usage continues to unexplainably climb. So to test I've replace my app with this - it is the simplest, smallest possible nodejs app:

"use strict";

const express = require("express");

const app = express();
const port = 80;

app.get("/", async (req, resp) => {
    resp.send("<html><body>running - testing mem usage</body></html>");
});

// start server
app.listen(port, () => {
    console.log(`️[server]: Server is running at http://localhost:${port}`);
});

Not only would you expect that to use a small amount of memory, but also that it wouldn't continually grow. 

I have disabled PHP and any other scripting thing I could find so its only just nodejs running, and after making the above change I restarted the node app.

As you can see in attached image, mem usage continues to climb rapidly. You can't even see where I changed from my app to the above simple example - mem usage is continuing to climb at a constant rate.

I am sure this is nothing to do with me - is someone able to investigate please and see if you have access to more fine grained mem usage reporting to diagnose what is causing this. Thanks.

Account: runningantdev, tommy2

memusage.png

Edited by Rant
Link to comment
Share on other sites

Here are the 10 processes that ran between 2024-01-04 03:00:00 and 2024-01-04 15:00:00 and the memory they were using summed over that time

| 84636120 | npm run start                                                                                                   
| 59420164 | /opt/plesk/node/17/bin/node /opt/plesk/node/17/bin/yarn start                                                   
| 58993356 | node dist/index.js                                                                                              
| 30844056 | /opt/plesk/node/17/bin/node dist/index.js                                                                       
| 27468068 | Passenger NodeApp: /home/runningantdev.helioho.st/httpdocs                                                      
|    76708 | npm                                                                                                             
|    58140 | npm install                                                                                                     
|     4504 | /usr/lib64/passenger/support-binaries/PassengerAgent spawn-env-setupper /tmp/passenger.spawn.XXXXV6tGEG --after 
|     4396 | /usr/local/psa/admin/bin/vhostmng-find                                                                          
|     2208 | bash /opt/plesk/phpenv/libexec/phpenv-init -

Are you trying to say that someone other than you ran these commands?

Link to comment
Share on other sites

Your load looks fine for the last few hours

image.png.c24815a83c3d1f46c95aafdff57b52d0.png

Here's the same memory usage report for 2024-01-04 21:00:00 through 2024-01-05 02:00:00

10378912 | Passenger NodeApp: /home/runningantdev.helioho.st/httpdocs

I suspect those node, npm, yarn, etc commands were failed attempts to start your Node website and you didn't realize they were continuing to run in the background and you had no idea how to stop them. Hopefully, based on your recent memory usage, you've realized that Passenger loads and unloads your website for you so it doesn't run if there is no page hits, and it will help prevent you from being suspended.

For what it's worth, we do plan on adding a high load warning system that automatically kills processes and emails people before they get suspended. It's fairly high priority too because of people like you trying to crash our servers quite frequently.

Link to comment
Share on other sites

Thanks for your reply, I've since found Azure provides free nodejs hosting which just worked first go including with sqlite which was failing on your service, so I am going to move across to there. 

Link to comment
Share on other sites

SQLite works on HelioHost, it's just trickier to set up because you need to make sure the file permissions are correct so the database can be read from and written to. We usually recommend people use MariaDB or PostgreSQL because the performance is going to be much better, and it's easier to get working.

Link to comment
Share on other sites

  • Krydos locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...