Discord.js: Internal Sharding

Created on 25 Apr 2017  路  8Comments  路  Source: discordjs/discord.js

Starting with v12.0.0 add an option for internal sharding. This would be different than the traditional sharding manager, in that your one Discord Client/process would handle sharding with discord rather than spawning multiple processes with their own Discord Client instances each.

Benefits:

  • Memory for small/mid sized bots would be less than the sum of traditional sharding shards due to the following reasons:

    • The base instance of your bot with all dependencies before anything is cached, is not duplicated for each shard.

    • Users which are shared with guilds of different shards aren't duplicated across caches (because it is one collection for users, instead of one for each shard).

  • It is easier and more efficient to manage, in that to perform simple tasks you do not have to broadcast eval to all shards, and do the computations to eliminate duplications from your results. For instance, getting the number of unique users your bot has across all shards.
  • It is easier to implement for the bot dev. Work In Progress implementations/PRs from @GusCaplan has been as easy as setting the client option shardCount to an integer (number of shards) or as the string 'auto' to automatically determine how many internal shards should be created.
  • Still has the benefit of Traditional sharding over not sharding, in which if a websocket disconnects or receives a 1000 code and cannot reconnect or resume, the other shards remain up and unaffected by the outage.

Drawbacks:

  • Not viable for large/very large bots due to the single threaded nature of JavaScript. Such bots should use traditional sharding.

Sizes in this issue are based on the frequency of events handled, not via number of guilds.

roadmap major sharding discussion enhancement

Most helpful comment

It would be turned off by default because it's dumb.

All 8 comments

This seems good, shouldn't be too hard to implement once the WebSocket rewrite is merged into master as it's mainly just a case of creating more WebSocketConnections 馃憤

So will bots be auto-sharding now or will the option to turn on / off internal sharding be a thing?

+1 (sorry if this is spam)

this is being handled by #1501

P.S. @CakeNetwork internal sharding will be __off__ by default

@DiscordDonut That would probably be true. I don't see any reason why it would be turned off by normal.

EDIT: Just now saw devsnek's comment.

It would be turned off by default because it's dumb.

Is this still in progress?

look at the Internal Sharding branch, this branch is currently in testing of some bots from D.js staff and after they are sure that it works correct without bugs they will merge it into master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iCrawl picture iCrawl  路  3Comments

Dmitry221060 picture Dmitry221060  路  3Comments

tiritto picture tiritto  路  3Comments

kvn1351 picture kvn1351  路  3Comments

Alipoodle picture Alipoodle  路  3Comments