mongodb - Can we move the document dynamically across shards in mongo db? -
i building tracking platform has following use cases.
- need track 50,000 vehicles
- each vehicle relays location every 60 secs.
- get api returns vehicles in x km range.
so, need scale writes , achieve query isolation. can create shard cluster geographical region shard key(geohash). me balance writes , achieve query isolation. happens when vehicle moves across regions mangodb automatically move document new shard in case?
you cannot change shard key fields record once written. using region shard key prevent moving across regions unless delete record in original region , insert using new one.
on choosing shard key, 1 matches common query pattern. querying on shard key allow retrieve record directly shard. queries don't use shard key have perform scatter gather query against shards.
if on or can use mongodb 2.4, , don't need perform range based queries, may want consider using hashed shard key allow distribution, if shard key monotonically increasing. see this page advice on choosing shard key.
Comments
Post a Comment