Huawei Cloud Yaoyun Server L インスタンスに基づくパフォーマンス評価 | MySQL のパフォーマンス評価

Huawei Cloud Yaoyun Server L インスタンスに基づくパフォーマンス評価 | MySQL のパフォーマンス評価

1. テスト環境の紹介

  クラウド コンピューティングの時代がさらに深まるにつれ、ビジネス運営と革新的な開発をサポートするために、使いやすく高出力で効率的なクラウド コンピューティング インフラストラクチャ製品を必要とする中小企業や開発者がますます増えています。この需要に基づいて、Huawei Cloud は Huawei Cloud サーバー インスタンスの新製品を発売しました。
  Huawei Cloudサーバーには、インテリジェントでスタックしない、手頃な価格で使いやすい、使い始めやすい、安心して管理できるという4つの利点があるため、クラウドへの迅速なアクセスが可能になります。
  この記事では、Huawei Cloud Yaoyun Server L インスタンスMySQL サービスのパフォーマンス ベンチマーク テストを実行します。
  購入方法公式チャンネルリンク - Huawei Cloud Server Lインスタンス
ここに画像の説明を挿入します
 
ここに画像の説明を挿入します
 
ここに画像の説明を挿入します
 
ここに画像の説明を挿入します
 

2. テスト環境のセットアップ

モデル オペレーティングシステムの例 CPU メモリ ハードディスク MySQLのバージョン
Yunyao クラウド サーバー L インスタンス Huawei Cloud EulerOS 2.0 2コア 2G システムディスク 40 GiB MySQL8.0.33

  オペレーティング システムの選択: Huawei Cloud EulerOS(略称 HCE OS) は、ファーウェイのオープン ソース コミュニティ openEuler 上に構築された Linux オペレーティング システムです。アプリケーションを開発および実行するためのクラウド ネイティブで高性能、安全かつ安定した実行環境を提供し、企業顧客と開発者を支援します。クラウドへの迅速な移行、イノベーション。

   MySQL の主なパフォーマンス指標は次のとおりです。
   ● TPS: 、つまり、成功数に基づいたTransactions Per Second1 秒あたりにデータベースによって実行されるトランザクションの数です。    ● : 、つまり 1 秒あたりのデータベース実行数(挿入、選択、更新、削除などを含む)。    ● : 、応答時間。平均応答時間、最小応答時間、最大応答時間、各応答時間のクエリの割合が含まれます。ほとんどの場合、これによって欠点が決まるため、注目する必要があるのは最大応答時間の最初の 95 ~ 99% です。    ● : 同時実行性、1 秒あたりに処理できるクエリ リクエストの数。commit
QPSQueries Per SecondSQL
RTResponse Time
Concurrency Threads

このパフォーマンス テストは、主にスループットとレイテンシの 2 つの指標に焦点を当てています。

   オペレーティングシステムHuawei Cloud EulerOSにデプロイメントをインストールしますMySQL 8.0.3

[root@hcss-ecs-3501 ~]# yum install -y gcc-c++ openssl  openssl-devel make bison ncurses-devel
[root@hcss-ecs-3501 ~]# yum install -y libtirpc libtirpc-devel rpcgen m4
[root@hcss-ecs-3501 ~]# tar xvf cmake-3.25.3.tar.gz 
[root@hcss-ecs-3501 ~]# cd cmake-3.25.3
[root@hcss-ecs-3501 ~]# ./bootstrap 
[root@hcss-ecs-3501 ~]# make && make install 
[root@hcss-ecs-3501 ~]# ln -s /usr/local/bin/cmake /usr/bin/
[root@hcss-ecs-3501 ~]# cmake --version
cmake version 3.25.3
[root@hcss-ecs-3501 ~]# tar xvf boost_1_77_0.tar.gz 
[root@hcss-ecs-3501 ~]# cd boost_1_77_0
[root@hcss-ecs-3501 boost_1_77_0]# ./bootstrap.sh --prefix=/usr/local/
[root@hcss-ecs-3501 boost_1_77_0]# ./b2 install


[root@hcss-ecs-3501 ~]# tar xvf mysql-8.0.33.tar.gz 
[root@hcss-ecs-3501 ~]# cd mysql-8.0.33
[root@hcss-ecs-3501 mysql-8.0.33]# mkdir build
[root@hcss-ecs-3501 mysql-8.0.33]# cd build/
[root@hcss-ecs-3501 mysql-8.0.33]# cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/var/lib/mysql \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost

[root@hcss-ecs-3501 mysql-8.0.33]# make && make install

   MySQL を構成します。

[root@hcss-ecs-3501 ~]# groupadd mysql
[root@hcss-ecs-3501 ~]# useradd -r -g mysql -s /bin/false mysql
[root@hcss-ecs-3501 ~]# cd /usr/local/mysql
[root@hcss-ecs-3501 mysql]# chown -R mysql:mysql .
[root@hcss-ecs-3501 mysql]# bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql

   起動時に MySQL が自動的に起動するように設定します。

[root@hcss-ecs-3501 mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@hcss-ecs-3501 mysql]# chkconfig --add mysql
[root@hcss-ecs-3501 mysql]# chkconfig mysql on
cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
log-error=/var/lib/mysql/mysql.log
pid-file=/var/lib/mysql/mysql.pid
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_connections=1024	# 设置最大连接数
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/lib/mysql/mysql.log
pid-file=/var/lib/mysql/mysql.pid
socket=/tmp/mysql.sock

   セキュリティを構成します。

/usr/local/mysql/bin/mysql_secure_installation
ln -s /usr/local/mysql/bin/mysqlslap /usr/bin/
ln -s /usr/local/mysql/bin/mysql /usr/bin/

mysql -u root -p
Enter password: 

# 查看最大连接数
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 1024  |
+-----------------+-------+
1 row in set (0.01 sec)

  オペレーティング システムは最適化および構成されておらず、デフォルト構成が使用されます。MySQL の最大接続数が変更されました。

3. テストツール

3.1. mysqlslap

  Mysqlslap は MySQL によって公式に提供されており、さまざまなエンジンのパフォーマンス テストを提供します。mysqlslap のテストプロセスは sysbench に比べて比較的単純で、1 つのコマンドですべてのプロセスを完了できます。

mysqlslap \
--defaults-file=/etc/my.cnf  \
--concurrency=100,1000 \
--iterations=3 \
--number-int-cols=20 \
--number-char-cols=30 \
--auto-generate-sql \
--auto-generate-sql-add-autoincrement \
--auto-generate-sql-load-type=mixed \
--engine=innodb \
--number-of-queries=10000 \
--create-schema=mydb \
-uroot \
-p123456

  読み取りおよび書き込み同時実行テストを 2 回シミュレートします。1 回目は 100、2 回目は 1000、テスト テーブルには 20 の init フィールド、30 の char フィールドが含まれ、毎回 10,000 のクエリ リクエストが実行されます。テストエンジンはinnodbです。

   ● --concurrency: 同時実行性、つまり、同時にコマンドを実行するためにシミュレートされるクライアントの数。--delimiterカンマまたはパラメータで指定した値を区切り文字として複数の値を指定できます。
   ● --iterations: テスト実行の反復回数。
   ● --number-int-cols: 自動生成されたテスト テーブルに含まれる数値列の数。デフォルトは 1。
   ● --number-char-cols: 自動生成されるテストテーブルに含まれる文字型列の数。デフォルトは 1 です。
   ● --auto-generate-sql: テストテーブルとデータを自動生成します。このコマンドの効果は、sysbenchコマンドの効果と似ていますprepare
   ● --auto-generate-sql-add-autoincrement:auto_increment列を追加します。
生成された特定のスクリプトを確認したい場合は、–only-printコマンドを使用して、実際にテスト ステートメントを実行せずにテスト ステートメントのみを出力できます。
   ● --engine: テストテーブルの作成に使用されるストレージエンジン。複数指定可能です。
   ● --number-of-queries: テスト クエリの総数 (同時顧客数 × 顧客ごとのクエリ数)。
   ● --create-schema: テスト用、 schemaMySQL のデータベース名schemaですdatabase(実際にはライブラリは生成されません)。
   ● -uroot -p123456: MySQL アカウントとパスワードを設定します。

mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
	Running for engine innodb
	Average number of seconds to run all queries: 1.863 seconds
	Minimum number of seconds to run all queries: 1.777 seconds
	Maximum number of seconds to run all queries: 1.945 seconds
	Number of clients running queries: 100
	Average number of queries per client: 100

Benchmark
	Running for engine innodb
	Average number of seconds to run all queries: 2.160 seconds
	Minimum number of seconds to run all queries: 2.077 seconds
	Maximum number of seconds to run all queries: 2.223 seconds
	Number of clients running queries: 1000
	Average number of queries per client: 10

  テスト結果の説明:
  Innodb は、初めて追加のクエリを開始するために 100 クライアントに対して 1.863/s を使用し、2 回目の追加クエリを開始するために 1000 クライアントに対して 2.160/s を使用します。

3.2. システムベンチ

   sysbench は主に、さまざまなシステム パラメーターの下でデータベースの負荷を評価およびテストするために使用されます。OLTP ベンチマークは、/usr/share/sysbench/ディレクトリ内の Lua スクリプトを通じて実行する必要があります。たとえば、oltp_read_only.luaスクリプトは読み取り専用テストを実行します。
   sysbench は、コマンドの実行時に独自の Lua スクリプトを指定することでテストをカスタマイズすることもできます。

   インストールツール:

[root@hcss-ecs-3501 ~]# yum install m4 autoconf automake libtool -y

[root@hcss-ecs-3501 ~]# find /  -name 'libmysqlclient*' 
/root/mysql-8.0.33/packaging/deb-in/libmysqlclient-dev.lintian-overrides.in
/root/mysql-8.0.33/packaging/deb-in/libmysqlclient21.install.in
/root/mysql-8.0.33/packaging/deb-in/libmysqlclient21-dbgsym.install.in
/root/mysql-8.0.33/packaging/deb-in/libmysqlclient-dev.install.in
/root/mysql-8.0.33/packaging/deb-in/libmysqlclient21.lintian-overrides.in
/root/mysql-8.0.33/build/library_output_directory/libmysqlclient.so.21
/root/mysql-8.0.33/build/library_output_directory/libmysqlclient.so
/root/mysql-8.0.33/build/library_output_directory/libmysqlclient.so.21.2.33
/root/mysql-8.0.33/build/archive_output_directory/libmysqlclient.a
/usr/local/mysql/lib/libmysqlclient.a
/usr/local/mysql/lib/libmysqlclient.so.21
/usr/local/mysql/lib/libmysqlclient.so
/usr/local/mysql/lib/libmysqlclient.so.21.2.33

[root@hcss-ecs-3501 ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.21 /usr/local/lib/libmysqlclient.so.20
[root@hcss-ecs-3501 ~]# echo /usr/local/lib  >> /etc/ld.so.conf
[root@hcss-ecs-3501 ~]# /sbin/ldconfig -v
[root@hcss-ecs-3501 ~]# tar xvf sysbench-1.0.20.tar.gz
[root@hcss-ecs-3501 ~]# cd sysbench-1.0.20
[root@hcss-ecs-3501 sysbench-1.0.20]# ./autogen.sh
[root@hcss-ecs-3501 sysbench-1.0.20]# ./configure
[root@hcss-ecs-3501 sysbench-1.0.20]#  make -j
[root@hcss-ecs-3501 sysbench-1.0.20]#  make install
[root@hcss-ecs-3501 sysbench-1.0.20]# sysbench --version
sysbench 1.0.20

  sysbench に付属の Lua スクリプトの使用方法を確認してください。

sysbench /usr/local/share/sysbench/oltp_common.lua help

   データの準備 (準備):

mysql> select user,host,password from mysql.user;
mysql> alter user root@'%' identified  with mysql_native_password by '123456';
mysql> flush privileges;
mysql> create database sbtest;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sbtest             |
| sys                |
+--------------------+
[root@hcss-ecs-3501 ~]# sysbench \
--mysql-port=3306 \
--mysql-user=root \
--mysql-password='123456' \
/usr/local/share/sysbench/oltp_common.lua \
--db-driver=mysql \
--report-interval=5  \
--time=300 \
--mysql-db=sbtest \
--table-size=100000 \
--tables=10 \
prepare

sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Creating table 'sbtest1'...
Inserting 100000 records into 'sbtest1'
Creating a secondary index on 'sbtest1'...
Creating table 'sbtest2'...
Inserting 100000 records into 'sbtest2'
Creating a secondary index on 'sbtest2'...
Creating table 'sbtest3'...
Inserting 100000 records into 'sbtest3'
Creating a secondary index on 'sbtest3'...
Creating table 'sbtest4'...
Inserting 100000 records into 'sbtest4'
Creating a secondary index on 'sbtest4'...
Creating table 'sbtest5'...
Inserting 100000 records into 'sbtest5'
Creating a secondary index on 'sbtest5'...
Creating table 'sbtest6'...
Inserting 100000 records into 'sbtest6'
Creating a secondary index on 'sbtest6'...
Creating table 'sbtest7'...
Inserting 100000 records into 'sbtest7'
Creating a secondary index on 'sbtest7'...
Creating table 'sbtest8'...
Inserting 100000 records into 'sbtest8'
Creating a secondary index on 'sbtest8'...
Creating table 'sbtest9'...
Inserting 100000 records into 'sbtest9'
Creating a secondary index on 'sbtest9'...
Creating table 'sbtest10'...
Inserting 100000 records into 'sbtest10'
Creating a secondary index on 'sbtest10'...

   ● oltp_common.lua: テストスクリプトが実行されました。/usr/share/sysbench/インストールには yum が使用されるため、ディレクトリに移動してsysbench組み込みの lua テスト スクリプトを確認する必要があります。
   ● --time: 最大合計実行時間 (秒単位)、デフォルトは 10 秒です。
   ● --events: 許可されるイベントの最大数、デフォルトは 0 です。これが--time最大実行時間と最大回数を形成します。

   MySQL 関連パラメータ:
   ● --mysql-host: MySQL サーバーのホスト
   ● --mysql-port: MySQL サーバーのポート
   ● --mysql-user: MySQL サーバーのアカウント
   ● --mysql-password: MySQL サーバーのパスワード
   ● --mysql-db: MySQL サーバーのデータベース名
   ● --table-size: テーブルのレコード数
   ● --tables: テーブル名
   ● --threads: 使用するスレッドの数、デフォルト1 ● : 秒単位で指定した間隔で中間統計を定期的にレポートします。デフォルトは 0 で、中間レポートを無効にすることを意味します。
   ●    :準備データを実行します。--report-interval
prepare

  テスト データが存在することを確認します。

[root@hcss-ecs-3501 ~]# mysql -u root -p123456 sbtest;
mysql> show tables;
+------------------+
| Tables_in_sbtest |
+------------------+
| sbtest1          |
| sbtest10         |
| sbtest2          |
| sbtest3          |
| sbtest4          |
| sbtest5          |
| sbtest6          |
| sbtest7          |
| sbtest8          |
| sbtest9          |
+------------------+
10 rows in set (0.00 sec)

  テーブルをランダムに選択し、そこに 100,000 個のデータがあることを確認します。

mysql> select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
|   100000 |
+----------+
1 row in set (0.08 sec)

   テストを実行します (実行):

   ● oltp_read_write.lua: 実行したテストスクリプト/usr/share/sysbench/は以下の通りです。このスクリプトは、読み取りと書き込みの混合を表します。トランザクションにおけるデフォルトの比率は次のとおりですselect:update_key:update_non_key:delete:insert = 14:1:1:1:1これが、テストした TPS と QPS の比率が約 1:20 である理由です。1 トランザクションで 18 回の読み取りおよび書き込み操作に相当します。
   ● run: テストを実行します。

[root@hcss-ecs-3501 ~]# sysbench \
--time=300 \
--mysql-host=localhost \
--mysql-port=3306 \
--mysql-user=root \
--mysql-password=123456 \
/usr/local/share/sysbench/oltp_read_write.lua \
--mysql-db=sbtest \
--tables=10 \
--table_size=100000 \
--report-interval=5 \
run


sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Report intermediate results every 5 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!
# 以下是每5秒返回一次的结果,统计的指标包括:
# 线程数、tps(每秒事务数)、qps(每秒查询数)、每秒的读//其它次数、延迟、每秒错误数、每秒重连次数

[ 5s ] thds: 1 tps: 110.56 qps: 2214.86 (r/w/o: 1550.68/442.85/221.33) lat (ms,95%): 15.27 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 1 tps: 142.00 qps: 2840.27 (r/w/o: 1988.05/568.21/284.01) lat (ms,95%): 9.73 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 1 tps: 148.60 qps: 2972.01 (r/w/o: 2080.41/594.40/297.20) lat (ms,95%): 9.39 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 1 tps: 154.20 qps: 3083.99 (r/w/o: 2158.79/616.80/308.40) lat (ms,95%): 8.74 err/s: 0.00 reconn/s: 0.00
......
[ 290s ] thds: 1 tps: 157.80 qps: 3155.23 (r/w/o: 2209.22/630.41/315.60) lat (ms,95%): 8.74 err/s: 0.00 reconn/s: 0.00
[ 295s ] thds: 1 tps: 156.60 qps: 3129.37 (r/w/o: 2189.78/626.39/313.20) lat (ms,95%): 8.74 err/s: 0.00 reconn/s: 0.00
[ 300s ] thds: 1 tps: 157.00 qps: 3143.33 (r/w/o: 2200.55/628.79/313.99) lat (ms,95%): 8.43 err/s: 0.00 reconn/s: 0.00
SQL statistics:
    queries performed:
        read:                            661290			# 执行的读操作数量 
        write:                           188940			# 执行的写操作数量
        other:                           94470			# 执行的其它操作数量
        total:                           944700
    transactions:                        47235  (157.45 per sec.)	# 执行事务的平均速率
    queries:                             944700 (3148.96 per sec.)	# 平均每秒能执行多少次查询
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          300.0028s		# 总消耗时间
    total number of events:              47235			# 总请求数量(读、写、其它)

Latency (ms):
         min:                                    3.92
         avg:                                    6.35
         max:                                  163.55
         95th percentile:                        8.58	# 采样计算的平均延迟
         sum:                               299879.21

Threads fairness:
    events (avg/stddev):           47235.0000/0.00
    execution time (avg/stddev):   299.8792/0.00

   テスト結果の説明:
   157 TPS+3148 QPS+8.58ms 遅延

  クリーンデータ (クリーン):

sysbench \
--time=300 \
--mysql-host=localhost \
--mysql-port=3306 \
--mysql-user=root \
--mysql-password=123456 \
/usr/local/share/sysbench/oltp_read_write.lua \
--mysql-db=sbtest \
--tables=10 \
--table_size=100000 \
--report-interval=5 \
cleanup

sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Dropping table 'sbtest9'...
Dropping table 'sbtest10'...

   結論: Huawei Cloud Yaoyun Server L インスタンスの 2 コア 2G 構成の場合、mysqlslap ツールを使用すると、100 クライアントが 1.863/s で追加クエリを同時に開始し、1000 クライアントが 2.160/s で追加クエリを同時に開始します。sysbench ツールを使用し、10 のテーブルと各テーブルの 100,000 レコードを使用したテスト結果は、157 TPS + 3148 QPS + 8.58 ミリ秒の遅延でした。基本的には中小企業のデータベースパフォーマンス要件を満たすことができます。

おすすめ

転載: blog.csdn.net/wangzongyu/article/details/132907588