数据库小计

PolarDB-X 1.0 Sysbench测试说明

2022-03-29  本文已影响0人  祁小彬

Sysbench是一款开源的、模块化的、跨平台的多线程性能测试工具,可以执行数据库在CPU、内存、线程、IO等方面的性能测试。本文将验证PolarDB-X 1.0在Sysbench OLTP和SELECT场景中的性能表现。

测试设计

测试参数说明

| test='/usr/local/share/sysbench/oltp_drds.lua' | OLTP测试场景数据的路径。 |
| test='/usr/local/share/sysbench/select.lua' | SELECT场景数据的路径。 |
| mysql_table_options='dbpartition by hash(id) tbpartition by hash(id) tbpartitions 2' | PolarDB-X 1.0分库分表语法,表示每个分库2张分表。 |
| oltp-table-size=160000000 | 准备1.6亿数据。 |
| oltp_auto_inc=off | 关闭自增主键。 |
| oltp_skip_trx=on | 开启跳过事务设置。 |

测试语句范例:

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测试结果

image.png
规格 并发数 每秒 read/write 数量
入门版 8C32G 100 20807.12
标准版 16C64G 230 49667.48
企业版 32C128G 450 90693.70
企业版 64C256G 900 177506.48

SELECT测试结果

[图片上传失败...(image-7260bf-1648453169649)] image.png
规格 并发数 每秒 read/write 数量
入门版 8C32G 200 41401
标准版 16C64G 300 98182.26
企业版 32C128G 600 180500.00
企业版 64C256G 1200 366863.48

OLTP场景测试脚本详情

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

上一篇下一篇

猜你喜欢

热点阅读