Connectivity optimization for MongoDB performance optimization

Source: Internet
Author: User
Tags mongodb

When a new Web machine node is added to the project, the performance of its MongoDB cluster is found to be impacted, at the peak of the request, and the MongoDB response time becomes very long.

Monitoring found that the number of connections MongoDB at peak times reached around 1100~1500, which resulted in considerable memory overhead due to the need for each connection to use 10M of memory with a stack size default of 10240.

The Boxedice approach is to first optimize the connection pool, control the number of connections by 800, and then modify the kernel stack size value, from the default 10M to 1M, so that the memory of the connection is greatly reduced.


The number of MONGODB connections can drag down performance and query the number of connections by Serverstatus:

Mongo> db.serverstatus (). connections

Each connection is a thread that requires a stack,linux the default stack setting is generally larger:

Shell> Ulimit-a | grep Stack stack size              (Kbytes,-s) 10240

As for the actual stack size used by MongoDB, you can use the following command to confirm (unit: 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 control the size and RSS in the command result:

Shell> cat/proc/$ (pidof mongod)/smaps | grep 10240-a 10

The amount of memory consumed by all connections can be staggering, and it's recommended that you set the stack down a little bit, say 1024:

Shell> ulimit-s 1024

Note: Starting at MongoDB1.8.3, MongoDB will automatically set stack at startup.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.