0

I am going to create a telegram bot to handle 150k users simultaneously (per second).

I am going to use TDLib (because I do want to face Telegram Bot API limits about 30 messages per second).

Previously I always used Telegram Bot Webhook. I registered webhook to point on my server. And my server handles requests from Telegram and sends messages to users. I had no any loading on my server. Max loading is 10 or 30 users per second.

Now I am going to use TDLib. So interactions by architecture.

Interaction 1. Telegram Webhook + TDLib

It doesn't work because in logs of nginx I see that nginx doesn't receive any webhook requests when TDLib is running.

Interaction 2. Several instances of TDLib

It works. Every instance can send message and get updates. But I am worry about network traffic because every instance will get all updates.

Interaction 3. One instance of TDLib (SELECTED CURRENTLY)

One instance of TDLib gets all updates and just sends it to the queue (lets call it as in.queue).

I will write a program to handle the updates from the queue in.queue.

The processing of the update from the queue is create a response command and post it to another queue (out.queue).

The TDLib instance listens out.queue and applies command.


But I want to know how I could test my bot before deploying on prod.

Does it possible to somehow emulate such loading (150k users simultaneously) to test my architecture?

atygaev.mi
  • 144
  • 2
  • 11
  • 1
    150k users simultaneously? wtf? Anyway, TDLib is the best choice, because it creates a direct TCP tunnel between you and Telegram. I think you should write to @BotSupport because this is a very edgy case, maybe you can work out a solution. PS: Have you tried Webhooks with a load balancer? – MarcoBuster Nov 14 '19 at 18:02
  • @MarcoBuster thank you for your response. I decided to use TDLib anyway. About load balancer. It helps to hold the users but it fails with Telegram limits by sending messages to users. Yes I can use direct response but when I want to do "send some message to every user" I will face with the Telegram Bot API limits (30 messages per second). – atygaev.mi Nov 23 '19 at 06:10
  • When you send "global" messages to many users you should slow down and sleep every n, if the timing is not so important. With a very large userbase it can take days but it's the only way. Again, maybe if you explain your situation to [@]BotSupport they could help you by removing some API limits. – MarcoBuster Nov 23 '19 at 18:57

1 Answers1

0

Are you sure using TdLib instead of BOT.Api don't hit the telegram limits? do you reach any improvement?

Graymind
  • 11
  • 2