Botxona

Bot sleep and wake-up (scale-to-zero)

Many Telegram bots are used only occasionally during the day. That is why Botxona puts idle bots to sleep when needed — the container stops completely and frees server resources — and wakes them up within a few seconds when a new message arrives.

How it works

A bot that receives no updates keeps running as long as the server has enough memory (the "warm" state) and answers messages instantly — in a fraction of a second. Idle bots are put to sleep (status "sleeping") only when the server needs resources (RAM): the one idle the longest goes first, and never before 10 minutes of inactivity. When a user writes to a sleeping bot or presses a button, the system accepts the update and restarts the container — this takes a few seconds (about 3–6 seconds for Python/aiogram bots), after which the message is delivered to the bot; no updates are lost.

Operating modes

On your bot's page, under Settings → Operating mode, you can choose one of three options:

  • Auto (default) — if no scheduled tasks (scheduler) are found in the code, the bot may be put to sleep when the server runs low on memory (after at least 10 minutes of inactivity); if a scheduler is found, the bot is automatically set to always on.
  • Always on — the bot never sleeps. Needed for background tasks such as sending reminders or daily reports.
  • Sleep — the bot sleeps when idle even if it has a scheduler. Note: in this mode scheduled tasks (e.g. "send a message every day at 09:00") may be missed, because the bot may not be running at that moment.

How is a scheduler detected?

During the check, the system automatically searches the code for time-based libraries such as APScheduler, node-cron, setInterval, in Go time.NewTicker, time.Tick(, robfig/cron, go-co-op/gocron, and JobQueue. If one is found, the bot is flagged as "needs always_on" and stays always on in "Auto" mode — you can also control this manually with the always_on field in botxona.yaml.

Always on with the Business plan

Bots on the Business plan are always on regardless of the setting — one of the plan's main advantages (important, for example, for bots that accept payments or orders, where every millisecond and uninterrupted operation matter).

Why does this matter?

"Always on" bots permanently occupy server resources. Most bots, however, are used only now and then — so putting idle bots to sleep when server memory runs low makes it possible to host thousands of bots on an affordable server. While there is enough memory, bots stay awake; a bot that has gone to sleep may take a few seconds to answer the first message.

Next step

Other dashboard features: A tour of the dashboard.