We have a Telegram bot. It has around 1.2 million subscribers.
Now we're facing a problem in sending messages to these number of subscribers.
Telegram bot API does not provide any batch message functionality and we'd have to send individual requests to Telegram. The problem is, after a few thousand messages, Telegram starts responding with Error 429: too many requests, and does not accept any requests for a while.
How can we effectively message our subscribers?
The HTTP 429 Too Many Requests response status code indicates the user has sent too many requests in a given amount of time ("rate limiting").
Telegram API Performance Limitations Currently, Telegram is limited to sending a maximum of 100 requests per second to your backend. The sooner you are able to process this request and reply, the sooner users will see the changes in the bot client.
Wait to send another request. The simplest way to fix an HTTP 429 error is to wait to send another request. Often, this status code is sent with a “Retry-after” header that specifies a period of time to wait before sending another request. It may specify only a few seconds or minutes.
You should simply implement a global rate limiter to ensure no single user gets above a fixed number of messages per second. to be safe, set your limiter at lower than 30, maybe even to 5 msgs per second.
Really anything higher than 5 messages per second to a single user quickly becomes an annoyance.
cheers.
I'm the owner of Ramona Bot. There is a limit for sending message to users. as they said ~30 message per second. Otherwise you will get that Error 429.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With