You may want to optimize your code to avoid reaching the limits for data storage, data requests, or backend requests. You can also upgrade your plan to receive more resources. Read about premium plans to understand the limitations that exist and which plans increase which limits.
You can take the following steps to reduce the amount of storage your site uses:
You can optimize your data requests by reducing the number of requests you make or by decreasing the requests' processing time.
You can take the following steps to reduce the number of data requests in your code:
bulkInsert()
and bulkUpdate()
functions instead of writing each item individually. These functions count as 1 request toward the quota.You can take the following steps to reduce the processing time of the data requests in your code:
_id
and _createdDate
fields are indexed by default.You can optimize your backend requests by reducing the number of requests you make or by decreasing the requests' processing time.
You can take the following steps to reduce the number of backend requests in your code:
Batch your requests: Batch multiple backend requests into one. Make sure not to batch time-consuming requests together as there's also a time limit for backend requests.
Instead of calling a series of backend functions from your frontend code, like this:
You can batch the requests together in the backend and make one call to the batch function from the frontend, like this:
Frontend code
Backend code
Avoid repetition: Avoid repeating large database requests or complex calculations. If you can, cache the result or aggregate database queries.
You can take the following steps to reduce the processing time of the backend requests in your code:
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.
To test your code’s running time using console logs, do the following:
In your backend code, add console.time()
before calling a function and console.timeEnd() after the call.
For example:
Open the Site Events log.
Use Functional Testing to trigger your backend code.
Check the log to see how long it took your function to run.
The results are displayed in your Site Events log:
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 try upgrading 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, use pagination or process your data in chunks. Don't create too many requests, as there is also a quota on requests per minute.
Use indexes: Querying with an index is faster than querying items directly. All _id and _createdDate fields are indexed by default.