umbraco / Umbraco.Cms.Integrations

MIT License
31 stars 20 forks source link

Shopify - Slow perfomance #174

Closed thenexus00 closed 1 month ago

thenexus00 commented 3 months ago

Hi All, I need help clarifying on the integration.

If you have this integration and have a product list view we are noticing in some cases very slow performance and thus page load. When you have a the data field and you call this in a for loop in a view/template we are seeing page loads of 8+ seconds in some cases which appears to be as a result of some products and their Shopify connection.

I can see the Cachhelper code but not sure if this is integrated fully or correctly?

acoumb commented 3 months ago

Hi @thenexus00 ,

With the latest version of the Shopify integration (detailed more here) we've introduced a new feature for products pagination based on the recommended approach from Shopify: https://shopify.dev/docs/api/usage/pagination-rest. Caching is no longer used, as the response we receive from Shopify takes into consideration a response header value for page info.

This isn't something I've experienced, but if you could provide me some additional context, like number of products, number of selected items, I could try and replicate your use case.

Maybe this asynchronous call in the converter does not complete in a reasonable time frame.

var t = Task.Run(async () => await _apiService.GetProductsByIds(ids));

var result = t.Result;

Adrian

thenexus00 commented 3 months ago

Hi, @acoumb https://www.enlighten.com.au/accessories I have put some direct caching on the list and the view on these so any page load after is fast but you will see the delay. There are only 30 products. The issue is around the picker to fetch the data.

As you loop through and do:

var thisProduct = product.Value<IEnumerable<ProductViewModel>>("productSelection").FirstOrDefault();

On investigation it is not the amount exactly but with certain products. There is no real difference in the Data processed but "Current Vico Models" for example increases the slow performance. { "id": 8602005209409, "title": "Current Vico Models", "body_html": "Battery pack for all Vico BL12++/BL06++ models, 6.4V 3000mAh LiFePO4", "vendor": "enLighten Australia", "status": "active", "tags": "", "variants": [ { "id": 46505610445121, "price": "71.50", "sku": "BL-Batt-Li", "position": 1, "barcode": "", "inventory_quantity": 72 } ], "image": { "src": "https://cdn.shopify.com/s/files/1/0793/5629/7537/files/BL-Batt-Li-v2.jpg?v=1708574123" } }

Remove this from the list and it does speed up. Testing the API directly using Postman and just some products you request from shopify take longer to respond and sometimes the request just sometimes takes longer due to their queue system.

Based on all this I can see why pagination was required Adrian but I think that kind of just patches and underlining issue that some requests are slow. So the core Data for products maybe needs to be on a schedule fetched and used or something different? On a single product page it is fine, but for loops I think it is an issue for lists so a different method is needed.

acoumb commented 3 months ago

Hi @thenexus00 ,

I will think of available options and get back to you with an answer. In the meantime, if there's something you can spot and amend, PRs are most welcome.

Thanks, Adrian

acoumb commented 2 months ago

Hi @thenexus00 ,

Could you give me an update on this? Do you still experience issues?

Adrian

acoumb commented 1 month ago

Closing this for now, please reopen if issue persists.