Mongodb Certified Developer Associate C100dev · Free Practice Question Hard
Question 28
A development team is configuring an application to connect to a MongoDB cluster hosted on Atlas. The application must connect securely, utilize MongoDB's latest features, and handle high traffic with automatic failover. The team also needs to specify a custom read preference to distribute read operations across multiple replicas. What is the most appropriate MongoDB URI connection string for these requirements?
-
A
- mongodb+srv://username:password@host/test?retryWrites=false&readPreference=primary
-
B
- mongodb+srv://username:password@host/test?ssl=true&readPreference=secondary
-
C
- mongodb+srv://username:password@host/test?retryWrites=true&w=majority&readPreference=nearest
-
D
- mongodb://username:password@host1,host2,host3/test?readPreference=primaryPreferred
Reveal correct answer
Correct answer: C
A.
This URI string uses the mongodb+srv protocol but disables retryWrites which is crucial for handling write operations during failover, and uses a "primary" read preference which could lead to performance bottlenecks under high traffic conditions.
B.
This URI string uses the mongodb+srv protocol and SSL for security but specifies a read preference of "secondary" which may not optimally distribute read operations for high traffic scenarios.
C.
This URI string uses the mongodb+srv protocol for simplified DNS configuration, includes automatic retry of write operations, specifies a read preference of "nearest" for distributing read operations across replicas, and uses a replica set to ensure high availability.
D.
Although this string connects to a replica set and specifies a read preference, it does not use the mongodb+srv protocol which simplifies DNS management and does not automatically include failover capabilities.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
