Forums

'CPU Usage' kpi not updating on dashboard.

Hi!

I have a question; my CPU Usage KPI is not updating on my dashboard. Sometimes my web app is very fast (I use Flask), but other times or a day later, each request can take over 1 second to complete. I am trying to figure out why this is happening, and I thought it might be related to the CPU usage (I have 2,000 secs), but I can't see the KPI updating.

Any suggestions?

Thanks in advance!

Hey - It might be that you're app is failling into the tarpit. More information here - https://www.pythonanywhere.com/tarpit/

It'd be good to know what your cpu usage is when you get one of these slow requests

Hi,

Thanks for the response! I figured out that it isn't the CPU usage, but rather the query that are sometimes very fast and sometimes slow.

Any idea how i can fix this? The queries are optimized (with indexes), but can still sometimes take over 1 sec to complete with no a such big database.

I use from flaskext.mysql import MySQL as mysql connector in python.

Thanks in advance!

Are those queries always the same or do they differ per request? Do you see any pattern when they are slower then usual?

Hello,

I note no difference despite logging every request and query. However, I have observed that a majority of the requests are held up, waiting for the query to be completed. The speed of these queries varies. While some are swift, about two-thirds of the time, they take more than a second to complete. This is unexpected, especially considering some tables contain only four rows of data.

e.g.: a simple requests when a page is loaded: Fsc = time to find the python script Qry = time to finish the query Req = the full request.

Fsc: 06:42:22s | Exc time: 0.0009s | user=dev | data_generate_screen Qry: 06:42:22s | Exc time: 1.2189s | user=dev | select date_format(f1.date,"%Y-%m-%d"), f1.start_time, f1.end_time, f1.total_time, f1.bedrijf, f1.code from t_timeregistration as f1 left join t_employees as f2 on f2.code = f1.code where f1.bedrijf = "100" and (f1.date between "2023-06-12" and "2023-06-18") and f2.code = "" order by f1.date; Req: 06:42:22s | Req time: 1.3271s | user=dev | args=s:data_generate_screen | source=/application/t_input_hours

This is just an example, but such a process should not take more than one second, right? Can I do something to expedite the query? I use mysqlclient for my MySQL connection.

Thanks in advance!

Looks like you are sometimes running out of workers in your web app with -dev in domain name, so requests are waiting until the web worker is available to handle them.