You need to enable JavaScript to run this app.
导航

测试方法

最近更新时间2022.12.14 21:50:11

首次发布时间2022.11.07 20:07:17

本文介绍云数据库 PostgreSQL 版性能测试所使用的测试环境、测试工具、测试步骤以及测试指标。

测试环境

  • 地域:华东 2(上海)
  • 可用区:可用区 A
  • 云服务器:通用平衡增强型 g1ie 58C224G,规格代码:ecs.g1ie.14xlarge
  • 操作系统镜像:CentOS 7.9 64 位版本

说明

由于压测工具需要安装额外的编译工具,建议使用 ECS 绑定弹性 IP。

测试工具

SysBench 是一个跨平台且支持多线程的模块化基准测试工具,用于评估系统在运行高负载的数据库时相关核心参数的性能表现,快速了解数据库系统的性能。

下载安装测试工具

wget -c https://github.com/akopytov/sysbench/archive/1.0.12.zip
yum install make automake libtool pkgconfig libaio-devel postgresql-devel
unzip 1.0.12.zip
cd sysbench-1.0.12
# sysbench 默认支持 mysql,此处需要配置支持 pgsql。
./autogen.sh
./configure --with-pgsql --without-mysql
make
make install

测试步骤

请根据实际信息,替换命令中的数据库、用户名、密码、端口、主机域名等信息。本次性能测试时长统一为 180 秒。

1.初始化测试数据

根据目标库大小初始化测试数据,具体命令如下:

sysbench ./tests/include/oltp_legacy/oltp.lua \
--db-driver=pgsql \
--pgsql-db=sbtest \
--pgsql-user=<username> \
--pgsql-password=<password> \
--pgsql-port=5432 \
--pgsql-host=<host> \
--oltp-tables-count=64 \
--oltp-table-size=10000000 \
--time=180 \
--max-requests=0 \
--threads=20 \
--report-interval=5 \
--forced-shutdown=1 \
prepare

2.启动测试

执行以下命令,进行性能测试。

sysbench ./tests/include/oltp_legacy/oltp.lua \
 --db-driver=pgsql \
 --pgsql-db=sbtest \
 --pgsql-user=<username> \
 --pgsql-password=<password> \
 --pgsql-port=5432 \
 --pgsql-host=<host> \
 --oltp-tables-count=64 \
 --oltp-table-size=10000000 \
 --time=180 \ 
 --max-requests=0 \
 --threads=64 \
 --report-interval=5 \
 --forced-shutdown=1 \
 run

3.清理测试数据

性能测试结束后,使用以下命令清理测试数据。

sysbench ./tests/include/oltp_legacy/oltp.lua \
 --db-driver=pgsql \
 --pgsql-db=sbtest \
 --pgsql-user=<username> \
 --pgsql-password=<password> \
 --pgsql-port=5432 \
 --pgsql-host=<host> \
 --oltp-tables-count=64 \
 --oltp-table-size=10000000 \
 --time=180 \
 --max-requests=0 \
 --threads=200 \
 --report-interval=5 \
 --forced-shutdown=1 \
 cleanup

测试指标

  • TPS
    Transactions Per Second,数据库每秒执行的事务数,每个事务中包含 18 条 SQL 语句。

  • QPS
    Queries Per Second,数据库每秒执行的 SQL 数,包含 Read、Write 和 Other 类别。