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โ€ข2y 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
billytheapeโ€ข2y ago
DiscordJS version: 13.10.2 NodeJS version: 16.13.0
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeโ€ข2y ago
Strangely I see no effect with removing the caching for guild members ๐Ÿ˜ฆ
Unknown User
Unknown Userโ€ข2y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeโ€ข2y ago
Hmm
billytheape
billytheapeโ€ข2y 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โ€ข2y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeโ€ข2y 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โ€ข2y ago
Message Not Public
Sign In & Join Server To View
billytheape
billytheapeโ€ข2y 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โ€ข2y ago
Bro that's way too much. U could def get way more ram at digital ocean on a vps
crawl
crawlโ€ข2y ago
just dont have 18 shards with 1k guilds you CAN run 2 but dont even have to
billytheape
billytheapeโ€ข2y 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
More Posts
loading Slash Commands with REST dont worksit just stop here and don't load the commands , dont return any errosSending an error to the channel the error was caught onI have a simple error handling script that checks for `uncaughtException`s, and if one pops up sendsHow to prevent people from spamming my slash commandsI've already tried with 1s cooldown but that doesn't work cause discord takes pretty long to pass thguys i tried doing rich presence (running on ubuntu ARM64 (armcord))``` Error: Could not connect at Socket.onerror (/home/notdemonix/autostartstuff/node_modules/disSlash Command PermissionsHow do I do role based permissions with slash commands?ImageURLOptionswhy is StaticImageURLOptions and ImageURLOptions dont exist in main docs ?I'm trying to work on perms for my bot.It is getting stuck in the for loop. I have administrator perms so I should be able to run a commandname_localizations[STRING_TYPE_REGEX] String value did not match validation regex.โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” [ AntiCrash ] : Unhandled Rejection/Catch โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”Filter execution failsHey, does someone know why my <TextChannel>.awaitMessages() collector filter won't get executed if thow to use ButtonBuilder.fromso how do you use ButtonBuilder.from