MongoDB Sharding on single linux machine
Let's say I wanna have a MongoDB Server with 5 shards on one machine and each shard having replica set of 3 servers.
Would that increase performance? What are downsides of this?
The plus sides:
- you would be able to have concurrent writes, provided that the data was hashed to different shards. MongoDB locks the entire database on that instance when doing a write, so even a non-sharded replica set can only write one thing at a time
- it's a good way of learning sharding/replica sets/admin, but if you just want to do that you can achieve this with less instances
- replication would be very quick :)
The downsides:
- you would need a powerful machine (multiple CPUs but also as much memory as possible, and quick disks) to really benefit from the performance - Mongo craves RAM! For optimal performance your total index size should fit into RAM, which means if you have 2 gigs of index per shard, you would need 5 * 3 * 2 = 30 gigs of ram, plus the memory for the OS etc as well
- you may not benefit much from the slaveOK query option
- you would have no protection against hardware failure - if the box goes, all your shards and your replica sets go