# Python to Go, in one restart.

> On 11 September 2026 we moved our link remover bot, which sits in 81,300 Telegram groups, from Python to Go. The switch took a single Heroku dyno restart: 10–15 seconds offline, with no group losing a setting.

## 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.

## Questions

### How long was the bot offline during the migration?

Between 10 and 15 seconds: the length of one Heroku dyno restart.

### Did any group lose its settings?

No. The Go version reads the same database and fields as the Python one, so settings carried over untouched.

### Why did the bot not reply right after the switch?

Telegram had queued over 72,000 old updates, growing by about 300 a second. The fix was to drop the backlog on startup and ignore anything older than a minute.

---
Page: https://kustbots.com/case-studies/python-to-go
Pricing: a fixed price for an agreed outcome, never hourly.
Contact: https://t.me/kustbhai (Telegram, a human answers)
Status: https://status.kustbots.com
Overview for agents: https://kustbots.com/llms.txt
