Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

PHP MongoDB connection to replicationset

$
0
0

In the original situation, we had 3 web nodes (each in their own network segment) who connected to a single mongod instance. To add redundancy, we created a 3-node replset, with 1 node in each of the network segments of the web nodes.

Currently, the 3 web nodes still connect to the first server, which is the primary server in the replset. By changing the connectionstring, I should be able to specify the 2 other servers as well.

Given that the read preference of the PHP driver is set to RP_PRIMARY by default, does this mean that the 2 other servers will be doing nothing most of the time? Assuming I change my read preference to allow use of the secondary servers, what would happen if I write something and then try to re-read the same information? Will this read be sent to the primary or to the secondary (which might just not yet have received the data we wrote).

Although the nodes are in different network segments, the latency between them is just a few milliseconds, so I don't expect a lot of issues with stale data, but I just need to know.


Viewing all articles
Browse latest Browse all 17268

Trending Articles