tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
3.17k stars 599 forks source link

[Feature request] add cluster mode #651

Open Grommash9 opened 2 weeks ago

Grommash9 commented 2 weeks ago

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)

EtnDiaz commented 2 weeks ago

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

LimLex commented 2 weeks ago

+1

levlam commented 1 day ago

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.

Grommash9 commented 1 day ago

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