我刚刚使用mysqlslap
对RDS上的MySQL服务器和EC2实例上的MySQL服务器进行了基准测试。
以下是我的参数和测试结果:
5.6.44
db.t3.large
t3.large
General Purpose (SSD)
amzn2-ami-hvm-2.0.20190618-x86_64-gp2
default.mysql5.6
No
tokyo
tokyo
enabled
100GB
100GB
disabled
RDS和EC2实例上的两个MySQL服务器都是新创建的。在运行mysqlslap
之前,它们不包含任何数据。
EC2实例也是新创建的。我只在上面安装了MySQL服务器。我没有更改实例上的其他任何内容。
mysqlslap
是从我本地的MacBook Pro运行的。
通过运行sudo su &&
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm &&
rpm -ivh mysql-community-release-el6-5.noarch.rpm &&
yum install mysql-server &&
/etc/init.d/mysqld start
这是基准测试结果:
# MySQL on RDS benchmark testing result:
mysqlslap --host=loadtest.xxxxxxxxx.xx-xx-x.rds.amazonaws.com \
--user=myusername \
--password=mypassword \
--create-schema=load_test_table \
-vv \
--concurrency=50 --iterations=5 \
--auto-generate-sql
Building Create Statements for Auto
Building Query Statements for Auto
Parsing engines to use.
Starting Concurrency Test
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Generating stats
Benchmark
Average number of seconds to run all queries: 4.362 seconds
Minimum number of seconds to run all queries: 3.134 seconds
Maximum number of seconds to run all queries: 7.581 seconds
Number of clients running queries: 50
Average number of queries per client: 0
# MySQL on EC2 benchmark testing result:
mysqlslap --host=<ec2's ip address> \
--user=myusername \
--password=mypassword \
--create-schema=load_test_table \
-vv \
--concurrency=50 --iterations=5 \
--auto-generate-sql
Building Create Statements for Auto
Building Query Statements for Auto
Parsing engines to use.
Starting Concurrency Test
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Loading Pre-data
Generating primary key list
Generating stats
Benchmark
Average number of seconds to run all queries: 2.196 seconds
Minimum number of seconds to run all queries: 2.000 seconds
Maximum number of seconds to run all queries: 2.445 seconds
Number of clients running queries: 50
Average number of queries per client: 0
运行mysqlslap
时,两个MySQL服务器上的CPU信用余额均大于0。因此,不存在用尽CPU信用余额的问题。
从基准测试结果中可以看到,RDS上的MySQL服务器运行速度是EC2实例上的MySQL服务器运行速度的两倍。
为什么会这样?
我是否可以配置任何参数以使RDS上的MySQL服务器性能与EC2实例上的一样好?
Here是EC2 MySQL的SHOW GLOBAL VARIABLES;
的输出。
Here是RDS MySQL的SHOW GLOBAL VARIABLES;
的输出。
Here是运行3个基准测试后EC2 MySQL的SHOW GLOBAL STATUS;
的结果。
here是运行3个基准测试后RDS MySQL的SHOW GLOBAL STATUS;
的结果。
我发现在RDS MySQL上禁用sync_binlog
可以提高其性能。但是这样做之后,RDS MySQL的性能仍然比EC2 MySQL差。