Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable high availalability #117

Open
dudeofawesome opened this issue Feb 9, 2023 · 3 comments
Open

Enable high availalability #117

dudeofawesome opened this issue Feb 9, 2023 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed p3 Priority 4 (Low)

Comments

@dudeofawesome
Copy link
Collaborator

dudeofawesome commented Feb 9, 2023

This is different from Discord's "sharding" which enables multiple instances of your bot to listen to different guilds.

Rather, we want multiple instances of the bot to be able to listen to the same guilds, while avoiding handling the same event twice.

Prior art:

@dudeofawesome dudeofawesome added enhancement New feature or request help wanted Extra attention is needed labels Feb 9, 2023
@EdgarSaldivar
Copy link
Member

EdgarSaldivar commented Feb 9, 2023

Additional Resources (they are designed to work together it seems):

@dudeofawesome
Copy link
Collaborator Author

Crappy diagram of a possible architecture:

stateDiagram-v2
	direction LR

    state "Discord WS API" as DiscordWSAPI

    state "DiscordJS LB 1" as DiscordJSLB1
    state "DiscordJS LB 2" as DiscordJSLB2

    state "Leaderboard Cmd Handler" as CmdLeaderboardHandler
    state "Check Cmd Handler" as CmdCheckHandler
    state "Settings Cmd Handler" as CmdSettingsHandler

    DiscordWSAPI --> DiscordJSLB1
    DiscordWSAPI --> DiscordJSLB2

    DiscordJSLB1 --> DiscordJSLB2
    DiscordJSLB2 --> DiscordJSLB1

    DiscordJSLB1 --> CmdLeaderboardHandler
    DiscordJSLB2 --> CmdLeaderboardHandler
    DiscordJSLB1 --> CmdCheckHandler
    DiscordJSLB2 --> CmdCheckHandler
    DiscordJSLB1 --> CmdSettingsHandler
    DiscordJSLB2 --> CmdSettingsHandler
Loading

The loadbalancers would communicate with each other on a per-request basis to decide if one has failed and the request should be retried on the other.

@uPaymeiFixit
Copy link

Happy Path Diagram

sequenceDiagram
    participant DI as Discord
    participant IN1 as Instance 1
    participant IN2 as Instance 2
    participant ETCD

    par
        IN1->>DI: Subscribe to Websocket
        IN2->>DI: Subscribe to Websocket
    end

    par
        DI->>IN1: Message 0xDEADBEEF
        DI->>IN2: Message 0xDEADBEEF
    end

    rect rgb(240, 255, 255)
        IN1->>+ETCD: Check status of 0xDEADBEEF
        ETCD->>-IN1: Record not found
        IN1->>ETCD: Create 0xDEADBEEF with <br>status=PROCESSING and {timestamp}
    end

    rect rgb(255, 240, 240)
        IN2->>ETCD: Check status of 0xDEADBEEF
        ETCD->>IN2: 0xDEADBEEF has <br>status=PROCESSING, and {timestamp}
        IN2->>IN2: Wait {TIMEOUT} seconds
    end

    rect rgb(240, 255, 255)
        IN1->>IN1: Process 0xDEADBEEF
        IN1->>DI: Response
        IN1->>ETCD: Update 0xDEADBEEF with <br>status=COMPLETE
    end

    rect rgb(255, 240, 240)
        IN2->>ETCD: Check status of 0xDEADBEEF
        ETCD->>IN2: COMPLETE
    end

    %% rect rgb(255, 240, 240)
    %%     IN2->>ETCD: Check status of 0xDEADBEEF
    %%     ETCD->>IN2: PROCESSING
    %% end
Loading

@dudeofawesome dudeofawesome added the p3 Priority 4 (Low) label Feb 21, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Virginity Bot Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed p3 Priority 4 (Low)
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants