How to reduce Magento 2 rest api performance time?
-
15-04-2021 - |
Question
I have created some custom rest api's and using Magento's default rest api's.
I want to reduce the loading time of the api, as I have custom api's too so the request time and response time is quite more than usual.
Is there any way or solution to this scenario. that will be a great help.
Thanks in advance.
Solution
kindly follow these steps while developing:
- do not use addAttributeToSelect(*), only select attributes which you need.
- do not use ObjectManager
- Use the Magento\Framework\Data\Collection class to retrieve a collection of filtered objects instead of directly querying the database.
- Avoid creating helper classes
- use caching practice in GET API calls
- to boost your APIs you can use the following module: https://github.com/magespecialist/m2-MSP_APIEnhancer
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange