After the new Web Machine node was added to the project, it was found that the performance of its MongoDB cluster was beginning to suffer, and the response time of MongoDB became very long during the peak period of the request.
The monitoring found that the number of MongoDB connections reached around 1100~1500 at its peak time, because each connection needed to use 10M (stack size defaults to 10240) of memory, which resulted in considerable memory overhead.
Boxedice is handled by optimizing the connection pool, controlling the number of connections by about 800, and then modifying the kernel's stack size value from the default of 10M to 1M, so that the memory consumed by the connection is greatly reduced.
If you have too many MongoDB connections, you can drag performance and query the number of connections by Serverstatus:
Mongo> db.serverstatus (). connections
Each connection is a thread and requires a stack,linux the default stack setting is generally larger:
Shell> Ulimit-a | grep Stack stack size (Kbytes,-s) 10240
As for MongoDB's actual stack size, it can be confirmed with the following command (in K):
Shell> cat/proc/$ (pidof mongod)/limits | grep Stack | Awk-f ' size ' {print int ($NF)/1024} '
If the stack is too large (for example, 10240K) it doesn't make sense, simply compare the size and RSS in the command result:
Shell> cat/proc/$ (pidof mongod)/smaps | grep 10240-a 10
The amount of memory that all connections consume is quite staggering, and it's recommended to make the stack smaller, say 1024:
Shell> ulimit-s 1024
Note: Starting with MongoDB1.8.3, MongoDB will automatically set up the stack at startup.