Bot memory consumption
Hey guys -- was hoping to get a little assistance with my bot. I'm trying to determine if there's something I can do about the memory consumption & growth.
My first question: am I having a normal amount of RAM usage? My bot is in just under 1k servers with more adding every day, and I'm frequently running up against the 2GB RAM limit in my heroku dyno instance. Seems to start at around 1.6GB and slowly grow until 2, then it's forced to restart and the cycle continues. This app also runs rabbitmq and mongodb but those don't seem to have TOO huge an impact (running these both in other apps without issue)... If this seems extreme perhaps there is some other issue (though I've dug pretty far to find any other memory leak issues...)
Second question: are there other techniques I'm missing that can reduce the memory consumption?
Stuff I've tried: I have sharding enabled with a relatively large number of shards (18), and I also have a sweeper setup to prevent caching except for channels, permissions, roles, guilds, and guild members, (which all seem to complain if I try to prevent their caching....) - image below with details
Thanks in advance š
14 Replies
ā¢ What's your exact discord.js
npm list discord.js
and node node -v
version?
ā¢ Post the full error stack trace, not just the top part!
ā¢ Show your code!
ā¢ Explain what exactly your issue is.
ā¢ Not a discord.js issue? Check out #useful-servers.DiscordJS version:
13.10.2
NodeJS version: 16.13.0
Unknown Userā¢3y ago
Message Not Public
Sign In & Join Server To View
Strangely I see no effect with removing the caching for guild members š¦
Unknown Userā¢3y ago
Message Not Public
Sign In & Join Server To View
Hmm
I think it's related to this possibly? https://github.com/discordjs/discord.js/pull/7182 Maybe this type of memory management doesn't work in v13?
GitHub
fix(sweepers): provide default for object param by ckohen Ā· Pull Re...
Please describe the changes this PR makes and why it should be merged:
I dumb dumbed it
Status and versioning classification:
Code changes have been tested against the Discord API, or there are no...
Unknown Userā¢3y ago
Message Not Public
Sign In & Join Server To View
Upgrading to v14 does seem to have improved the situation by a little at least
Does having more shards help or hurt memory usage?
Unknown Userā¢3y ago
Message Not Public
Sign In & Join Server To View
Thanks for all your help btw. Sadly I'm going to have to find some new hosting provider, seems like this bot has just grown beyond heroku, and paying $250/mo for their 2.5 gb plan seems crazy
Bro that's way too much. U could def get way more ram at digital ocean on a vps
just dont have 18 shards
with 1k guilds you CAN run 2
but dont even have to
It has a ton of interactions on every server - I run into a lot of really slow and incomplete responses even below 10 shards. I did reduce the number and that has helped tho
Part of the problem is a lot of the servers are using it in a way that introduces a lot of burst activity, and the single node process just can't handle it. Spreading them out helps a ton
I suppose I just need to find the right balance, and drop heroku for the bot because if we continue growing at this rate it won't be useful soon.