Mongodb – run a mongos without any config servers

mongodb

I just want to use mongos as a tool to scale up the number of connections I can open to mongo. So can I run the mongos without any config servers?

Has any one done this before?

Best Answer

You cannot run a mongos without a config server, but you shouldn't have to in order to "scale up" your connections in any case - all you would be doing is adding an unnecessary layer between the driver you are using and the replica set. Unless you are using sharding, having that layer is not necessary, and can introduce performance issues in some cases (such as unbatching delays).

Your driver (which you don't mention) will have connection pool settings (the Java version can be found here) and perhaps multiplier options to determine how many connections you will open to your replica set, and how many threads will block and wait for a connection from the pool.

Some general advice:

  • If you do go down the route of having a single shard (which is what your replica set would effectively become with config servers and mongos processes), then do not run with a single config server - always run with 3 config servers in production, period.
  • Be careful with connections - each connection on the MongoDB side will require 1MB of memory (as will each connection on a mongos). If you ramp up connection levels you will be using memory for connection heap rather than data - this can be significant (10GB of memory for 10,000 concurrent connections)
  • If you do ramp up connections, make sure your ulimit settings can handle it

Finally, this use of mongos as a general proxy has been proposed before. In theory it would simplify some of the driver code needed if there was always a mongos in the connection path, but it is not as simple as just allowing it. The relevant feature request can be found (and voted for, watched etc.) here:

https://jira.mongodb.org/browse/SERVER-1594