I have deployed an Angular 8 universal app in a server droplet of Digital Ocean. It is running in production. The server config is 4GB memory and 2 vCPU. The app is run via nodejs in the server. It's been running fine for over a month until recently it suddenly started crashing in no definite time. Since it's running in my client's computer browser, I don't know any way to monitor the error in their console. I also run this app with NOHUP command which dumps all the server side node js logs in a nohup.out file. But nohup.out file shows nothing about the crash.
Things that happened around the crash event started to happen.
1. I have pushed an update which is totally unrelated to the bootstrapping of the app. As per my understanding the Angular universal only renders the initial view and sends it to client browser. After that it's the browser that takes care of rest of the jobs.
The app uses websocket to maintain a bidirectional connectivity with the backend app written in Java. Also I don't think WS is the reason, because after implementing the WS feature, it ran just fine for over a week.
Thirdly i noticed that there are some image links(of the website) that are loaded from a CDN/Edge server and for last couple of days some static files located in the CDN server are taking too long to load/download. The response time to load those files spike up to 25-26 seconds sometimes. Since these static files are loaded during startup, can the delay of loading the static files cause any type of timeout event when Node JS renders the page in the startup?
As you can understand I have no clue how to debug this thing. Is there anyway who faced similar crashing issue with Angular Universal and help me point to the right direction? Thanks
Related
I have a REST api node app.
Once its running on localhost, it runs until I stop the dev debugging, no errors.
I moved it over to my cPanel hosting, installed a node app.
It starts up the same as localhost.
But after 30 minutes being idle, it shuts down.
The next request after this, restarts the app.
There are no crash or errors in the log, just the restarting messages.
I know this is default behaviour for free hosting, like Heroku but I'm paying for this hosting package.
Does anyone know...
Is this default behaviour for cPanel hosted node apps, or is my app causing this (using too much memory or cpu for example?
Is there any settings that can be edited to change this?
According to the docs, cPanel uses something called Phusion Passenger to run Node.js. In turn, Passenger docs show a default "idle time" of 5 minutes and a default of passenger_min_instances = 1. No idea if cPanel changes the defaults, or if the hosting provider did. I would recommend contacting the hosting provider about the issue in any case, and asking about these options specifically - they may be able to help or tune the service for you.
The startup time for a node app depends on what it's doing. A rest-api could be in the milliseconds, whereas a small Ai app loading a corpus or training a dataset (which mine was) could end up being 30 seconds plus. However the quantity of users did not warrant a dedicated server, so the work-around was to call the endpoint using a CRON, keeping the app alive.
Not perfect, but this type of thing may be useful if you are using aws lambda, which calls a 3rd party service, and which charges based on time taken. Every millisecond counts.
I have a Parse Server which is a Node.js + express wrapper for a mobile app (about 100 simultaneous users every day), hosted on DigitalOcean. The app server communicates with MongoDB, which is hosted on another droplet of DigitalOcean. I'm using pm2 as a process manager and its monitoring tool, which is web-based. On the same process, we operate LiveQuery, a WebSocket server made by the Parse community as well.
The thing is, I've been having some performance issues with the server. Everything works smoothly, until the Active handles rise up uncontrollably! (see the image below) It's like after one point the server says "I'm done! Now I rest!"
Usually the active handles stay between 30 to 70. The moment I restart the process with pm2 restart everything goes back to normal!
I've been having this issue for quite some time now and I haven’t been able to figure out what’s causing it! Any help will be greatly appreciated!
EDIT: I did a stress test where I created 200 LiveQuery sockets for 1 user, instead of 2 that a user normally has and there was a spike of 300 active handles, for like 5 seconds! The moment the sockets were all created, everything went back to normal!
I usually use restart based on memory usage
pm2 start filename.js --max-memory-restart 160 --exp-backoff-restart-delay=100
pm2 has also built-in cron job or autostart script setup in case the server ever restarts, see https://pm2.keymetrics.io/docs/usage/restart-strategies/
it would be could if pm2 would provide restart options based on active connections or heap memory
I recently uploaded a website to heroku (using their free service). The website is built using node.js and express. According to google I had a page speed score of 99 and 100 for mobile and desktop respectively. The following day I made some basic changes to the html and css, and after pushing to heroku again the TTFB is now extremely slow. The app was out of hibernation mode when I did the speed tests. Is this issue with Heroku's servers or should I look for another way to solve it? I don't know how changing the html and css would cause TTFB issues. Is this a common issue with Heroku?
Update: After pushing changes to heroku a second time I had no problems. Seems to have been a glitch with heroku's server.
TTFB is the time that the server takes to show the first byte of content. This audit fails when the browser waits more than 600ms for the server to respond to the main document request.
So, I don't know much about Heroku but if it is a free service, the response time must be much slower than the payment plans.
I have this app I'm developing and I thought of moving the VM I was using to real hardware. My Raspberry Pi 2 came to mind, a quad-core 900mhz ARM v7 with 1GB of ram. This hardware clocks at twice the speed I set my VM to run (a typical low end VPS equivalent) so it should be more than enough.
Installed Raspbian, nginx and the nodejs package from their repository using apt-get. Everything is super! But I noticed this distinct slowness when accessing the app. It's like a 7-10 sec pause before everything loads.
To test it further I installed full-fledged Node.js app called Tiddlywiki which I installed and used many times in the past. And it's true, there it was again that 7-10 sec delay when you refresh the page.
The app seems to run fine, POST and GET is instant once it's up and running in the Web Browser, but the delay is there if I refresh the page.
NOTE: If I restart the Pi and wait for it to restart the first time I access the app URL the delay seems to double, about 15 sec. Nginx html pages seem lightning fast in comparison.
Any thoughts on this?
Apparently Node.JS apps are quite fast on the Raspberry Pi 2.
The app I was test driving had and still has some weird behavior when using a password to encrypt content and starting the server with --password 12345678 made everything run very slow.
Running the app without a password is lightning fast.
PS. The app in question was Tiddlywiki, which can be run as a server for collaboration and such.
Environment: Windows Server 2008
I have a Node.js and a Sails.js apps. For example, my Node.js app does something like this:
http.createServer(function(req,res){...}).listen(8000);
Both are really simple apps, but I need them available at all times. I had problems creating a Windows Service, so i created a task for each app in the Task Scheduler.
They seem to be working fine except for when the apps haven't been used for over an hour or so (not sure on the exact timing). After some time when I go to localhost:8000, my Node.js app (same with my Sails.js app) responds only after about 10-20 seconds, and in less than a second in the following requests.
I am thinking about writing another task :) - a warm-up script that will send periodic requests to keep the apps running. But there's gotta be a better way! Is there a server timeout setting in Node.js/Sails.js that can be disabled/modified?