Instance stops for all users while waiting for result from a time consuming MYSQL query(approx 30 sec.)

While waiting for an ajax request which executes a database query (long 30 sec query), all the users working on the instance have to wait till the request is completed. Just like a single threaded application but for every users also?
Any suggestions to overcome this?

1 Like

Hi @suresh_murugesh,

If you want to avoid using the main thread, check frappe.enqueue
You can enqueue your request in a background job.

1 Like

Hello,
Please help, I would also like to overcome this problem.
what is frappe.enqueue?

Where do I find it?

and how can I enqueue request in a background job?
Thanks

Hi @deatram,

Here is the document link : Running Background Jobs

I would suggest digging into Frappe’s code to understand it deeper before using it in production.

Good luck!

1 Like

I have the same problem. My query is being executed in a script report. The problem is not about the report running but about queries being created at each refresh.

When the report is executed, the mysql query occupies one CPU core. The report is complex and the user loses patience and presses refresh which spawns more queries which hog the CPU leading to the system getting locked down till the admin kills those queries individually.

1 Like

Thanks for the guidance we will be looking into it, but is there only 1 worker thread or each request spawns individual threads bcs when i start the process no one else can use the application till i finish my process.

How many Gunicorn workers have do you have?