Hello, this morning (Central Time (CST)) my app it was working well, and some minutes ago it was increasing memory usage (at this moment has 1.011GB) and normally it was consuming 120MB. When I tried to call methods (with Meteorman DDP Client) or login, it takes like 7 seconds (returns with error because of timeout of the connection) and after that the session is disconnected.
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
49e4eca38d44 crontab 0.00% 1.484MiB / 3.844GiB 0.04% 1.48kB / 0B 0B / 0B 1
1545bfa635cb app 44.03% 1.103GiB / 3.844GiB 28.69% 132MB / 202MB 4.1kB / 0B 11
These are my meteor packages:
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
email@example.com # Packages every Meteor app needs to have
firstname.lastname@example.org # Packages for a great mobile UX
email@example.com # The database Meteor supports right now
firstname.lastname@example.org # CSS minifier run for production mode
email@example.com # JS minifier run for production mode
firstname.lastname@example.org # ECMAScript 5 compatibility for older browsers
email@example.com # Enable ECMAScript2015+ syntax in app code
firstname.lastname@example.org # Enable TypeScript syntax in .ts and .tsx modules
email@example.com # Server-side component of the `meteor shell` command
firstname.lastname@example.org # Dependency tracker to allow reactive callbacks
static-html # Define static page content in .html files
akryum:vue-component # Vue-CLI template to publish components
meteortesting:mocha # A package for writing and running your meteor app and package tests with mocha
Anyelse have had the same problem?
- Server: Digital Ocean - Docker image: disney/meteor-base - 4GB , 2vCPUs
- Node 14.17.1
- Meteor 2.3.0
- Mongo Atlas 4.4.6
Check for memory leaks. Get a memory snapshot feom your server and use chrome dev tools to check which variables are eating too much memory.
(search on how to check memory leaks from the server)
It was very weird, yesterday at night I turned off the server and today I turned it on again and ran correctly (95MB of ram). Yesterday, I restarted the server and immediately memory usage was increasing very fast with only 3 connections which weren’t calling methods.
After some hours… I realized that maybe it was the montiapm-agent (meteor package), since I removed it and the app hasn’t had that issue again (so far). Before of this, I downgraded to Meteor 2.2 and it happened the same (memory usage increased), so that’s why I wanted to try by removing montiapm, since it was the only thing that runs at the starting of the application and maybe was the cause of memory usage. So, on the next days I’m going to upgrade again to Meteor 2.3.
After some days, unfortunately I got the same problem, however, this time was without the agent of Monti APM. So, I was finding out the reason why this happened and now I can suspect that it was Mongo Atlas. I was using the free tier which brings RAM shared and 512MB of storage. It was weird because some days works perfectly but one day can be very slow (guess is due to RAM shared) and this affect to my meteor app by having issues like logging in and response times. I am almost sure that the problem is caused by the database of Mongo Atlas because when I got that problem in the application and I access to the database (through Robo 3t), the connection to it is slow too. Unlike when the montiapm agent was present, this time only increase the memory until certain number (240MB) whereas with agent increased without stopping (exceeded 1.6GB of memory), so, maybe the Mongo Atlas problem also affected to the agent and it ended up affecting the application in a worse way.
Before of this, I used to have mongodb in a docker container in the same machine where it was also hosted the meteor app container, however, because I had to add transactions to my app, I had to acquire a Replica Set instance of MongoDB, and Mongo Atlas seemed to be a good option. So, some days ago I configured a Replica Set instance of MongoDB in docker containers and it has been working well so far. I use a droplet of Digital Ocean with 4GB of RAM, 2vCPUs and 80GB of SSD, and I think that is a good hardware to run a test server and pay 20 dollars per month for it.
Shared a docker compose file example with the configuration of a replica set instance for a meteor app:
This docker-compose file covers the following aspects:
- Cron container to do backups of the database.
- Nginx container to add HTTPS (and consequently WSS) to node apps. (Remember to add force-ssl package to redirect automatically to HTTPS from HTTP)
- Containers for a replica set instance of MongoDB (More info here).
- App service is using a dockerfile from Disney.
If you need more details, do not hesitate to ask.