morkro / happy-plants

🌵 Web application to manage plants
https://happyplants.garden
BSD 3-Clause "New" or "Revised" License
287 stars 34 forks source link

App is getting slow with many plants #94

Open matthijsthoolen opened 4 years ago

matthijsthoolen commented 4 years ago

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

morkro commented 4 years ago

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:

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

morkro commented 4 years ago

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.