drex44 / good-food-guide

A guide to know which foods are good when you have certain disease! [Built with React/NextJs]
https://good-food-guide.now.sh
MIT License
48 stars 38 forks source link

Performance problem #71

Open drex44 opened 5 years ago

drex44 commented 5 years ago

Now the website had a backend and is used to query from the database. this has resulted in slow page response.

Need to think of a way to increase the performance.

abCods commented 5 years ago

You can do something about boosting query performance in order to tackle the sluggishness from back-end. For MongoDB you can take following steps.

  1. Cache Queries: MongoDB has a built in cache mechanism for queries as explained here. You can utilize it well by doing the Document's indexing right. You can dig deeper into MongoDB's indexing by following it's official docs here.

  2. Cache Query Results: For most used queries you can go one step further and cache their resultant data-sets using Redis. I have used it in one of my projects on MySQL and found it useful. Here is a tutorial for using it on Mongo.

drex44 commented 5 years ago

@abZameen I would surely look into it. Right now my biggest problem is each page calls APIs separately and this results in multiple time fetching the same data. I was thinking about creating a global store using state management libraries such as redux to reduce the number of times the APIs are getting called.