Wednesday 23 October 2019

How do you implement sharding in a Node.js, Express, Mongoose application?

https://mongoosejs.com/docs/guide.html#shardKeyThe documentation doesn't say much, I think the shard key takes for argument the fields in the schema you want to use for the key, but the example given should only work for the range-based sharding if I understand correctly.https://docs.mongodb.com/manual/reference/method/sh.shardCollection/I thought I had to implement my own logic for sharding, but it seems I just need to modify the schema when using it with Mongoose. The things that aren't clear however is how to use hashed sharding? Is it done configuration side? The doc says we need can only use 1 field, so does that mean it won't work if we provide 2 like in the example given?Also, how do we configure this properly if we use MongoDB Atlas?

Submitted October 24, 2019 at 12:49AM by jesusscript

No comments:

Post a Comment