We have three servers in a replica set. For the sake of example, ServerA is primary, while ServerB and ServerC are secondaries. While stress testing the environment, the server load on ServerA has spiked to around 4.00, while the secondaries remain at 0.00. The URL targets of the stress testing do not do any writes to mongo, but it appears that reads are not being distributed to the secondaries.
We are using the official C# driver.
ServerA log shows many connections being opened, lsn set entries, and a bunch of “killcursors” commands — it is obviously working to serve up pages. ServerB and ServerC, however, only show the initial connections from the web servers (four of them), and after that only “lsn set” entries appear in the logs. After a few minutes, the initial four connections timeout and close.
The replica set is in full working order. I can stop mongo on the primary, and the secondaries will correctly elect a new primary.
Our connection string from Web.config:
<connectionStrings>
<add name="wellness.mongodb" connectionString="mongodb://serverA:27017,serverB:27017,serverC:27017/mydatabase?safe=true;replicaset=myreplicaset;slaveok=true" />
</connectionStrings>
What are we doing wrong?
The connection string looks OK. I’ll try and reproduce and report back.