Since the data store uses a MongoDB cluster, the address is the address of Mongos when accessed externally, and no problems were found during use. The configuration is as follows:
<mongo:mongo host="${mongodb.hostname}" port="${mongodb.port}"> <mongo:options connections-per-host="${mongodb.port}" threads-allowed-to-block-for-connection-multiplier="${mongodb.threads-allowed-to-block-for-connection-multiplier}" connect-timeout="${mongodb.connect-timeout}" max-wait-time="${mongodb.max-wait-time}" auto-connect-retry="${mongodb.auto-connect-retry}" socket-keep-alive="${mongodb.socket-keep-alive}" socket-timeout="${mongodb.socket-timeout}" slave-ok="${mongodb.slave-ok}" write-number="${mongodb.write-number}" write-timeout="${mongodb.write-timeout}" write-fsync="${mongodb.write-fsync}" /> </mongo:mongo>
However, after several rounds of performance testing, Mongos machines are found to be overloaded at large concurrencies and other storage Mongod machines are under load, so let's solve this problem.
After several analyses, the reasons originally were as follows:
1. Mongos, config server and mongod are all deployed on one machine.
2. The use of multiple Mongos to distribute external requests is not considered.
Thus, several other Mongos are deployed, using the same configuration library, to solve the problem, as follows:
<mongo:mongo id="mongo" replica-set="${mongodb.replica-set}"> <mongo:options connections-per-host="${mongodb.port}" threads-allowed-to-block-for-connection-multiplier="${mongodb.threads-allowed-to-block-for-connection-multiplier}" connect-timeout="${mongodb.connect-timeout}" max-wait-time="${mongodb.max-wait-time}" auto-connect-retry="${mongodb.auto-connect-retry}" socket-keep-alive="${mongodb.socket-keep-alive}" socket-timeout="${mongodb.socket-timeout}" slave-ok="${mongodb.slave-ok}" write-number="${mongodb.write-number}" write-timeout="${mongodb.write-timeout}" write-fsync="${mongodb.write-fsync}" /> </mongo:mongo>
Where, replica-set format: ip1:port,ip2:port,...