The following checklist, along with the Operations Checklist, provides recommendations to help you avoid issues in your production MongoDB deployment.
- Ensure that your schema design does not rely on indexed arrays that grow in length without bound. Typically, best performance can be achieved when such indexed arrays have fewer than 1000 elements.
- Make use of connection pooling. Most MongoDB drivers support connection pooling. Adjust the connection pool size to suit your use case, beginning at 110-115% of the typical number of concurrent database requests.
- Ensure that your applications handle transient write and read errors during replica set elections.
- Ensure that your applications handle failed requests and retry them if applicable. Drivers do not automatically retry failed requests.
- Use exponential backoff logic for database request retries.
cursor.maxTimeMS()for reads and wtimeout for writes if you need to cap execution time for database operations.