happy-plants icon indicating copy to clipboard operation
happy-plants copied to clipboard

App is getting slow with many plants

Open matthijsthoolen opened this issue 3 years ago • 2 comments

I have added a lot of plants to the app, 92 and still have to add some. But the app is extremely slow in the first load, up to a few minutes before the first image is shown. I already optimized this quite a lot by compressing all images (and creating thumbnails for the overview, and larger images for the detail pages), this saves both space and bandwith (feature 'request' 1).

The second problem is the large amount of request that are getting send to the firebase, for every plant 2 request are created. They are all executed before the first image is rendered. I don't have enough experience with firebase and/or vue.js to find the correct solution for this, but to me it seems that there must be a way to optimize this. By combining requests, or by using lazy-loading.

If you have any ideas on this, happy to help implement it

matthijsthoolen avatar Aug 03 '20 20:08 matthijsthoolen

Yes, this is a major problem. I also have a lot of plants added and it slows down considerably. With v2 I am planning to address this and have made a few minor improvements overall but haven't found a good overall solution just yet. One of the problems is that I don't really know how to reduce a) network requests and b) speed them up.

The current flow for a) is as follows:

  1. Make a request to get a collection of all plants (and their IDs)
  2. Iterate over collection and make an additional request per plant to get the full data
  3. At the same time, another request to get the image URL per plant

A few ideas that come to mind:

  • Store list of plants in localStorage, gets rid of first request (already done in v1, still not optimal as sync takes a while)
  • Create additional thumbnails per plant (in Firebase via functions) to speed up load time on Home, only load high-resolution on detailed plant view
  • Investigate if Firebase API could be used differently (e.g. queries)
  • Look into different Firestore database pattern (e.g. optimised documents/collections)

Since v2 isn't released and finished yet, I want to fix this for the new release. Happy for any help on this :)

morkro avatar Aug 04 '20 07:08 morkro

I have found a good improvement, which is currently implemented in v2. It refactors Firebase API usage and leverages a Web Worker for fetching images in another thread. This speeds up the load time immense and on my own account I get a load time of 1sec.

morkro avatar Aug 24 '20 08:08 morkro