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

Run multiple replicas in k8s of bot app #2112

Open
MrPatryk opened this issue May 7, 2024 · 1 comment
Open

Run multiple replicas in k8s of bot app #2112

MrPatryk opened this issue May 7, 2024 · 1 comment
Assignees
Labels
question M-T: User needs support to use the project

Comments

@MrPatryk
Copy link

MrPatryk commented May 7, 2024

How run multiple replicas of bot app in k8s and still handle it only in 1 insance till it dies. We run our bot using k8s but sometimes it scales down/up moving node to other vmk - like 4-5min break in bot work while its starting again. For 1 replica all works fine, but when we have more than 1 there is race condition. There is any way to setup it to support 2+ isntances of bot and don't make mess with handling events/commands as 1st started instance, not both (with 50% of working for 1st bot/50% for 2nd).

@slack/bolt version

^3.15.0

Your App and Receiver Configuration

const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN,
port: 3000
});

Node.js runtime version

v16.13.0

Steps to reproduce:

(Share the commands to run, source code, and project settings)

  1. run 1st instance with diff say() msg for using command
  2. run 2st instance with another diff msg for cmd
  3. run command and watch output

Expected result:

Only one bot handles all events

Actual result:

50% that 1st bot catch command and says 1st msg, 50% that 2nd bot reply with diff message

Requirements

@hello-ashleyintech hello-ashleyintech self-assigned this May 7, 2024
@hello-ashleyintech hello-ashleyintech added question M-T: User needs support to use the project and removed untriaged labels May 7, 2024
@hello-ashleyintech
Copy link
Contributor

Hi, @MrPatryk! Thank you for your question! 🙌

Based on what you've described, it does sound like the expected behavior of Bolt with socket mode.

By design, when there are multiple connections, Socket Mode will randomize sending the event between the socket connections.

As mentioned here, this might be a good potential workaround:

If you need to scale to multiple app instances, then you may need to use 1 app that establishes a SocketMode connection and adds each request to a job queue for other instances to handle. We don't have a working example of this but if you want to share your solution then we'd greatly appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants