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
d.js docs
d.js docsā€¢3y ago
ā€¢ 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.
billytheape
billytheapeOPā€¢3y ago
DiscordJS version: 13.10.2 NodeJS version: 16.13.0
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeOPā€¢3y ago
Strangely I see no effect with removing the caching for guild members šŸ˜¦
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeOPā€¢3y ago
Hmm
billytheape
billytheapeOPā€¢3y ago
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
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeOPā€¢3y ago
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
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeOPā€¢3y ago
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
Creeper
Creeperā€¢3y ago
Bro that's way too much. U could def get way more ram at digital ocean on a vps
crawl
crawlā€¢3y ago
just dont have 18 shards with 1k guilds you CAN run 2 but dont even have to
billytheape
billytheapeOPā€¢3y ago
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.
Want results from more Discord servers?
Add your server