#more then 1000+ requests per second

41 messages · Page 1 of 1 (latest)

native ridgeBOT
#
  • 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!
placid pewter
#

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?

plucky mica
placid pewter
#

You could listen to the debug event that could possibly give more information. Other then that I’m not too sure

scenic wagonBOT
#

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 bot or other identifiers you need to use these instead of client
  • If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
plucky mica
lost cave
plucky mica
lost cave
#

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

plucky mica
#

The error only appears at 10:00 when all try to make their reservation otherwise the bot runs very smoothly

lost cave
#

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

plucky mica
#

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

lost cave
#

In that case a deferReply should be used first thing in interactionCreate and that should mitigate most issues already

plucky mica
lost cave
plucky mica
#

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

lost cave
plucky mica
lost cave
plucky mica
plucky mica
lost cave
plucky mica
plucky mica
placid pewter
#

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

plucky mica
placid pewter
#

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

lost cave
#
  • 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?
plucky mica
#

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

lost cave
#

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

plucky mica
#

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.

tranquil mountain
plucky mica
#

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

lost cave
#

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?