The starting point
The link remover was a single long-running Python process serving every group. It worked, but at 81,300 groups we wanted more headroom and more predictable behaviour under load, which is exactly what Go is good at.
The cutover
We rewrote the bot in Go against the same database and the same fields, so every group’s settings carried over without a migration. Then we switched production in one dyno restart. Downtime was 10–15 seconds.
What went wrong on first boot
When the Go version first started, Telegram was holding more than 72,000 old updates for the bot, and the pile was growing by about 300 a second. The new bot dutifully worked through stale messages and answered nothing new, including our own test command.
We began a rollback to Python, then cancelled it once the cause was clear. Nothing was rolled back.
The fix
- Drop the pending backlog when the bot starts.
- Ignore any message or edit older than one minute.
- Result: the update queue now sits at zero or one, and new messages are handled immediately.
What we took from it
A rewrite is rarely the hard part. The hard part is the moment it meets real traffic that has been waiting for it. We now check the pending-update count after every deploy, and we build every large bot to start clean.