development:
  clients:
    default:
      # MONGODB_URI includes draft_content_store_development or content_store_development
      # depending on whether we're running content store in draft mode or not.
      uri: <%= ENV['MONGODB_URI'] || 'mongodb://localhost/content_store_development' %>
      options:
        write:
          w: 1

test:
  clients:
    default:
      uri: <%= ENV['TEST_MONGODB_URI'] || 'mongodb://localhost/content_store_test' %>
      options:
        write:
          w: 1
        # In the test environment we lower the retries and retry interval to
        # low amounts for fast failures.
        max_retries: 1
        retry_interval: 0

production:
  clients:
    default:
      uri: <%= ENV['MONGODB_URI'] %>
      options:
        ssl: <%= ENV['MONGO_SSL'] || 'false' %>
        ssl_verify: <%= ENV['MONGO_SSL_VERIFY'] || 'true' %>
        server_selection_timeout: 5
        write:
          w: <%= ENV['MONGO_WRITE_CONCERN'] || 'majority' %>
        read:
          mode: :secondary_preferred

development:
  clients:
    default:
      # MONGODB_URI includes draft_content_store_development or content_store_development
      # depending on whether we're running content store in draft mode or not.
      uri: <%= ENV['MONGODB_URI'] || 'mongodb://localhost/content_store_development' %>
      options:
        write:
          w: 1

test:
  clients:
    default:
      uri: <%= ENV['TEST_MONGODB_URI'] || 'mongodb://localhost/content_store_test' %>
      options:
        write:
          w: 1
        # In the test environment we lower the retries and retry interval to
        # low amounts for fast failures.
        max_retries: 1
        retry_interval: 0

production:
  clients:
    default:
      uri: <%= ENV['MONGODB_URI'] %>
      options:
        ssl: <%= ENV['MONGO_SSL'] || 'false' %>
        ssl_verify: <%= ENV['MONGO_SSL_VERIFY'] || 'true' %>
        server_selection_timeout: 5
        write:
          w: <%= ENV['MONGO_WRITE_CONCERN'] || 'majority' %>
        read:
          mode: :nearest

Use the `nearest` read mode for MongoDB
Use the `nearest` read mode for MongoDB

The Content Store is a read heavy application, as it only processes
writes when things change, but it's constantly serving the frontend
applications with data.

This can be seen in the load on the MongoDB machines, currently the
primary gets off lightly with a low load, and the secondary machines
handle most of the operations.

Using the nearest MongoDB machine should spread the load more evenly,
and might even increase performance due to reduced network latency.

I've been looking at this, as the MongoDB machines often complain
about high load (especially on the AWS side of Staging).
