You need to enable JavaScript to run this app.
文档中心
云数据库 PostgreSQL 版

云数据库 PostgreSQL 版

复制全文
下载 pdf
性能白皮书
测试方法
复制全文
下载 pdf
测试方法
本文介绍云数据库 PostgreSQL 版性能测试所使用的测试环境、测试工具、测试步骤以及测试指标。​
测试环境​
  • 地域:华北 2(北京)自动驾驶云,节点池中的机型为S20​
  • 可用区:可用区 B​
  • 客户端云服务器:计算型c3i 32 vCPU 64 GiB,规格代码:ecs.c3i.8xlarge​
  • 操作系统镜像:CentOS 8.3 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工具加载测试数据,具体命令如下:​
​
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=32 \​
--oltp-table-size=10000000 \​
--time=180 \​
--max-requests=0 \​
--threads=20 \​
--report-interval=5 \​
--forced-shutdown=1 \​
prepare​
​
2.启动测试​
执行以下命令,进行性能测试。在测试过程中,会调整 threads 参数,找到最优性能的 threads 并记录结果。​
​
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=32 \​
--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=32 \​
--oltp-table-size=10000000 \​
--time=180 \​
--max-requests=0 \​
--threads=200 \​
--report-interval=5 \​
--forced-shutdown=1 \​
cleanup​
​
测试指标​
  • TPS​
  • Transactions Per Second,数据库每秒执行的事务数。​
  • QPS​
  • Queries Per Second,数据库每秒执行的 SQL 数,包含 Read、Write 和 Other 类别。​
测试结果​
关于测试结果的详细信息,请参见性能测试结果。​
​
最近更新时间:2026.06.04 15:05:44
这个页面对您有帮助吗?
有用
有用
无用
无用