Scheduled tasks running slowly

Hi Pythonanywhere team. I run several scheduled tasks and have noticed that performance of all these tasks have gone down considerably by 8x since April 15th. Please check why is it being caused. Also if the scripts are run on console then it works fine. So it is not the issue /changes in the script. It was working fine until April13th and the degradation of tasks is in sync with all the scheduled jobs since 15th April. Please look into it urgently. Thanks

We're not aware of any system-wide issues that might cause a problem like that. What are your tasks doing?

Hi Giles

Few scripts are running just basic calculations and opening around 3 excel files and was taking ~20 seconds before which shot up to 600 seconds in last 2 weeks . Also just to confirm for all the scripts I went checking again for the remaining scripts. Some gateway error was thrown out in the interim and the site refreshed. Now when I check the timing its taking similar time as it was taking before 15th April. So was something amended by you guys at the backend? Though I still have logs in scheduled tasks which shows significant degrading daily since 15th April. I will keep checking for few days if the issue reappears. Let me know if something was done by you guys in backend right now. Thanks

Are you sure you were not in the tarpit in the times when it was taking longer?

Yes I am sure about it. Never been in tarpit any day as usage is minimal and close to 20% daily cpu hours usage on average. And the issue was consistent since last 2 weeks and the slow runtime was occurring in multiple tasks exactly since the same day. Will confirm tomorrow if the the issue reoccurs if it's due to the time these tasks are run.

Ok. Let us know what you discover.

so the issue still persists. And just to make debugging the issue easier I timed and printed the actual time it took to run few of these tasks. I have some conclusive observations about the problem now. So the actual scripts took like few seconds to run. Pasting few examples as seen on task log.

31.31118941307068(this being the actual time it take to ran the script)

2021-05-05 12:34:52 -- Completed task, took 234.93 seconds, return code was 0.

10.151666402816772(this being the actual time it take to ran the script)

2021-05-05 13:13:52 -- Completed task, took 688.62 seconds, return code was 0.

So there are multiple issues I observed

1)The schedule jobs start is quite delayed in a lot of cases going up to 2 ~3 minutes late 2)After the script has run successfully and there are no ongoing tasks ,the task log still takes a lot of time to update. And this printing of last line of task log takes lot of time sometimes going upto 10 minutes .And this is what I feel the issue is

Now I am unsure if it is some account specific issue or system wide issue at your end. But I am definitely sure that the above two issues around schedule jobs exist.

I thought about deleting the existing scheduled task and creating new ones from scratch. Let me know if I should try that. Please let me know about the resolution urgently. Thanks

I'm not surre I understand what you mean by "the actual time it take to ran the script". How did you measure that?

Answers to your questions:

  1. The start of you scheduled task is not guaranteed - it will vary depending on the load on the task server at the time. If your tasks are run at "round" times (like on the hour or half hour or something like that), then they will be competing with all the other tasks that are also starting then. "Round" times are more busy on task servers.
  2. Again, depending on the load on the machine, the task log can take some time to update, but if your task has run and done it's job already, I'm not sure I understand why that's an issue for you. Are you using the task log to do something that is time sensitive?
  3. Deleting and re-creating the task is unlikely to have any effect on anything.

I timed the runtime of function and printed it out .The issue is just that if schedule task log says that it took 600 seconds to complete the task even though the runtime was actually lower then it doesn't depict the right information about the code. Understand that it's more to do with load on the system. But it's fine for now. Thanks for suggestions about "Round" times and timely response.

Cool. Glad to help.