MongoDB---performance optimization---(1)

Source: Internet
Author: User
Tags mongodb query

MongoDB Data Architecture


Upgrade resolution. Scenario

Problem finding

Server response slows due to the sudden influx of application server users


Check the server and find that each response is very slow, 30ops


Inspection process


. Discovery of database queries slow
. Check the Index
. Check the memory footprint. Usage
. Check the TCP connection




Comparison Test 1


. Hardware configuration:
Client
2CPU,2G Memory, windows2008
. Service side:
ROUTER:4CPU,4G, Memory, centos6.5 64-bit
mongod:2cpu,8g, Memory, centos6.5 64-bit
.1. Test for router in. 200QPS per second.
.2. Test for Mongod in. 500qps per second.
Summary: Make. With sharding architecture, the query will be more slow than direct to a single MONGO query.




Comparison Test 2


. Hardware configuration:
Client
2cpu,2.5g Memory, windows2008
2cpu,2.0g Memory, windows2008
. Service side:
mongod:2cpu,2.5g Memory, windows2008
.1.2cpu,2.5g memory locally, windows2008 into the. Line test, the query speed of 3000QPS, and even can break through 5000QPS.
.2. In 2cpu,2.0g memory, windows2008 to Mongod in. Line test, query speed 500QPS.
. Summary: TCP pair.. The network has a very big impact.




Comparison Test 3


. Hardware configuration:
Client
. Physical machine, 2cpu,4.0g memory, windows2008
. Service side:
. Physical machine, mongod:2cpu,4.0g memory, centos6.5 64-bit
. Physical machine, router:2cpu,4.0g memory, centos6.5 64-bit
.1. Test the Mongod, query speed 1000QPS.
.2. Test the router, query speed 500QPS.
Summary: The presence of a. A certain limit makes the speed limit.




Comparison Test 4


. Hardware configuration:
Client
. ucloud,2cpu,4.0g Memory, windows2008
. Service side:
. ucloud,mongod:2cpu,4.0g memory, centos6.5 64-bit
. ucloud,router:2cpu,4.0g memory, centos6.5 64-bit
.1. Test the Mongod, query speed 2000QPS.
.2. Test the router, query speed 1000QPS.
Summary: Ucloud. Li Yun's machine performance is good.




Comparison Test 5


. Hardware configuration:
Client
. ucloud,16cpu,64.0g Memory, windows2008
. Service side:
. ucloud,mongod:16cpu,64.0g memory, centos6.5 64-bit
. ucloud,router:16cpu,64.0g memory, centos6.5 64-bit
.1. Test the Mongod, query speed 13000QPS.
.2. Test the router, query speed 10000QPS.
Summary: At this point finally found the root knot, the client CPU cores determine the speed of MongoDB query.




Conclusion


1. Li Yun's cloud host has made certain restrictions that result. Regardless of setting the system, the configuration of the database, all. Cannot break through. An order of magnitude of QPS.
2. The number of client CPU cores determines the speed of MongoDB queries.
3.tcp limit passed. Walk inside. Nets can be avoided.
4.linux OS beats windows. So the MongoDB architecture is on Linux. Better than architecture on Windows.


Latest architecture




Latest architecture




Extreme Performance Testing


. above. The latest schema in. Line test:
. Open 4 IIS clients while router the. Line query,
Router can reach 20,000 queries per second. Change to a business comparison, which can handle 2000 people per second.




Performance conclusions


In order to ensure the normal operation of the online business. Rows, the server on which the database resides needs 8cpu,16g memory.
To ensure the integrity of the backup, the slave database is backed up and the router is backed up. Backup is retained for 30 days.
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.