Troubleshooting Slow API Requests
Slow API requests can cause all available web workers on your site to become busy, resulting in slower page loads, request timeouts, or even temporary downtime. Identifying and optimizing these requests is essential for maintaining good application performance.
Slow API requests are most commonly caused by long-running reports, inefficient database queries, or custom application code. If all web workers become occupied, new requests must wait until a worker becomes available.
Identify Slow Requests
- Open your site’s Insights page.
- Navigate to the Advanced Analytics section.
- Review the Slowest Requests chart.
- Identify the endpoints consuming the most execution time.
The chart is sorted by request duration, making it easy to identify the slowest endpoints that require optimization.
Common Slow Endpoints
| Endpoint | Description |
|---|---|
/api/method/frappe.desk.query_report.run |
Executes reports created using the Report doctype. Slow reports are one of the most common causes of performance issues. |
/api/method/frappe.desk.reportview.get |
Loads list views and reports. Performance can be affected by large datasets, multiple filters, or missing database indexes. |
/api/method/run_doc_method |
Executes a whitelisted method defined in a document controller. Custom application logic may require optimization. |
Ways to Improve Performance
- Optimize slow database queries and add appropriate database indexes where required.
- Review custom application code for inefficient processing.
- Use the built-in Frappe Recorder to profile slow requests and identify bottlenecks.
- Convert long-running synchronous operations into background jobs whenever possible.
If you enable the Frappe Recorder for performance analysis, remember to disable it after troubleshooting, as profiling adds additional overhead to your application.
Optimize Slow Reports
If /api/method/frappe.desk.query_report.run appears frequently at the top of the slow requests list, consider converting those reports into Prepared Reports. Prepared Reports run in the background and generate results asynchronously, reducing the load on web workers.
Check Server Resources
If your site runs on a dedicated server, also review your server analytics to determine whether the application or database server is reaching CPU or memory limits. Resource exhaustion can contribute to slower request processing even when application code is optimized.
Understanding the “Other” Category
The Other category represents all requests that are not individually listed among the slowest endpoints.
- If the Other category is large but most requests share a common endpoint pattern, investigate that endpoint for optimization.
- If no clear pattern exists and Other consistently dominates the chart, the server itself may be under heavy load and should be investigated.
Regularly monitor the Slowest Requests chart and optimize high-traffic endpoints before they begin exhausting available web workers. Addressing performance issues early helps maintain a responsive and stable site.