Discord.JS ShardingManager and Fastify

One of my Discord applications is growing at a good rate and it's getting to a point where I'm going to need to start messing around with sharding. My issue is that part of the application is the use of a Fastify server that listens for a few custom requests - one in particular being for the interactions endpoint URL (I use a sort of proxy server to still give a response when the application is offline for maintenance etc). I'm confused about the logic of how the application needs to work going forward while taking the Fastify server in to account. I'm fairly certain that as soon as a second shard comes online, it's going to fail to start Fastify because the port will already be in use on the first shard. This being that I have the Fastify instance as a 'property' of the client. Am I right in thinking that I should perhaps instead move that part of my application on to the ShardingManager and have one parent instance of Fastify to handle all of the shards? Should I expect a huge performance hit by having to lookup what guild an interaction was run on, to then forward the interaction from the parent Fastify instance down to the correct shard? It's a lot of work for someone like me so hoping for some advice first before I spend hours/days rewriting large sections of the application.
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
sludge
sludgeOP2y ago
discord.js 14.7.1 node 19.3.0
d.js docs
d.js docs2y ago
method (static) ShardClientUtil.shardIdForGuildId() Get the shard id for a given guild id.
sludge
sludgeOP2y ago
thanks for the insight, I'm glad I was on the right path with my thinking. just needed someone else to give input before I took the plunge haha
Want results from more Discord servers?
Add your server