Forums

CPU Usage - Tasks

Do tasks use CPU seconds?

Yes, they do -- everything apart from websites uses up your CPU quota.

Websites don't use up your CPU quota? My website is taking up my CPU seconds.

Wait. Then won't always-on tasks take CPU seconds?

Always-on tasks also take up CPU seconds. It's just websites that don't. If you're seeing CPU seconds being used up, it might be that you have a scheduled task or a console running in the background -- you can find out what processes are running by using the "running processes" section at the bottom of the "Consoles" page (for consoles and Jupyter notebooks) or the "Tasks" page (for both always-on and scheduled tasks).

If a scheduled task has to wait for a response from an external website for example, would that take up CPU usage? I'm making several serial requests to extranal resources, if I would implement multi-threading or asynco would that reduce my CPU usage time?

No, CPU usage is just for time spent when the CPU is busy running your code. So if you make an external request, there will be a small amount of CPU usage while it prepares and sends the request, then nothing at all while it waits for a reply, then a small amount while it unpacks the response.

I have a scheduled task every hour, which in three hours has taken the total of 65s run time. Yet my CPU usage figure tells me I have used 326s. Running processes tab informs nothing running, so why the difference between the two figures?

Because they're measuring 2 different things. The time taken for a task does not map directly to the CPU time. CPU time is the amount of time a task uses a CPU for. It can be more or less than the time a task takes depending on what the code is. Also, the process list on the Tasks page does not show all processes. Only the processes created by Scheduled and Always on tasks. There is another process list on your Consoles page that shows console and notebook processes.

Thanks. Will look into consoles page.

Hello...I have one webapp, a telegram bot that scrapp a especcific site when I request it. But my CPU seconds are being consumed all the time. Is it normal because my bot is always available? Or I have to do something to stop the incorret CPU usage? Thanks.

If the bot is sraping, check if you manage browser closing correctly -- if you keep open browsers it may consume your CPU in the background.