openfoodnetwork
openfoodnetwork copied to clipboard
Reduce response time shop pages
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.
Context
- https://github.com/openfoodfoundation/ofn-install/issues/859#issuecomment-1874840248
Impact and timeline
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.
let me work on this. Just to confirm, shopfront page means this api app/controllers/api/v0/shops_controller.rb
, right?
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.
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
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.
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).