#more then 1000+ requests per second
41 messages · Page 1 of 1 (latest)
Get a better network connection, make sure you deferReply all commands which use any kind of async functions which can take time, and pray for the best?
That’s what I already doing. But I don’t understand why the bot crashes without any error also pm2 is not restarting it
You could listen to the debug event that could possibly give more information. Other then that I’m not too sure
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as
botor other identifiers you need to use these instead ofclient - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
Thanks I’ll check this out see u tomorrow 😂
When you say it crashes what do you mean? Does the NodeJS process stop? Or does the bot just go offline? Or does it stay online but unresponsive?
Interaction did not respond. But the bot is displayed as online. Also the process is still up
Then it didn’t actually crash. Is the bot used on a lot of guilds or are the 1000+ uses all on the same guild? If the former you might want to look into sharding your bot for performance gain
The bot is only on 2 servers with 3k each members who are using the bot massively
The error only appears at 10:00 when all try to make their reservation otherwise the bot runs very smoothly
Ah nvm, the bottleneck isn’t your bot, it‘s the endpoint your bot code calls, isn’t it? I may have misunderstood the issue here
Can be the case it just makes a post request to my api endpoint to add an entry to my database but still I don’t get why the bot crashes and my api is still fine
In that case a deferReply should be used first thing in interactionCreate and that should mitigate most issues already
Yeah that’s what I’m doing
It doesn’t crash. It just takes more than 3s for the initial reply
Okay but after it let’s say I get the red message interaction did not respond only a restart of the bot resolves the issue
And is everything else handling your command async?
try catch 👀
Of course I already double checked it
So no commands work anymore at all? Even after waiting 10 minutes or an hour or …?
Exactly I get the red error message but the bot is still online and the process is running
For me it would be better if the process crash so pm2 would restart it
Do you have any other event handlers apart from interactionCreate?
I had the message create but I comment out everything in it
And ofc the ready event
You don’t wrap any of the executes in try catch blocks, and any which you do you don’t await the execute, so catch won’t log anything
Ofc my commands which gets executed got all try catch blocks
It’s probably important to add a try catch at handling level too, plus the ones you have you don’t await as I said, so they’re pointless
- Is that getUserState something that might take time while being a sync operation?
- I was asking about other event listener to find out if they were still emitting
- try to put a console.log at the beginning of your interactionCreate to find out if it still emits when you feel like your bot crashed
- what exactly does your slashcommand do besides contacting your game API?
The user state is just a record where I keep track of the data if a user uses my register command so there is just a key : discord id value: an object with some values
Maybe it’s a problem within discord because I read on the api only 50 requests per second are allowed? How does discord js handle this ?
And when 6k people pressing the command at 10:00 this might be the issue ?
Because the problem only happens at 10:00 am
I see a lot there that slows the whole process down.
- Starting from all those API calls in your autocomplete ( keep in mind you receive an AutocompleteInteraction on every single character they add/type in an autocomplete option)
- the command itself doing four different API calls (can‘t you make your API return the results you need from the single endpoint you use for booking a slot?)
- assuming the creation of banner is done with canvas or similar that‘s a blocking I/O call in there, clogging your event loop
- the clearing of messages done with your InteractionUtils might also accumulate to a lot of queued discord API calls because of ratelimit (why do you need that in the first place?)
And why send the result as channel.send instead of interaction.followUp (the latter wouldn’t share the ratelimit of your bot)
And considering you delete and send 1000+ messages in a short period of time, those messages won‘t be able to be seen by anyone
Yeah I agree I need definitely some improvements there. Thank you Qjuh I’ll try to optimize like u suggested and let’s see if it solves it.
on on every single character they add/type in an autocomplete option)
well, that is debounced so you are not getting flooded with requests.
or is the approach with wiping the message okaish? when i will use the follow up what do you think @lost cave ? but ofc i need to filterout the message id otherwise i get unkowen message error
You said you have 1000+ requests per second during your peak. How do you expect to put those into an embed without it being unreadable/spammy?