[Original] MongoDB, handlersocket and MySQL Performance Test and result analysis

Source: Internet
Author: User
Tags bulk insert mongodb server mongodb version

 

I. Test Environment
1. Test Server Status
A total of four test servers are involved:

Stress testing server
Web Server
MongoDB Server

MySQL server.

 

Machine Configuration:
CPU: Intel (r) core (TM) 2 Duo CPU e7200 @ 2.53 GHz
Ram: 8g DDR2 667
Disk: SATA

OS: RedHat 5.5

 

1. stress testing server
Install webbench 1.5 and press the Web server through webbench.

 

2. Web Server
Nginx 0.8.54 + PhP 5.3.3 (PHP-FPM), installed with the PHP driver of MongoDB and handlersocket.
MongoDB's PHP driver is: mongodb-mongo-php-driver-1.1.1-19-gc584231.tar.gz
Handlersocket PHP driver for: php-handlersocket-0.0.7.tar.gz
Using PHPProgramTo call MongoDB and handlersocket.

 

3. MongoDB Server
MongoDB version: 1.6.5

 

4. MySQL Server
MySQL version: 5.1.53
Handlersocket version: 1.0.6-60-gf51e061
MySQL storage engine: InnoDB. The thread pool size of InnoDB is adjusted to 2 GB.

2,Test procedure and test data extraction
1. To avoid the bottleneck of opening connections and the HTTP server, set the public connection for every 1000 requests in the test program, and set each page request to execute 1000 data requests.
2. test data, including QPS, CPU, Io, and other data, from commands provided by the operating system (such as vmstat and iostat) it can be obtained by using commands provided by MongoDB and MySQL (such as mongostat and mysqladmin.

Ii. Test Results
1. 1 million records
1. Query

 

 

2. Insert

2. 10 million records
1. Query

2. Insert

 

3. 20 million records

1. Query

 
2. Insert

 

4. 50 million records
1. Query

 

2. Insert

Iii. Test Analysis Summary

1. I/O read/write status
From the inserted TPS data, we can see that there are significant differences between MySQL, handlersocket, and MongoDB data, which is mainly related to their internal implementation and testing methods.

 

In the test scenario, MySQL uses a single insert, so we can see that the QPS and TPS are basically the same, that is, each insert operation corresponds to an I/O write operation. Some optimizations can be made from the MySQL database itself. This test did not cover this scenario.

 

The bulk insert operation is used inside the handlersocket. Therefore, we can see that the number of QPS is significantly greater than the number of TPS, and batch insert operations significantly improve the overall performance.

 

MongoDB adopts the method of merging operations internally. Data is first stored in the memory and then flushed to the disk. Therefore, from the test data, we can see that the TPS curve slope is very high: Sometimes the TPS is zero, it is still in the memory, and it is not flushed to the disk; sometimes the TPS is very high, at the same time, the CPU is also very high, almost 100%, and flush to the disk is performed at this time. Based on this mechanism, more detailed optimization and testing will be performed in the future, because there may be several problems:
First, it may cause high I/O and CPU pressure in a certain period of time, or even peak. In this case, the overall health status of the Service will face some challenges.
Second, if the server is restarted, data may be lost. Data in the memory will be lost if it is not flushed to the disk. Of course, this situation has two sides, because using this method, we can see from the test results that the overall Write Performance is higher than that of MySQL and handlersocket, which is a trade-off, it depends on whether the specific business can accept such high performance in exchange for data reliability, some businesses may be acceptable, such as feed.

2. CPU usage
From the query results, we can see that MySQL and MongoDB are close to 100%, while handlersocket saves a variety of SQL parser and related operations, and keeps the CPU usage between 40% and 60%, within a reasonable range.

 

From the inserted CPU data, we can see that the CPU usage of handlersocket remains between 40% and 60%, which is lower than that of MySQL and MongoDB. MySQL and MongoDB are mostly kept between 50%-90%.

 

3. QPS
From the QPS data under the query condition, we can see that the query performance of handlersocket and MongoDB is almost the same, reaching more than 30 thousand. As the data volume increases, the performance remains below 30 thousand. Currently, it is only the case where the maximum test is 50 million data, and a higher value is not covered in this test. The performance of MySQL is worse than that of MySQL, generally between 18000 and 25000. Of course, this time we didn't have much Optimization for MySQL, but only increased the innodb_thread_pool size and the size of the data block allocated each time. If we optimize MySQL, we may be able to improve the performance of handlersocket and MySQL at the same time.

 

From the inserted QPS data, we can see that MongoDB has a significant advantage, which is related to its implementation methods. As the data volume increases, QPS is correspondingly reduced. In this regard, MySQL has the largest scope. When the data volume reaches more than 50 million, MySQL's insertion performance is 2000-3000, while handlersocket can be kept above 10 thousand, and MongoDB is above 20 thousand.

 

Author: Hong Xiaojun
Source:Http://www.cnblogs.com/inrie

Please indicate the source for reprinting. Thank you!

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.