Question

I'm using a sharded version of MongoDB (Mongo 2.2.0), with two shards, each with a single replica.

I've noticed the network between different zones in amazon isn't as fast as in the same zone. ping latency for the same zone is about 0.5ms and between zones it's about 1.5ms with peaks of 13ms.

I wonder if there is a way to set replicas on each zone, and have the queries routed to the closest machine.

thanks

Was it helpful?

Solution

There's a section in the documentation about Data Center Awareness and Deploying Geographically Distributed Replica Sets. Essentially, there's a tagging feature for sharding and for replica sets so you can explicitly specify where a write or read should go to.

The big question, however, concerns your application architecture and whether you want to have application servers in different zones or not. Since writes must always go to a primary, there's little benefit in having application servers in different locations for write-heavy applications.

You can, however, speed up reads by either using the tag feature or by using nearest as a read preference, which will help read-heavy applications a lot.

Generally speaking, hosting applications in different data centers is not easy, because you either need a single point of synchronization or you need to use some kind of multi-version concurrency. From a technical perspective, that is a tradeoff, and it depends on the nature of the application which position in the spectrum works best for you.

OTHER TIPS

For every Amazon Instance, It will have unique Private IP. Try to use that for better performance. It will connects within their network.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top