Sharding Questions

Hello, As my bot is nearly reaching the 2k servers. I need to prepare it to sharding but I have some questions to that : As I use a system like that :
const global_variables = {
/*For the users actually using the bot*/ plays: {} , /*For all users database*/users: {}, /*A cache containing songs that were played before */searchCache: []
}

module.exports = {
global_variables,
}
const global_variables = {
/*For the users actually using the bot*/ plays: {} , /*For all users database*/users: {}, /*A cache containing songs that were played before */searchCache: []
}

module.exports = {
global_variables,
}
Then I get all the values I need from that const. But as sharding is splitting my code in multiple processes, to gain performance I want these to be centralized in one file and accessible for all the shards at the same time without them to have each one a copy of that data. I made this system to generate less database calls but if each process need to call the database and save his part I will need to change that. Thanks !
3 Replies
d.js toolkit
d.js toolkit9mo ago
- 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!
Kinect3000
Kinect30009mo ago
I would’ve made a class that manages that One that can cache stuff and make db calls only when necessary You could also consider using Redis
✨𝓜𝓪𝓲𝓽𝓻𝓮𝓖𝓔𝓔𝓚ツ✨
Interesting, I'll try that, thanks Well I think he's not really a resource gourmand but as it's a Music Bot I don't know how it will handle in more than 1000 calls at the same time Yeah I know redis but I don't want to increase the amount of operation Local files and distant files Including Radio files

Did you find this page helpful?