Forums

Always-On Tasks for Bot and Suitable Purchase Tier

Hello, I'm looking to run 2 always-on tasks, a script for a telegram bot with polling and a flask server that handles that bot's communication with a chatbot that provides the replies. If I want to have my bot online the whole day, that would take around 86000 seconds of CPU uptime for these two tasks, which seems a bit excessive.

I cannot (due to disk quota) install playwright's browser kits in order to test my bot online and see how much its replies will be slowed down when my apps reach the tarpit, so I wanted to ask, how much does that affect speed etc and what would you think would be a reasonable buying tier for me to go for, for this specific usage.

Thanks a lot in advance!

First thing, for clarity: the CPU-seconds isn't related for how much time your code runs for. It's the amount of time that your code is using 100% of a CPU. So, for a typical Telegram bot, it will only use CPU while it's actually handling a user's message, and even then it's unlikely to use CPU at a rate of one second per "real" second. To take an example, let's imagine a bot that did some web scraping.

  • Initially, it's doing nothing, just waiting for messages. It is not using CPU time.
  • A message comes in. It uses a tiny amount of CPU time (probably milliseconds) to decode the message.
  • It then starts up Selenium, which starts Chromium. This uses some CPU (maybe half a second or so) -- it would probably be a good idea to keep a "pool" of a few running instances.
  • It then does the web-scraping. That uses a very small amount of CPU to send the instructions from your code to the browser, then the browser uses a bit more to make the request to the site that it's scraping. It then uses no CPU while waiting for the response. The response comes back, and then it uses CPU to render the page, and more CPU is used up while parsing the page (in your code) to extract the required information.
  • Finally, your code assembles and sends the message back to the user, which will again use some CPU.

The general principle is, while your code is waiting and doing nothing, you don't use up any CPU. It's only when your code (or programs that your code runs, like Selenium/Chromium) is actually actively using CPU time that it counts.

A second thing: for the Flask server: you wouldn't be able to run that as an always-on task, that would be something you'd set up on the "Web" page inside PythonAnywhere.

So, with regard to your question -- without knowing all of the details of your code, it's hard to say what you'd need, but I'd suggest signing up for a Hacker plan (perhaps customized to add on some extra disk space) and seeing how much CPU it actually uses in practice. You can always upgrade to a larger plan, without downtime, by selecting a new plan on the "Account" page.