更新时间:2023-12-12 GMT+08:00
分享

测试方法

云数据库 GaussDB(for MySQL)是最新一代企业级高扩展海量存储云原生数据库,完全兼容MySQL。采用计算存储分离架构,128TB的海量存储,数据0丢失,既拥有商业数据库的高可用和性能,又具备开源低成本效益。

测试环境

GaussDB(for MySQL)测试环境如下:

  • 区域:华东-上海一(其他区域与可用分区情况可参见表1)。
  • 可用分区:可用区1。
  • 测试用云数据库 GaussDB(for MySQL)实例为一主一只读集群。
  • 弹性云服务器(Elastic Cloud Server,简称ECS):ECS与数据库节点在同一个可用区,规格建议选择通用计算增强型 | c7.8xlarge.4 | 32vCPUs | 128GB,操作系统镜像使用CentOS 7.6 64bit位版本。由于压测工具需要安装额外的编译工具,建议ECS绑定弹性IP。
    表1 区域与可用分区对应表

    区域

    可用分区

    华北-北京四

    可用区2

    上海一

    可用区1

    广州

    可用区6

测试工具

表2 测试工具

工具名称

描述及下载方式

版本号

Sysbench

Sysbench是一款基于LuaJIT的,模块化多线程基准测试工具,常用于数据库基准测试。通过内置的数据库测试模型,采用多线程并发操作来评估数据库的性能,请单击此处了解Sysbench更多详情。

Sysbench版本1.0.18

具体的安装命令如下:

登录ecs,执行以下命令,下载sysbench安装包。

wget https://codeload.github.com/akopytov/sysbench/zip/refs/tags/1.0.18

yum install -y autoconf libtool mysql mysql-devel vim unzip

请执行以下命令,解压安装包。

unzip 1.0.18

请执行以下命令,执行安装命令。

cd sysbench-1.0.18

./autogen.sh

./configure

make

make install

测试步骤

以下测试均在ECS上执行,请根据实际信息,替换线程并发数、连接IP、连接端口、用户名称与用户密码。

性能测试数据(包含SQL语句)都由sysbench工具自动生成。

压测机ECS与实例在同一可用区。

为了使sysbench 在大并发场景(512, 1000)正常运行,需要将参数 max_prepared_stmt_count 调大,建议改为 1048576(过多的prepare语句会占用大量内存空间进而导致OOM,4U16G规格该值建议设置为400000)。

为了提升sysbench压测的性能,建议检查以下参数并修改(以下参数修改并不影响产品功能及可靠性)并重启实例。

log-bin: OFF

只写性能测试:

  1. 导入数据。

    1. 执行以下命令,创建测试数据库“sbtest”

      mysql -u<user>-P <port> -h <host> -p -e "create database sbtest"

    2. 执行以下命令,将测试背景数据导入至“sbtest”数据库。

      sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=25000 --tables=250 --threads=<thread_num> oltp_common prepare

  2. 执行以下命令,测试性能。测试过程将持续10分钟。

    sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=25000 --tables=250 --time=600 --threads=<thread_num> --percentile=95 --report-interval=1 oltp_write_only run

  3. 执行以下命令,清理数据。

    sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=25000 --tables=250 --threads=<thread_num> oltp_common cleanup

只读性能测试:

  1. 导入数据。

    1. 执行以下命令,创建测试数据库“sbtest”

      mysql -u<user> -P<port> -h<host> -p -e "create database sbtest"

    2. 执行以下命令,将测试背景数据导入至“sbtest”数据库。

      sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=25000 --tables=250 --threads=<thread_num> oltp_common prepare

  2. 执行以下命令,测试纯读性能,测试过程将持续10分钟。

    sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=25000 --tables=250 --time=600 --range_selects=0 --skip-trx=1 --threads=<thread_num> --percentile=95 --report-interval=1 oltp_read_only run

  3. 执行以下命令,清理数据。

    sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=25000 --tables=250 --threads=<thread_num> oltp_common cleanup

读写混合性能测试:

  1. 导入数据。

    1. 执行以下命令,创建测试数据库“sbtest”

      mysql -u<user> -P<port> -h <host> -p -e "create database sbtest"

    2. 执行以下命令,将测试背景数据导入至“sbtest”数据库。

      sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=250000 --tables=25 --threads=<thread_num> oltp_common prepare

  2. 执行以下命令,测试读写混合性能,测试过程将持续10分钟。

    sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=250000 --tables=25 --time=600 --threads=<thread_num> --percentile=95 --report-interval=1 oltp_read_write run

  3. 执行以下命令,清理数据。

    sysbench --db-driver=mysql --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=sbtest --table_size=250000 --tables=25 --threads=<thread_num> oltp_common cleanup

测试指标

  • TPS:Transaction Per Second,数据库每秒执行的事务数。
  • QPS:Query Per Second,数据库每秒执行的SQL语句数,包含insert、select、update、delete等。
分享:

    相关文档

    相关产品