Resolving Throttled and Timed-out Backend Requests

4 min read
If the Monitoring dashboard indicates that backend requests to your site are being throttled or timing out, you can take the following steps to try and resolve the issue.

Identify the Error

Open the Backend Requests tab in the Breakdown section of the Monitoring dashboard.
Breakdown tabs with Backend Requests highlighted
The Failed requests panel displays the number of failed backend requests made to your site over time. You can use it to identify when requests to your site failed and whether the requests were throttled or timed out.
Failed requests panel
The Top backend functions panel also appears in the dashboard’s Breakdown section. It lists your site’s most frequently called backend functions. For each function, the total number of throttled and timed-out requests are displayed.
You can also connect your site to Google Operations to see logs of timed-out and throttled requests and identify which function caused them. This tool allows you to see logs in real time and stores a history of your site’s logs that you can view at any time.
If backend code on your site has a high number of throttled or timed-out requests, one of the suggestions below may help.

Troubleshoot

Once you have identified the type of error happening on your site and the code that’s causing it, you can try to resolve the error.

Timed-out Requests

If requests to your backend functions are timing out, it means your requests are exceeding the time quota. You can try to reduce the running time of your code using the following methods:
  • Identify parts of your code that are running for too long
    Identify the parts of your code that are taking too long to run, and optimize them to improve performance. You can do this by including console logs before and after the code you want to test, and then checking to see how long it takes to run.
  • Check your 3rd-party APIs
    If you are using 3rd-party APIs on your site, make sure they are not too slow. For example, if you notice an API call to a 3rd-party is taking a few seconds to run, break it into smaller calls or see if you can upgrade your 3rd-party account to improve performance.
  • Process data in chunks
    If you are running a slow process or loading a large amount of data, either use pagination or process your data in chunks. Make sure not to create too many requests, as there is also a quota on requests per minute.
  • Avoid repetition
    Avoid repeating large database requests or complex calculations. You can do this by turning page caching on for pages with content that doesn't need to be refreshed constantly. This way, the page's requests only happen at intervals and not every time the page loads. You can also avoid repeating requests by aggregating database queries.
  • Optimize query times
    If you’re querying a large data collection, you might want to consider adding an index to optimize query times. Learn more about reducing request and processing times.
  • Upgrade your plan 
    Upgrade your plan to increase your request limit.

Throttled Requests

If requests to your backend functions are being throttled, it means your site is exceeding the requests per minute quota. Your site is making too many requests to your backend code. You can try to reduce the number of requests and prevent the error using the following methods:
  • Batch your requests
    Batch multiple round trips (backend requests) into one. Make sure not to batch time-consuming requests together as there's also a time limit for backend requests.
  • Upgrade your plan 
    Upgrade your plan to increase your request limit.

Did this help?

|