# Resolving Throttled and Timed-out Backend Requests

Source: https://support.wix.com/en/article/resolving-throttled-and-timed-out-backend-requests (updated 2024-06-04)
Related: Wix developer documentation, https://dev.wix.com/docs/llms.txt; Help Center index, https://support.wix.com/en/llms.txt

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](https://user-images.githubusercontent.com/89579857/197393860-e52de4cb-50e7-4e4b-a825-9f3dd086ea20.png)

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](https://user-images.githubusercontent.com/89579857/197395454-09e2ad8a-bf1f-4435-bae3-dba215d7e0a4.png)

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.

![](https://lh3.googleusercontent.com/JzNI7bH5p3YPqgSXdlhXrd-y28QwsDwqsnwDIUwjzwoFK4C6c5YaHOrVdGPoiyKPzqMdf2hT3yohl6OAZLBwcc4JdeIugDdVGRX3Cu40lW8hxxEKeaLxi6FBBNosy8wmEg75Sho5kwuZShrhcQ)

You can also [connect your site](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/testing-monitoring/monitoring-your-published-site/connecting-site-events-to-google-operations-formerly-stackdriver) 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](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/premium-plans/compute-platform-features#backend-request-timeout). 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.

**See an example**

To test your code’s running time using console logs, do the following:

  
1. In your backend code, add [console.time()](https://developer.mozilla.org/en-US/docs/Web/API/Console/time) before calling a function and [console.timeEnd()](https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd) after the call.
2. Open the [**Site Events**](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/logs/viewing-live-site-events) log.
3. Use [Functional Testing](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/testing-monitoring/functional-testing/functional-testing-in-the-backend) to trigger your backend code.
4. Check the log to see how long it took your function to run.

  
 For example:

  
 export function rocketModel () {  
 console.time();  
  
 const trajectory = calculateTrajectory(velocity, direction);  
  
 console.timeEnd();  
 }

  
 The results appear in your **Site Events** log:

  
![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/11fda387-da5a-430a-ada3-46def885b67f/2022/05/22/b5e676ed-376a-4600-939b-71ba658204a4/288cc8ef-bc9d-4e77-bea1-181a26f8a8fc.png)

* **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](https://support.wix.com/en/article/cms-adding-and-setting-up-a-pagination-bar) or [process your data in chunks](https://dev.wix.com/docs/develop-websites/articles/best-practices/best-practices-for-improving-performance-in-wix-sites-with-data). Make sure not to create too many requests, as there is also a [quota on requests per minute](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/premium-plans/compute-platform-features#backend-requests-per-minute).
* **Avoid repetition**  
 Avoid repeating large database requests or complex calculations. You can do this by turning [page caching](https://support.wix.com/en/article/site-performance-caching-pages-to-optimize-loading-speed) 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](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/aggregations/working-with-aggregations-in-the-data-api).
* **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](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/premium-plans/data-platform-features#how-to-reduce-request-and-processing-time).
* **Upgrade your plan**  
[Upgrade](https://www.wix.com/upgrade/website) 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](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/premium-plans/compute-platform-features#backend-requests-per-minute). 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.

**See an example**

Instead of calling a series of backend functions from your frontend code, like this:

  
```
import {getSalary, getTax, calculateFinalSalary} from 'backend/myBackend.jsw';

const salary = await getSalary(employeeId);
const tax = await getTax(employeeId);
const finalSalary = await calculateFinalSalary(salary, tax);

```

  
 You can batch the requests together in the backend and make one call to the batch function from the frontend, like this: 

  
**Frontend code** 

  
```
import {computeFinalSalary} from 'backend/myBackend.jsw';

const finalSalary = await computeFinalSalary(employeeId);
```

  
**Backend code** 

  
```
export function computeFinalSalary(employeeId) {
  const salary = getSalary(employeeId);
  const tax = getTax(employeeId);
  return calculateFinalSalary(salary, tax);
}
```

* **Upgrade your plan**  
[Upgrade](https://www.wix.com/upgrade/website) your plan to increase your request limit.
