Sysbench is an open-source, modular, and multi-threaded performance testing tool that runs on multiple platforms. It can test database performance in areas such as CPU, memory, threads, and I/O. This topic describes a performance test of PolarDB-X 1.0 in online transactional processing (OLTP) and SELECT scenarios.
Test design
- The following instance types are used in this test:
- PolarDB-X 1.0 instance types:
- Starter Edition 8-core 32 GB
- Standard Edition 16-core 64 GB
- Enterprise Edition 32-core 128 GB
- Enterprise Edition 64-core 256 GB
- One ECS stress testing instance: 32-core, 64 GB, compute network-enhanced, running the Aliyun Linux 2.1903 64-bit operating system
- Twelve RDS instances: 16-core, 64 GB, MySQL 5.7, Dedicated
Note PolarDB-X 1.0, ECS, and RDS instances are in the same zone and VPC. - PolarDB-X 1.0 instance types:
- Create a database in the PolarDB-X 1.0 console. Use the horizontal splitting mode and select the 12 RDS instances.
- Install Sysbench on the ECS instance and prepare 160 million data records. For more information about how to use Sysbench, see the Sysbench user guide.
| Parameter | Description |
test='/usr/local/share/sysbench/oltp_drds.lua' |
The path to the data for the OLTP test scenario. |
test='/usr/local/share/sysbench/select.lua' |
The path to the data for the SELECT scenario. |
mysql_table_options='dbpartition by hash(`id`) tbpartition by hash(id) tbpartitions 2' |
PolarDB-X 1.0 database sharding and table sharding syntax. This indicates two shard tables for each shard database. |
oltp-table-size=160000000 |
Prepare 160 million data records. |
oltp_auto_inc=off |
Disable the auto-increment primary key. |
oltp_skip_trx=on |
Enable the setting to skip transactions. |
sysbench --test='/usr/local/share/sysbench/oltp_drds.lua' --oltp_tables_count=1 --report-interval=5 --oltp-table-size=160000000 --mysql-user=**** --mysql-password=**** --mysql-table-engine=innodb --rand-init=on --mysql-host=**** --mysql-port=3306 --mysql-db=**** --max-requests=0 --oltp_skip_trx=on --oltp_auto_inc=off --oltp_secondary --oltp_range_size=5 --mysql_table_options='dbpartition by hash(`id`) tbpartition by hash(id) tbpartitions 2' --num-threads=200 --max-time=300 run
OLTP test results

| Specification | Concurrency | Reads/writes per second |
| Starter Edition 8-core 32 GB | 100 | 20807.12 |
| Standard Edition 16-core 64 GB | 230 | 49667.48 |
| Enterprise Edition 32-core 128 GB | 450 | 90693.70 |
| Enterprise Edition 64-core 256 GB | 900 | 177506.48 |
SELECT test results

| Specification | Concurrency | Reads/writes per second |
| Starter Edition 8-core 32 GB | 200 | 41401 |
| Standard Edition 16-core 64 GB | 300 | 98182.26 |
| Enterprise Edition 32-core 128 GB | 600 | 180500.00 |
| Enterprise Edition 64-core 256 GB | 1200 | 366863.48 |
OLTP scenario test script details
pathtest = string.match(test, "(.*/)")
if pathtest then
dofile(pathtest .. "common.lua")
else
require("common")
end
function get_range_end(start)
return start + oltp_range_size - 1
end
function thread_init(thread_id)
set_vars()
if (((db_driver == "mysql") or (db_driver == "attachsql")) and mysql_table_engine == "myisam") then
local i
local tables = {}
for i=1, oltp_tables_count do
tables[i] = string.format("sbtest%i WRITE", i)
end
begin_query = "LOCK TABLES " .. table.concat(tables, " ,")
commit_query = "UNLOCK TABLES"
else
begin_query = "BEGIN"
commit_query = "COMMIT"
end
end
function event(thread_id)
local rs
local i
local table_name
local range_start
local c_val
local pad_val
local query
table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
if not oltp_skip_trx then
db_query(begin_query)
end
if not oltp_write_only then
for i=1, oltp_point_selects do
rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size))
end
if oltp_range_selects then
for i=1, oltp_simple_ranges do
range_start = sb_rand(1, oltp_table_size)
rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. get_range_end(range_start))
end
for i=1, oltp_sum_ranges do
range_start = sb_rand(1, oltp_table_size)
rs = db_query("SELECT SUM(K) FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. get_range_end(range_start))
end
for i=1, oltp_order_ranges do
range_start = sb_rand(1, oltp_table_size)
rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. get_range_end(range_start) .. " ORDER BY c")
end
for i=1, oltp_distinct_ranges do
range_start = sb_rand(1, oltp_table_size)
rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. get_range_end(range_start) .. " ORDER BY c")
end
end
end
if not oltp_read_only then
for i=1, oltp_index_updates do
rs = db_query("UPDATE " .. table_name .. " SET k=k+1 WHERE id=" .. sb_rand(1, oltp_table_size))
end
for i=1, oltp_non_index_updates do
c_val = sb_rand_str("###########-###########-###########-###########-###########-###########-###########-###########-###########-###########")
query = "UPDATE " .. table_name .. " SET c='" .. c_val .. "' WHERE id=" .. sb_rand(1, oltp_table_size)
rs = db_query(query)
if rs then
print(query)
end
end
for i=1, oltp_delete_inserts do
i = sb_rand(1, oltp_table_size)
rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i)
c_val = sb_rand_str([[
###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
pad_val = sb_rand_str([[
###########-###########-###########-###########-###########]])
rs = db_query("INSERT INTO " .. table_name .. " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, sb_rand(1, oltp_table_size) , c_val, pad_val))
end
end -- oltp_read_only
if not oltp_skip_trx then
db_query(commit_query)
end
end
该文章对您有帮助吗?