浅谈MYSQL5.7以及MariaDB10.3小差异

本文对比了MySQL 5.7与MariaDB 10.3在并发能力和性能上的差异。通过调整最大连接数并使用mysqlslap工具进行测试,发现MariaDB在并发性能上显著优于MySQL,最高可达2倍提升。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导读浅谈MYSQL5.7以及MariaDB10.3小差异

二者基础架构是一样的,默认变量参数数据也大同小异

mysql> SHOW VARIABLES LIKE 'max_con%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 100 |
| max_connections | 151 |
+--------------------+-------+
2 rows in set (0.01 sec)

因为初始连接值太低,不适合高并发能力,所以提高到2000来做测试,这时候就有差异了

差异一,修改max_connetctions方式

Mysql

必须修改linux系统本身的ulimit参数
/ 系统默认参数

[root@Centos7 ~]# ulimit -a | grep open
open files (-n) 1024

/修改limit参数

vim /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535

/ 修改MYsql配置文件

vim /etc/my.cnf
[mysqld]
max_connections=2000

systemctl restart mysqld

/ 查看变量,修改成功

mysql> SHOW VARIABLES LIKE 'max_con%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 100 |
| max_connections | 2000 |
+--------------------+-------+
2 rows in set (0.03 sec)

MariaDB

直接修改参数重启即可
/ 修改MYsql配置文件

vim /etc/my.cnf
[mysqld]
max_connections=2000

systemctl restart mysqld

/ 查看变量,修改成功

mysql> SHOW VARIABLES LIKE 'max_con%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 100 |
| max_connections | 2000 |
+--------------------+-------+
2 rows in set (0.03 sec)

差异二,并发能力强度对比

测试环境

mysqlsap工具
同时并发1000个连接
分别并发1000个连接
同时并发1000个连接

/ mysql的并发

[root@Centos7 ~]# mysqlslap -a -c 1000
Benchmark
Average number of seconds to run all queries: 40.796 seconds
Minimum number of seconds to run all queries: 40.796 seconds
Maximum number of seconds to run all queries: 40.796 seconds
Number of clients running queries: 1000
Average number of queries per client: 0

/ MariaDB的并发

[root@Centos7 ~]# mysqlslap -a -c 1000
Benchmark
Average number of seconds to run all queries: 19.427 seconds
Minimum number of seconds to run all queries: 19.427 seconds
Maximum number of seconds to run all queries: 19.427 seconds
Number of clients running queries: 1000
Average number of queries per client: 0

分别并发1000个连接

/ Mysql先并发1000个连接

[root@Centos7 ~]# mysqlslap -a -c 1000
Benchmark
Average number of seconds to run all queries: 28.096 seconds
Minimum number of seconds to run all queries: 28.096 seconds
Maximum number of seconds to run all queries: 28.096 seconds
Number of clients running queries: 1000
Average number of queries per client: 0

/ MariaDB 后续并发1000个连接

[root@Centos7 ~]# mysqlslap -a -c 1000
Benchmark
Average number of seconds to run all queries: 14.042 seconds
Minimum number of seconds to run all queries: 14.042 seconds
Maximum number of seconds to run all queries: 14.042 seconds
Number of clients running queries: 1000
Average number of queries per client: 0

总结:由此比对得出同时并发时,mysql跟MariaDB差距太大,可以达到2倍差距,分开并发MariaDB比mysql提高60%性能

原文来自:https://www.linuxprobe.com/mysql5-7-mariadb10-3.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值