Requirement Overview:We are capturing all activity on Jobs In mongoDB like view ,apply,view source,apply source etc.There is lots of read query fired on real times to get stats about jobs.
We need to scale our read load so that we can serve all read request without any delay.
Approach :There are 2 ways of reducing read load on Primary MongoDB server.
- Distributing the Data on Multiple Node (Sharding).
2. Use secondary mongodb node for read query.
Since Our data size is not large ,we have not implemented sharding .But read operation are very high on the same data Set.
Code Snippet:
var collection =dataLoggerDB.collection(currentCollection,{readPreference:'secondaryPreferred'});
Read Preference Options:
Read Preference Mode
|
Description
|
In most situations, operations read from secondary members but if no secondary members are available, operations read from the primary.
| |
Operations read from member of the replica set with the least network latency, irrespective of the member’s type.
|
No comments:
Post a Comment