openfoodnetwork icon indicating copy to clipboard operation
openfoodnetwork copied to clipboard

Reduce response time shop pages

Open mkllnk opened this issue 1 year ago • 6 comments

What we should change and why (this is tech debt)

According to New Relic, shopfront load times are usually okay (730 ms). The "slowest trace" is 31 s though and the longest "transaction duration" is 2 minutes. I don't know why these numbers are not the same. Another view states 3 min as maximum transaction time. Screenshot from 2024-01-03 15-34-11

Context

  • https://github.com/openfoodfoundation/ofn-install/issues/859#issuecomment-1874840248

Impact and timeline

mkllnk avatar Jan 03 '24 05:01 mkllnk

I suspected that we were maybe re-rendering product images for the shopfront but looking deeper into New Relic it looks like an n+1 problem. Certain database queries are run hundreds of times. It's not easy to see for me though what the real impact is. It may be better to experiment locally.

mkllnk avatar Jan 03 '24 05:01 mkllnk

let me work on this. Just to confirm, shopfront page means this api app/controllers/api/v0/shops_controller.rb, right?

bmd08a1 avatar Jan 08 '24 01:01 bmd08a1

We have the shop list (index) and the individual shop (show) pages. Both need optimising, actually. I don't know where the slow spot it, though. You may need to generate some test data locally to have 1000 shops or 1000 products so see the impact.

mkllnk avatar Jan 08 '24 02:01 mkllnk

Oh I saw the other issue on shops index too, I'll work with this shopfront page first. Can you share me some logs/traces on New Relic for this page, that could help a lot in debugging the issue

bmd08a1 avatar Jan 08 '24 10:01 bmd08a1

Can you share me some logs/traces on New Relic for this page, that could help a lot in debugging the issue

Unfortunately, I didn't find anything useful in New Relic. Also revisiting the shop didn't take that long. So it may be a caching issue. I don't know. I think that you need to find a way to re-produce it.

mkllnk avatar Jan 10 '24 01:01 mkllnk

If the response time on the shop pages is normally ~700ms, those anomalous 2-minute response times are likely taking place during a period where the server is under heavy load due to something other than that page (most likely reports).

Matt-Yorkley avatar Mar 22 '24 02:03 Matt-Yorkley