sysbench 0.4.13: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Initializing random number generator from timer.
Random number generator seed is 0 and will be ignored
Doing OLTP test.
Running mixed OLTP test
Using Uniform distribution
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Using 1 test tables
Threads started!
Time limit exceeded, exiting...
(last message repeated 15 times)
Done.
OLTP test statistics:
queries performed:
read: 3964912
write: 1416040
other: 566416
total: 5947368
transactions: 283208 (78.67 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 5380952 (1494.66 per sec.)
other operations: 566416 (157.33 per sec.)
Test execution summary:
total time: 3600.1084s
total number of events: 283208
total time taken by event execution: 57599.8189
per-request statistics:
min: 3.57ms
avg: 203.38ms
max: 1183.50ms
approx. 95 percentile: 498.73ms
Threads fairness:
events (avg/stddev): 17700.5000/35.07
execution time (avg/stddev): 3599.9887/0.03
海外merger server测试oltp的数据:
sysbench 0.4.13: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Initializing random number generator from timer.
Random number generator seed is 0 and will be ignored
Doing OLTP test.
Running mixed OLTP test
Using Uniform distribution
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Using 1 test tables
Threads started!
Time limit exceeded, exiting...
(last message repeated 15 times)
Done.
OLTP test statistics:
queries performed:
read: 2008804
write: 717430
other: 286972
total: 3013206
transactions: 143486 (39.85 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 2726234 (757.23 per sec.)
other operations: 286972 (79.71 per sec.)
Test execution summary:
total time: 3600.2908s
total number of events: 143486
total time taken by event execution: 57602.0610
per-request statistics:
min: 64.60ms
avg: 401.45ms
max: 6108.75ms
approx. 95 percentile: 573.04ms
Threads fairness:
events (avg/stddev): 8967.8750/22.93
execution time (avg/stddev): 3600.1288/0.08
海外2次测试oltp(修改innodb_flush_method=O_DIRECT):
sysbench 0.4.13: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Initializing random number generator from timer.
Random number generator seed is 0 and will be ignored
Doing OLTP test.
Running mixed OLTP test
Using Uniform distribution
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Using 1 test tables
Threads started!
Time limit exceeded, exiting...
(last message repeated 15 times)
Done.
OLTP test statistics:
queries performed:
read: 537600
write: 192000
other: 76800
total: 806400
transactions: 38400 (42.66 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 729600 (810.49 per sec.)
other operations: 76800 (85.32 per sec.)
Test execution summary:
total time: 900.1910s
total number of events: 38400
total time taken by event execution: 14401.4218
per-request statistics:
min: 131.79ms
avg: 375.04ms
max: 871.31ms
approx. 95 percentile: 517.90ms
Threads fairness:
events (avg/stddev): 2400.0000/5.15
execution time (avg/stddev): 900.0889/0.05
sysbench 0.4.13: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Initializing random number generator from timer.
Random number generator seed is 0 and will be ignored
Doing OLTP test.
Running mixed OLTP test
Using Uniform distribution
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Using 1 test tables
Threads started!
Time limit exceeded, exiting...
(last message repeated 15 times)
Done.
OLTP test statistics:
queries performed:
read: 545762
write: 194915
other: 77966
total: 818643
transactions: 38983 (43.31 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 740677 (822.81 per sec.)
other operations: 77966 (86.61 per sec.)
Test execution summary:
total time: 900.1752s
total number of events: 38983
total time taken by event execution: 14401.2252
per-request statistics:
min: 100.85ms
avg: 369.42ms
max: 860.14ms
approx. 95 percentile: 509.75ms
Threads fairness:
events (avg/stddev): 2436.4375/6.77
execution time (avg/stddev): 900.0766/0.05
~
"result_5.log" 45L, 1514C
2. sysbench
fileio。先看下相关的参数:
[liujinguang@VM_221_168_centos sysbench-0.4.12.7]$ sysbench --test=fileio help
sysbench 0.4.13: multi-threaded system evaluation benchmark
fileio options:
--file-num=N number of files to create [128];测试要创建的文件数目
--file-block-size=N block size to use in all IO operations [16384];测试中使用的文件块的大小:16k
--file-total-size=SIZE total size of files to create [2G];测试中要创建的文件总大小
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw};测试模式:顺序写,顺序rewrite,顺序读,随机读,随机写,随机rewrite?
--file-io-mode=STRING file operations mode {sync,async,fastmmap,slowmmap} [sync]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all=[on|off] do fsync() after each write operation [off]
--file-fsync-end=[on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5];读写比例,没用过
3. innodb flush method
innodb_flush_method
Command-Line Format --innodb_flush_method=name
System Variable Name innodb_flush_method
Variable Scope Global
Dynamic Variable No
Permitted Values (Windows) Type string
Default async_unbuffered
Valid Values normal
unbuffered
Permitted Values (Unix) Type string
Default NULL
Valid Values fsync
littlesync
nosync
O_DSYNC
O_DIRECT
Defines the method used to flush data to the InnoDB data files and log files, which can affect I/O throughput.
If innodb_flush_method=NULL on a Unix-like system, the fsync option is used by default. If innodb_flush_method=NULL on Windows, the async_unbuffered option is used by default.
The innodb_flush_method options for Unix-like systems include:
fsync: InnoDB uses the fsync() system call to flush both the data and log files. fsync is the default setting.
O_DSYNC: InnoDB uses O_SYNC to open and flush the log files, and fsync() to flush the data files. InnoDB does not use O_DSYNC directly because there have been problems with it on many varieties of Unix.
littlesync: This option is used for internal performance testing and is currently unsupported. Use at your own risk.
nosync: This option is used for internal performance testing and is currently unsupported. Use at your own risk.
O_DIRECT: InnoDB uses O_DIRECT (or directio() on Solaris) to open the data files, and uses fsync() to flush both the data and log files. This option is available on some GNU/Linux versions, FreeBSD, and Solaris.
The innodb_flush_method options for Windows systems include:
async_unbuffered: InnoDB uses Windows asynchronous I/O and non-buffered I/O. async_unbuffered is the default setting on Windows systems.
normal: InnoDB uses a simulated asynchronous I/O and buffered I/O. This option is used for internal performance testing and is currently unsupported. Use at your own risk.
unbuffered: InnoDB uses a simulated asynchronous I/O and non-buffered I/O. This option is used for internal performance testing and is currently unsupported. Use at your own risk.
How each settings affects performance depends on hardware configuration and workload. Benchmark your particular configuration to decide which setting to use, or whether to keep the default setting. Examine the Innodb_data_fsyncs status variable to see the overall number of fsync() calls for each setting. The mix of read and write operations in your workload can affect how a setting performs. For example, on a system with a hardware RAID controller and battery-backed write cache, O_DIRECT can help to avoid double buffering between the InnoDB buffer pool and the operating system's file system cache. On some systems where InnoDB data and log files are located on a SAN, the default value or O_DSYNC might be faster for a read-heavy workload with mostly SELECT statements. Always test this parameter with hardware and workload that reflect your production environment. For general I/O tuning advice, see Section 8.5.7, “Optimizing InnoDB Disk I/O”.
Prior to MySQL 5.1.24, the default innodb_flush_method option was named fdatasync. When fdatasync was specified, InnoDB used the fsync() system call to flush both the data and log files. To avoid confusing the fdatasync option name with the fdatasync() system call, the option name was changed to fsync in MySQL 5.1.24.
4. 优化Limit查询
目前拼的sql:
mysql> explain select id,playerId,type,mailId,title,content,params,classification,effectTime,createTime,updateTime,invalid from email limit 6200000,100000;
+----+-------------+-------+------+---------------+------+---------+------+----------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+----------+-------+
| 1 | SIMPLE | email | ALL | NULL | NULL | NULL | NULL | 19179630 | NULL |
+----+-------------+-------+------+---------------+------+---------+------+----------+-------+
1 row in set (0.00 sec)
order by 优化使用索引:
mysql> explain select id,playerId,type,mailId,title,content,params,classification,effectTime,createTime,updateTime,invalid from email order by id limit 6200000,100000;
+----+-------------+-------+-------+---------------+---------+---------+------+---------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+---------+---------+------+---------+-------+
| 1 | SIMPLE | email | index | NULL | PRIMARY | 4 | NULL | 6300000 | NULL |
+----+-------------+-------+-------+---------------+---------+---------+------+---------+-------+
1 row in set (0.03 sec)
1. sysbench
prepare
run
mysql参数
62 rows in set (0.02 sec)
国内merger server测试oltp的数据:
海外merger server测试oltp的数据:
海外2次测试oltp(修改
innodb_flush_method=O_DIRECT
):海外3次测试(
file_format=BARRACUDA,file_per_talbe=on, data_file_path=10M
):2. sysbench
fileio。先看下相关的参数:
3. innodb flush method
4. 优化Limit查询
目前拼的sql:
order by 优化使用索引:
尝试禁用查询缓存,query_cache_size=0, query_cache_type=off:结果email的合并变为了:2370s,比上次长了一些时间,看来禁用查询缓存还是有负面影响。
接着调整query_cache-size=1G,看效果
尝试从sending data这里入手:先对比下查询数据
5. mysql自带优化工具
show profiles
。展示所有性能收集。set profiling=on
打开性能收集。show profile for query QUERY_ID。
查看制定查询的性能分析数据。查看上面说到的韩国服的慢查询性能分析数据:
给出的还不是很详细,只是说到sending data要很长时间。
6. Percona
yum install perl
。yum install -y perl-CPAN perl-Time-HiResyum install -y perl-CPAN perl-Time-HiRes
make && make install
。pt-query-digest /data/mysql/data/mysql/3306/slow_query_log.log > slow_report.log