Top.Mail.Ru
English
Use case · 10 min

How to choose a VPS for a Telegram bot

A small bot needs modest resources. Reliability comes from deployment, queue handling, monitoring and tested backups rather than an oversized server.

In this guideResourcesNetworkDeploymentDataRecovery

Size by workload

Bot typeStarting pointScale when
Simple bot without a database1 vCPU, 1 GB RAM, 10–20 GB SSDHandlers queue or memory becomes tight
Bot with PostgreSQL or Redis2 vCPU, 2–4 GB RAM, NVMeDatabase or queue metrics require it
Media or background jobs2–4 vCPU, 4+ GB RAMMeasured CPU, memory or storage pressure

Leave memory for the OS and updates. Database latency and memory often matter more than a large disk. Move long-lived media to object storage or delete it by policy. Use the CPU and RAM guide for a measured upgrade decision.

Long polling, webhooks and location

Long polling is simple and does not require inbound HTTPS. A webhook suits scalable deployments but needs a domain or stable HTTPS endpoint and a valid certificate. In both cases, stable routing to Telegram and third-party APIs matters more than a headline gigabit port.

Test a provider from the real application before moving production. A bot that processes media may also need a generous transfer allowance; review the bandwidth guide for large or unpredictable volumes.

Deploy for repeatable recovery

  1. Create a non-root service account and use SSH keys.
  2. Store tokens and passwords in secrets or environment variables, never in the repository.
  3. Run the process under systemd or a container restart policy.
  4. Close unused ports and install security updates.
  5. Rotate logs before they fill the disk.
  6. Make releases reproducible and document rollback.

Set timeouts for external APIs and use bounded retries with backoff. Do not perform a long task in the message handler: enqueue it, acknowledge the user and limit duplicate execution.

Database, queue and files

ComponentRiskMonitor
Bot processStops after error or rebootHealth check, restart count, errors
DatabaseLoss or slow queriesBackups, size, connections, query time
QueueJobs accumulateQueue length and oldest-job age
MediaDisk fillsQuota, retention and cleanup
External APILimits or outageTimeouts, failure rate and bounded retries

SQLite may suit one small process with limited writes. PostgreSQL is easier to operate when handlers run concurrently or reporting grows. Redis is useful for cache and queues, but important data needs persistence and backups.

Monitor and test recovery

Use external monitoring: a dead server cannot alert from inside itself. Watch CPU, memory, swap, disk, error rate, handler duration and queue delay. Back up the database separately and restore it periodically. A provider snapshot does not replace a portable copy; see the VPS backup guide.

Test failure modes before launch

Use a separate test bot or environment and simulate a database timeout, an unavailable third-party API and a server reboot. Confirm that jobs are retried only as intended, duplicate messages are not produced and the process returns automatically. Then fill a temporary disk or trigger an alert threshold safely to verify that monitoring reaches an operator.

This exercise reveals reliability problems that extra CPU cannot solve. Keep the recovery instructions short enough for another maintainer to follow, including token rotation, database restore, deployment and DNS or webhook changes.

Good starting point: 1–2 vCPU, 2 GB RAM, 20–30 GB NVMe, KVM, monthly billing and independent backups. Scale the measured bottleneck only.

Frequently asked questions

Is 1 GB RAM enough?

Often for a simple bot. PostgreSQL, Redis and several containers make 2–4 GB a safer starting point.

Do I need a domain?

Not for long polling. A webhook needs a reachable HTTPS endpoint, and a domain simplifies certificates and migration.

Can the database run on the same VPS?

Yes for a small project with external backups. Separate it later if load or availability requirements justify the complexity.

Find a reliable starting serverSet minimum resources, NVMe and location, then compare current plans.
Compare VPS plans