Cache/sweeper settings for memory constraints, mostly messages
We are in a very memory constrained environment. Our individual bot processes can't exceed 512 MB. Right now each process is managing 3 shards of our Discord connection.
1. The bot only listens for new messages and new threads to join.
2. It only determines if it needs to reply to a message, and we also log some info about the guild to an external service
3. We don't care about reactions, members, message edits, any other part of the message lifecycle, and we don't need to retain any messages longer than it takes to process them.
I'm trying to configure the
makeCache
and sweepers
settings to help optimize memory usage in this scenario. What I have is below, any other suggestions would be welcome
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!

If I don't cache members at all, does that increase latency when I get a new message again from the same member right afterward? It's unclear to me what the caches are for exactly.
My bot is very simple, it is just reading all messages to check for things to reply to, I don't need to retain the message or info about it beyond that, unless it makes the bot perform better somehow with some caching
Would you set most caches to
0
in that case to disable them?