Reputation: 4309
Say you have multiple Mongo shards in a production environment, so each of them are replica sets. You have three different Mongos instances running for connecting to these replica sets, so you're doing something like this:
new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27017,mongos3.example.com:27017");
What scheme does the PHP Mongos driver use to determine which of these it's going to connect to? Doing a search for this, I've been able to find relatively little information, and the few things I have come across tend to contradict each other, some saying it picks the first one to respond, and others saying it picks the first one you enter in your code.
Does anyone know?
This is for PHP 1.3.4.
Upvotes: 0
Views: 77
Reputation: 1469
As Sammaye stated, the MongoClient connects to the "nearest" mongos
first, where "nearest" is determined by latency. If you're interested, you can take a look at manager.c and read_preference.c in the php driver.
Upvotes: 1