Sysbenchは、データベース、CPU、メモリ、スレッド、およびI/Oのパフォーマンスをテストするために使用される、オープンソース、モジュラー、クロスプラットフォーム、およびマルチスレッドのツールです。 現在、SysbenchはMySQL、Oracle、およびPostgreSQLデータベースでサポートされています。 以下では、オンライントランザクション処理 (OLTP) シナリオおよびSELECTシナリオでSysbenchを使用して、PolarDB-X 1.0インスタンスのパフォーマンスをテストします。
テストデザイン
- PolarDB-X 1.0インスタンス、Elastic Compute Service (ECS) インスタンス、およびApsaraDB RDS for MySQLインスタンスを購入します。
- 次の仕様の4つのPolarDB-X 1.0インスタンス: Starter Editionは8コア32 GB、Standard Editionは16コア64 GB、Enterprise Editionは32コア128 GB、Enterprise Editionは64コア256 GB
- ストレステストマシンとしての1つのECSインスタンス: 32コア64 GB、Aliyun Linux 2.1903 64ビット、および拡張コンピューティングネットワーク
- 12のApsaraDB RDS for MySQLインスタンス: 16コア64 GB、MySQL 5.7、および専用インスタンスタイプ
すべてのPolarDB-X 1.0インスタンス、ECSインスタンス、およびApsaraDB RDS for MySQLインスタンスは、同じゾーンおよび同じVPCにあります。
- PolarDB-X 1.0コンソールで水平パーティショニングを使用してデータベースシャードを作成し、購入した12のApsaraDB RDS for MySQLインスタンスを選択します。
- ECSインスタンスにSysbenchをインストールし、160万行のデータを準備します。 Sysbenchの詳細については、「Sysbenchユーザーガイド」をご参照ください。
テストパラメータ
-- test='/usr/local/share/sysbench/oltp_drds.lua' // OLTPシナリオではoltp_drds.luaを使用し、selectシナリオではSELECT. luaを使用します。
-- mysql_table_options='dbpartition by hash('id') tbpartition by hash(id) tbpartitions 2 '// PolarDB-X 1.0インスタンスでのデータベースおよびテーブルシャーディングの構文。 この例では、データベースシャードごとに2つのテーブルシャードが作成されます。
-- oltp-table-size=160000000 // 160万行のデータを準備します。
-- oltp_auto_inc=off // 自動インクリメント主キーを無効にします。
-- oltp_skip_trx=on // トランザクションをスキップします。
-- oltp_secondary // 主キーの競合を防ぐために、id列を非主キー列に設定します。
-- oltp_range_size=5 // 5つの連続した値を指定します。 したがって、5つのシャードがクエリに関与します。
-- rand-init=on // Sysbenchを有効にして、各テストテーブルにランダムデータを入力します。
-- num-threads=200 // 各シナリオの同時スレッド数。 詳細については、次の表をご参照ください。サンプルテスト文: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=indb-ホスト3306 -- mysql-要求=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 runOLTPテスト結果
| インスタンス仕様 | 同時スレッド数 | 1秒あたりの読み取り /書き込み操作数 |
| 8コア32 GBスターターエディション | 100 | 20807.12 |
| 16コア64 GBスタンダードエディション | 230 | 49667.48 |
| 32コア128 GB for Enterprise Edition | 450 | 90693.70 |
| 64コア256 GB for Enterprise Edition | 900 | 177506.48 |
SELECTテスト結果
| インスタンス仕様 | 同時スレッド数 | 1秒あたりの読み取り /書き込み操作数 |
| 8コア32 GBスターターエディション | 200 | 41401 |
| 16コア64 GBスタンダードエディション | 300 | 98182.26 |
| 32コア128 GB for Enterprise Edition | 600 | 180500.00 |
| 64コア256 GB for Enterprise Edition | 1200 | 366863.48 |
OLTPシナリオのテストスクリプト
pathtest = string.match(test, "(.*/)")
pathtestの場合
dofile(pathtest .. "common.lua")
else
require("common")
終了
関数get_range_end(start)
return start + oltp_range_size - 1
終了
関数thread_init(thread_id)
set_vars()
if (((db_driver == "mysql") または (db_driver == "attachsql")) およびmysql_table_engine == "myisam")
ローカルi
local tables = {}
i=1の場合、oltp_tables_count
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"
終了
終了
関数イベント (thread_id)
ローカルrs
ローカルi
ローカルtable_name
ローカルrange_start
ローカルc_val
ローカルpad_val
ローカルクエリ
table_name = "sbtest" .. sb_rand_uniform(1, oltp_tables_count)
oltp_skip_trxでない場合は、
db_query(begin query)
end
oltp_write_onlyでない場合は、
i=1の場合、oltp_point_selectsは
rs = db_query("SELECT c FROM" .. table_name .." WHERE id=".. sb_rand(1, oltp_table_size)
end
oltp_range_selectsの場合、
i=1の場合、oltp_simple_rangesは
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
i=1の場合、oltp_sum_rangesは
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
i=1の場合、oltp_order_rangesは
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
i=1の場合、oltp_distinct_rangesは
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
oltp_read_onlyでない場合は、
i=1の場合、oltp_index_updatesは
rs = db_query("UPDATE" .. table_name .. "SET k=k + 1 WHERE id=" .. sb_rand(1, oltp_table_size)
end
i=1の場合、oltp_non_index_updatesは
c_val = sb_rand_str("#########################################################################-######)-##-#
query = "UPDATE" .. table_name .. "SET c='" .. c_val .. "'WHERE id=" .. sb_rand(1, oltp_table_size)
rs = db_query (クエリ)
もしrsなら
プリント (クエリ)
end
end
i=1の場合、oltp_delete_insertsは
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
oltp_skip_trxでない場合は、
db_query(commit_query)
終了
終了