MySQL并发测试

MySQL并发测试


 

一 测试说明

本次主要对比MySQL官方社区版mysql5.6.34和onesql5.6.34。测试模式为从100并发到4000并发,每次增加100并发,单表1000万数据,每次总请求数100万requests。测试参数如下:

--oltp-table-size=10000000  //表的记录数1000万

--num-threads=$i   //并发数量从100到4000递增

--max-requests=1000000  //每次请求的量100万

二 服务器配置

2.1 测试服务器配置

两路32core,单台服务器128GB内存,本地盘RAID5,网卡是两块千兆的电口做的绑定。具体信息如下。

 

CPU总内核:

[root@host01 test]# cat /proc/cpuinfo | grep 'processor' | wc -l

32

 

内存总数:

[root@host01 test]# cat /proc/meminfo

MemTotal:       131463880 kB

 

网卡信息:

[root@host01 test]# ethtool bond0

Settings for bond0:

        Supported ports: [ ]

        Supported linkmodes:   Not reported

        Supported pause frameuse: No

        Supportsauto-negotiation: No

        Advertised linkmodes:  Not reported

        Advertised pause frameuse: No

        Advertisedauto-negotiation: No

        Speed: 2000Mb/s ---网卡做的负载均衡模式,但是交换机侧没有做绑定,最大只有1000Mb/s速度。

        Duplex: Full

        Port: Other

        PHYAD: 0

        Transceiver: internal

        Auto-negotiation: off

        Link detected: yes

 

磁盘信息:

[root@host01 test]# fdisk -l /dev/sdb

 

Disk /dev/sdb: 4495.0 GB, 4494998896640 bytes, 8779294720 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

磁盘挂载模式;

/dev/mapper/datavg-mysqldata on /mysqldata type xfs (rw,noatime,nodiratime,attr2,nobarrier,inode64,noquota)

 

2.2 mysql社区版服务器说明

经过前期的测试mysql社区版服务器开启以下参数,对社区版本的性能会有50%的提升:

2.2.1 启用hugepage

[root@host01 test]# grep Page /proc/meminfo

AnonPages:       9952896 kB

PageTables:        50616 kB

AnonHugePages:   9787392 kB

HugePages_Total:   28000

HugePages_Free:    26289

HugePages_Rsvd:    19354

HugePages_Surp:        0

 

[root@host01 test]# ipcs -m

 

------ Shared Memory Segments --------

key       shmid      owner      perms     bytes      nattch     status     

0x00000000 4882432    mysql1    600        220200960  1         dest        

0x00000000 4915201    mysql1    600        5494538240 1          dest        

0x00000000 4947970    mysql1     600       5494538240 1          dest        

0x00000000 4980739    mysql1    600        5494538240 1          dest        

0x00000000 5013508    mysql1    600        5494538240 1          dest        

0x00000000 5046277    mysql1    600        5494538240 1          dest        

0x00000000 5079046    mysql1    600        5494538240 1          dest        

0x00000000 5111815    mysql1    600        5494538240 1          dest        

0x00000000 5144584    mysql1    600        5494538240 1          dest   

 

2.2.2 启用jemalloc

[root@host01 test]# ldconfig -p| grepjemalloc

       libjemalloc.so.2 (libc6,x86-64) => /usr/local/lib/libjemalloc.so.2

       libjemalloc.so (libc6,x86-64) => /usr/local/lib/libjemalloc.so

 

三 my.cnf配置信息

3.1 社区版my.cnf

[mysqld]

large_pages

skip-external-locking

skip-name-resolve

default-storage-engine = InnoDB

transaction_isolation = READ-COMMITTED

server-id = 11

user   = mysql1

port   = 3301

socket = /mysqldata/mysql1/run/mysql.sock

#basedir = /usr/local/onesql5634

basedir = /home/mysql1/mysql

datadir = /mysqldata/mysql1/data

pid-file=/mysqldata/mysql1/run/mysql.pid

lc-messages-dir=/home/mysql1/mysql/share

log-error = /mysqldata/mysql1/log/error.log

wait_timeout=86400

character_set_server=utf8

open_files_limit    = 40960

connect_timeout = 30

max_connections = 8000

max_connect_errors = 100000

table_open_cache = 3000

lower_case_table_names = 1

max_allowed_packet = 32M

tmp_table_size = 32M

key_buffer_size = 256M

slow_query_log = 1

long_query_time = 1.05

slow_query_log_file =/mysqldata/mysql1/log/slow.log

log-bin = /mysqldata/mysql1/bin/mysql-bin

binlog_format=mixed

max_binlog_cache_size = 8M

max_binlog_size = 1024M

innodb_buffer_pool_size = 40960M

innodb_data_file_path =ibdata1:1024M:autoextend

innodb_log_buffer_size = 200M

innodb_log_file_size = 256M

innodb_log_files_in_group = 2

innodb_max_dirty_pages_pct = 50

innodb_file_per_table = 1

innodb_locks_unsafe_for_binlog = 0

innodb_flush_method = O_DIRECT

innodb_flush_log_at_trx_commit = 2

innodb_thread_concurrency=16

sort_buffer_size = 128K

join_buffer_size = 128K

max_heap_table_size = 32M

sync_binlog = 1

binlog_cache_size = 4M

expire_logs_days = 1

read_buffer_size = 1M

read_rnd_buffer_size = 16M

bulk_insert_buffer_size = 64M

innodb_write_io_threads=8

innodb_read_io_threads=8

thread_cache_size = 200

 

四 测试结果

4.1 MySQL官方版

MySQL并发测试_第1张图片
MySQL并发测试_第2张图片

MySQL官方版测试结果说明:mysql官方版100并发的时候TPS在5300左右,TPS从100并发到400并发没有明显的下降波动.从500并发以后开始逐步降低。测试4000并发完毕,TPS下降到600。从100并发到4000并发,TPS从5300下降到600。并发越大,下降的越明显。

 

五 特别说明

Ø  sysbench发起端都在数据库服务器本身。

Ø  主机磁盘做成了RAID5,对性能有较大影响,随机读写的速度很低,详细见磁盘测试报告。

Ø  网卡,由于主机是千兆的电口,测试过程中,经常出现网络跑满的情况,对性能也有较大影响。

你可能感兴趣的:(mysql)