Closed sean-b765 closed 2 years ago
As the free MongoDB plan is a replica set, we may be able to set a readPreference to ensure quicker data access.
I believe this commit may speed up the response time while updating the DB. More testing will have to be done.
Using readPreference: 'secondary'
in mongoose connect options on the main thread may allow quicker data access while the DB is updating. The data being read may be stale but the response should be much quicker.
Replication
May also use readPreference: 'nearest'
as it chooses the replica node which has the least latency.
After heroku has started from being idle, it will perform a DB update if it has been +12 hours since the last update. Heroku
service=471ms
shows that the request is being handled quickly, but the response must be taking long because MongoDB is being updated with so much data.