Skip to content

Instantly share code, notes, and snippets.

@piemot
Created November 5, 2024 20:03
Show Gist options
  • Select an option

  • Save piemot/7d1c5468ac8208a92a205e4cfa1723e4 to your computer and use it in GitHub Desktop.

Select an option

Save piemot/7d1c5468ac8208a92a205e4cfa1723e4 to your computer and use it in GitHub Desktop.

ActivityRank Structure and Overview

Repositories

Overview

The bot is designed for easy scalability. There should be only one instance of the Manager repo deployed, and any number of instances of the Bot repo deployed. At the moment, we only use one instance of the bot repo on a 64GB RAM server. RAM is our current limiting factor for scale, likely because of Discord.JS's aggressive caching.

Guilds and users are also designed to be shardable in the database, but we haven't yet needed to implement that either. The Manager DB keeps a record of guildId | userId -> database shard ID, which is queried whenever a member or guild is updated.

As messages are sent in guilds, the Bot module recieves MESSAGE_CREATE events via its Gateway connection. Each shard of the bot aggregates its XP and statistics in a cache - src/bot/statFlushCache.ts and src/bot/xpFlushCache.ts, and the bot module periodically collects and flushes these statistics (src/models/shardDb/statFlush.ts) to the appropriate sharded database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment