A
Alokai•2y ago
haider

Possible Memory leak in vuestorefront-api

Hi, we are using vuestorefront 1, problem we facing at the moment is that with time the api server in pm2 is keep increasing. We are not sure why the memory keeps increasing for api server, but there is no limit, we have to restart it. On staging server it does not increase, but on live server as there is alot of user traffic it goes to GBs in an hour. We had to put a cron to restart api server preiodically. How to find out what is causing this memory to pile up. and how come there is no garbage collection or something.. In Attached image shows the memory for api
8 Replies
rohrig
rohrig•2y ago
Hi, @haider 👋 , I will ask our engineer team about this. Could you please paste in your package.json?
haider
haider•2y ago
Thankyou, it would be great help, as this is impacting sales for the minidowntimes, sure following is the package.json file.
haider
haider•2y ago
this is another screenshot, showing api reached 12GB of memory usage.
haider
haider•2y ago
And already it went through 25 restarts.
rohrig
rohrig•2y ago
I’m checking internally for the best answer 🙂 I will get back to as soon I have an answer.
rohrig
rohrig•2y ago
Hi again @haider 👋 , I spoke with our engineering team and it turns out that this issue has come up on occasion, but finding the cause can be a difficult task that I, unfortunately, could not do this via discord support. There could be many causes, and I think the best way for you to find the cause is by using analytic tools. In the meantime, I can offer you a bandaid solution, but from what you’ve written, it seems you already restart when the memory capacity is reached. I’m not sure if this has been a manual process thus far, if so, this should at least help with that. The idea would be to set the max member restart limit to automatically restart the process if the memory limit is reached. Via the start command:
pm2 start api.js --max-memory-restart 896M
pm2 start api.js --max-memory-restart 896M
module.exports = {
apps: [{
name: 'api',
script: 'api.js',
max_memory_restart: '896M'
}]
}
module.exports = {
apps: [{
name: 'api',
script: 'api.js',
max_memory_restart: '896M'
}]
}
Here’s a link to the documentation: https://pm2.keymetrics.io/docs/usage/memory-limit/ I hope this is of some help to you. 🙂
PM2 - Memory Limit Reload
Advanced process manager for production Node.js applications. Load balancer, logs facility, startup script, micro service management, at a glance.
haider
haider•2y ago
Many thanks rohrig, i can understand we can do use max_memory_restart and put a limit there, as this already has been implemented on ecosystem file of vuestore. However the underline problem, i am not able to detect why the memory is piling up, because if we do place restarts on limit, eventually it will restart when limit gets reached and those restarts are causing application downtimes. And i am trying to avoid any downtime for application as its very bad for the business.
haider
haider•2y ago
This is my current ecosystem file for vuestore-api you are right we can put max_memory limit there, however i am concerned it will not gonna minimize the downtimes.
Want results from more Discord servers?
Add your server