telegram-bot-api icon indicating copy to clipboard operation
telegram-bot-api copied to clipboard

[Feature request] add cluster mode

Open Grommash9 opened this issue 1 year ago • 2 comments

Hello all! I want to make my project horizontally scalable.

I am trying to deploy my bot to kubernetes. I have local bot api instance what is calling a cluster of my bot's.

Webhook url is my cluster url, if I am doing any curl request manually from telegram bot api pod - it's working and I am able to see how balancer sending requests for different pods, but it's not working for telegram updates - all of them are going to same POD, I am not sure I understand how it's selected and why is it working like that. Is it like session or something like that?

People in chat's recommending to create a script what will get all the updates and put them into kafka for bot instances to pick them up, but it feels like reinventing the wheel.

Is there are any setting to allow telegram communications working in cluster mode or maybe a flag for it? And if there is nothing like that can it be added? Or it's a bad idea?

Thanks!

photo_2024-10-13_08-11-23 photo_2024-10-13_08-11-23 (2) photo_2024-10-13_08-11-23 (3)

Grommash9 avatar Oct 14 '24 07:10 Grommash9

We've run into the same issue when trying to scale our bot in Kubernetes. It would be great if the Telegram API could natively distribute updates across pods without needing to rely on custom solutions like Kafka. Could cluster mode support be considered in future updates? @levlam

EtnDiaz avatar Oct 14 '24 15:10 EtnDiaz

+1

LimLex avatar Oct 15 '24 11:10 LimLex

You can distribute the updates sent to webhook in any way you want. You can use a message broker, or a reverse proxy. There is no need to implement all these software in the Bot API server.

levlam avatar Oct 31 '24 14:10 levlam

Do you maybe know about any example or best practices about it?

Grommash9 avatar Oct 31 '24 14:10 Grommash9