#Long startup time

28 messages · Page 1 of 1 (latest)

earnest moth
#

Hi, my bot is currently in ~2000 servers and it takes about 20 seconds for the 'ready' event to fire. I'm worried that as the bot continues to grow it will take several minutes for shards to go online, so I'm wondering what the best way to reduce the startup time is?

steel fiberBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

tight bay
#

Distribute shards into different processes. eg using pm2.

gaunt sigil
#

Iirc, Discord has a max concurrency limit for shard identifies

#

That might be limiting your ability to start a lot of shards at once

stone oriole
#

uhhh

#

max concurrency is almost entirely irrelevant here

balmy oar
#

2000 servers can be managed by 1 shard alone, depending on what your bot does might need 2 or 3. I figure you use internal sharding? Using traditional sharding would reduce startup time pretty sure

stone oriole
#

It probably would not, actually

#

It has no basis to be faster given what sharding actually is

balmy oar
#

Well, since internal sharding has a hardcoded 5s delay to start the next shard it somehow has…

stone oriole
#

everything has that delay

#

because it isn't our random addition

#

discord requires that 5s between identify calls.

Clients are limited by maximum concurrency when Identifying; if they exceed this limit, the gateway will respond with an Opcode 9 Invalid Session.

max_concurrency integer The number of identify requests allowed per 5 seconds

gaunt sigil
#

The base concurrency is one?

stone oriole
#

it's almost always 1

#

the only case where it isn't is if your bot has big bot sharding

#

which is 150_000 servers rn

gaunt sigil
#

Yeahh, I was reading the docs for sharding

#

Imagine starting 100 shards with 5sec delay notLikeCat

stone oriole
#

you don't have to imagine. that's how that works

#

if you have 100000 servers you really should be running code that doesn't require you to restart entire bot to update / fix something

#

so while annoying, yes, should be rare occurence at this scale

gaunt sigil
#

Got it, I'm not that good on programming

#

But if one day I have the opportunity to have a bot that big

#

It would be a nice project to work on

stone oriole
#

reloading commands and client.off exist

gaunt sigil
#

client.off hmmm (alias for removeListener)