'MongoDB general install question about replica set
I have a server where I have a mongodb database of 150Gb
There are 8 databases in it with intensive write activity (as I'm storing tweets)
I notice some latency when reading data and am wondering if it would be interesting to switch to a replica set, considering I only have one machine.
Idea would be to have mongo running on 3 different ports, and each pointing to a different folder.
Would there be a benefit? I imagine that having 3 mongo instances with one dedicated to writing would be better but I'm not sure.
If yes, how should I configure the replica set (priority? arbiter?...)
Thanks for your help
Solution 1:[1]
To improve your read performance :
- Add indexes if you don't have yet or optimize the current ones.
- Add better project stages in your queries (to fetch only the data that you need)
- Add more RAM
- Add more wiredTiger cache
- Improve filesystem performance (reduce swappiness, mount with noatime, etc.)
- If your queries have a lot of aggregation + sorting add more CPU.
- Disable your WiredTiger FTDC
- Mount the journal to separate partition.
- Distribute the 8x databases in 8x different disks (ssd/xfs preferred)
You can switch to replicaSet when:
- You need redundancy (for production you always need)
- Your use case allow read preference from SECONDARY (then adding more members benefits read performance since you can distribute reads to SECONDARY members)
Advice:
Considering you have write intensive applications sounds like a better option to switch to sharded cluster, adding more shards will distribute the writes better. Of course for 150GB (such small size), you need to decide if is worth the effort to do this if it is only for testing :)
Something like this sounds nice to me:
2x mongos + 3x CSRS + 3x shards (3x members in each replicaSet/shard)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | marc_s |