ラベル benchmark の投稿を表示しています。 すべての投稿を表示
ラベル benchmark の投稿を表示しています。 すべての投稿を表示

2014年5月3日土曜日

のmysqlslapとMySQLベンチマーク

Original post: http://anothermysqldba.blogspot.com/2014/05/mysql-benchmark-with-mysqlslap.html

だからあなたのデータベースに対して様々なMySQLクエリをベンチマーキングするのは非常に賢明なことです。 それは言うまでもない。 我々は最適化しながら、我々は彼らに彼らが参考に証明する必要があり、ベンチマークするために時間を割いEXPLAIN(および拡張EXPLAIN)を使用することができます最善を照会します。 

これはのmysqlslap文を実行する簡単な例です。 

この例では、私は、MySQLからのworldデータベースをロードしました。 (http://dev.mysql.com/doc/index-other.html ) 

私はすべての3つのテーブルを結合し、クエリを作成し、/ tmpに/ tests.sqlに入れて。 実行計画は以下の通りです。 

root@localhost [world]> EXPLAIN EXTENDED SELECT C.Name as City, Y.Name as Country, L.Language,Y.Population FROM City C INNER JOIN Country Y ON C.CountryCode = Y.Code INNER JOIN CountryLanguage L ON C.CountryCode = L.CountryCode WHERE C.Name LIKE 'D%' AND Y.Continent='Europe' \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: C
type: range
possible_keys: CountryCode,name_key
key: name_key
key_len: 5
ref: NULL
rows: 127
filtered: 100.00
Extra: Using where
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: Y
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 3
ref: world.C.CountryCode
rows: 1
filtered: 100.00
Extra: Using where
*************************** 3. row ***************************
id: 1
select_type: SIMPLE
table: L
type: ref
possible_keys: PRIMARY,CountryCode
key: CountryCode
key_len: 3
ref: world.C.CountryCode
rows: 2
filtered: 100.00
Extra: Using index
3 rows in set, 1 warning (0.00 sec)

root@localhost [world]> show warnings \G
*************************** 1. row ***************************
Level: Note
Code: 1003
Message: /* select#1 */ select `world`.`C`.`Name` AS `City`,`world`.`Y`.`Name` AS `Country`,`world`.`L`.`Language` AS `Language`,`world`.`Y`.`Population` AS `Population` from `world`.`City` `C` join `world`.`Country` `Y` join `world`.`CountryLanguage` `L` where ((`world`.`Y`.`Code` = `world`.`C`.`CountryCode`) and (`world`.`L`.`CountryCode` = `world`.`C`.`CountryCode`) and (`world`.`Y`.`Continent` = 'Europe') and (`world`.`C`.`Name` like 'D%'))


今のmysqlslapツールは、MySQL 5.1.4から存在しています 
以下にいくつかの他の有用なリンクがあります。 
今、私は私のクエリを持っていることを、私は、次のコマンドを使用してデータベースに対するベンチマークそれはすることができます。 

のmysqlslap - 同時実行性= 150 - 反復= 50 - クエリ=を/ tmp / test.sql内 - 作成 - スキーマ=世界 

一つ注意: 
問合せは、ツールが簡単にエラーの場合と同様に、非常にきれいである必要があります。 
例えば以下は、このエラーを投​​げ: 

SELECT C.Name as City, Y.Name as Country, L.Language,Y.Population
FROM City C
INNER JOIN Country Y ON C.CountryCode = Y.Code
INNER JOIN CountryLanguage L ON C.CountryCode = L.CountryCode
WHERE C.Name LIKE 'D%' AND Y.Continent='Europe' 

このクエリはうまく働いている間。 

SELECT C.Name as City, Y.Name as Country, L.Language,Y.Population FROM City C INNER JOIN Country Y ON C.CountryCode = Y.Code INNER JOIN CountryLanguage L ON C.CountryCode = L.CountryCode WHERE C.Name LIKE 'D%' AND Y.Continent='Europe' 


あなたのためのツールが出力ベンチマーク結果 


Benchmark
Average number of seconds to run all queries: 0.104 seconds
Minimum number of seconds to run all queries: 0.096 seconds
Maximum number of seconds to run all queries: 0.141 seconds
Number of clients running queries: 150
Average number of queries per client: 1 


のmysqlslap - ヘルプは、あなたとあなたのクエリをテストするための多数のオプションを提供します。 

あなたは、自動的にすべてを行うことができます 

# mysqlslap --auto-generate-sql
Benchmark
Average number of seconds to run all queries: 0.243 seconds
Minimum number of seconds to run all queries: 0.243 seconds
Maximum number of seconds to run all queries: 0.243 seconds
Number of clients running queries: 1
Average number of queries per client: 0 


あなたにも挿入をテストすることができます。 たとえば、私は、この表を作成しました: 

CREATE TABLE `foobar_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`time_recorded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB ; 


それでは、次のようにテストされています。 

# mysqlslap --concurrency=1150 --iterations=530 --query="use test;insert into foobar_table (id) values (null)" --delimiter=";"
mysqlslap: Could not create thread 


OKエラーは非常に有用ではありません...しかし、うまくいけば、エラーに気づく。 あなただけの530回の繰り返しを持っている場合、それは1150年の同時トランザクションを持つことは難しいです。 


# mysqlslap --concurrency=150 --iterations=30 --query=/tmp/test1.sql --create-schema=test --verbose
Benchmark
Average number of seconds to run all queries: 0.260 seconds
Minimum number of seconds to run all queries: 0.192 seconds
Maximum number of seconds to run all queries: 0.476 seconds
Number of clients running queries: 150
Average number of queries per client: 1


例えば以下は、はるかに優れていました。 

# mysqlslap --concurrency=200 --iterations=1000 --query=" insert into foobar_table (id) values (null)" --verbose --create-schema=test
Benchmark
Average number of seconds to run all queries: 0.282 seconds
Minimum number of seconds to run all queries: 0.217 seconds
Maximum number of seconds to run all queries: 0.726 seconds
Number of clients running queries: 200
Average number of queries per client: 1 


ちょうど私達が実際の挿入を行っていることを証明する.. 

root@localhost [test]> select count(id) from foobar_table;
+-----------+
| count(id) |
+-----------+
| 206091 |
+-----------+
1 row in set (0.13 sec) 

今、私はまた、これは私がブログの記事で使用するだけでテスト·データベースであることを言う必要がありますので、これらの結果と照らし合わせて本番データベースを評価しません。

私は、面倒なクエリを見つける...このすべての直後にポイントを推測、それはあなたができる最善の最適化、およびベンチマークそれ。 それだけではなく推測の自分の限界を知っている方がよい。 

2013年5月7日火曜日

ベンチマーク:: MySQLは、CPU、I / O、ファイル、メモリー::補正済み&Apacheのベンチマーク

Original post: http://anothermysqldba.blogspot.com/2013/05/benchmarking-mysql-cpu-file-io-memory.html



あなたが使用したいのですがどのツールを決定します。 
私は、この例では補正済みを使用します。 
まずダウンロード補正済み 
インストールします。 
  • #タール-vxzf補正済み-0.4.12.tar.gz
  • CD補正済み-0.4.12
  • 補正済み-0.4.12]#。/ configureを
  • 補正済み-0.4.12]#メイク
  • 補正済み-0.4.12]#make installを
補正済みマニュアル 
あなたのオプションを確認します: 
#補正済み - テスト= OLTPヘルプ 

コンパイルインテスト: 
にFileIO - I / Oテストをファイル 
CPU - CPUの性能試験 
メモリ - メモリ機能のスピードテスト 
スレッド - スレッド·サブシステムの性能試験 
ミューテックス - ミューテックス性能試験 
OLTP - OLTPテスト 

コマンド:実行クリーンアップのヘルプのバージョンを用意 

以下にいくつかの例: 

にFileIO - I / Oテストをファイル 
# sysbench --test=fileio help 
fileio options:
--file-num=N number of files to create [128]
--file-block-size=N block size to use in all IO operations [16384]
--file-total-size=SIZE total size of files to create [2G]
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
--file-io-mode=STRING file operations mode {sync,async,fastmmap,slowmmap} [sync]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all=[on|off] do fsync() after each write operation [off]
--file-fsync-end=[on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5] 

  • #補正済み - テスト=にFileIO準備
  • #補正済み - テスト=にFileIO - ファイルテストモード= rndwrラン


CPU - CPUの性能試験 
#補正済み - テスト= CPUのヘルプ 
CPUオプション: 
- 素数ジェネレータのCPU-MAXプライム= N上限[10000] 


  • #補正済み - テスト= CPU - NUM-スレッド= 25ラン


メモリ-メモリ機能のスピードテスト 
# sysbench --test=memory help 
memory options:
--memory-block-size=SIZE size of memory block for test [1K]
--memory-total-size=SIZE total size of data to transfer [100G]
--memory-scope=STRING memory access scope {global,local} [global]
--memory-hugetlb=[on|off] allocate memory from HugeTLB pool [off]
--memory-oper=STRING type of memory operations {read, write, none} [write]
--memory-access-mode=STRING memory access mode {seq,rnd} [seq] 

  • #補正済み - テスト=メモリ<memory options>ラン

スレッド-スレッド·サブシステムの性能試験 
# sysbench --test=threads help   
threads options:
--thread-yields=N number of yields to do per request [1000]
--thread-locks=N number of locks per thread [8] 

  • ##補正済み - テスト=スレッド - NUM-スレッド= 64 - テスト=スレッド - スレッド利回り= 100 - スレッドロック= 6ラン


ミューテックス-ミューテックス性能試験 
# sysbench --test=mutex help   
mutex options:
--mutex-num=N total size of mutex array [4096]
--mutex-locks=N number of mutex locks to do per thread [50000]
--mutex-loops=N number of empty loops to do inside mutex lock [10000] 
  • #補正済み - テスト=ミューテックス - NUM-スレッド= 64ラン




OLTP - OLTPテスト 
# sysbench --test=oltp help
oltp options:
--oltp-test-mode=STRING test type to use {simple,complex,nontrx,sp} [complex]
--oltp-reconnect-mode=STRING reconnect mode {session,transaction,query,random} [session]
--oltp-sp-name=STRING name of store procedure to call in SP test mode []
--oltp-read-only=[on|off] generate only 'read' queries (do not modify database) [off]
--oltp-skip-trx=[on|off] skip BEGIN/COMMIT statements [off]
--oltp-range-size=N range size for range queries [100]
--oltp-point-selects=N number of point selects [10]
--oltp-simple-ranges=N number of simple ranges [1]
--oltp-sum-ranges=N number of sum ranges [1]
--oltp-order-ranges=N number of ordered ranges [1]
--oltp-distinct-ranges=N number of distinct ranges [1]
--oltp-index-updates=N number of index update [1]
--oltp-non-index-updates=N number of non-index updates [1]
--oltp-nontrx-mode=STRING mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]
--oltp-auto-inc=[on|off] whether AUTO_INCREMENT (or equivalent) should be used on id column [on]
--oltp-connect-delay=N time in microseconds to sleep after connection to database [10000]
--oltp-user-delay-min=N minimum time in microseconds to sleep after each request [0]
--oltp-user-delay-max=N maximum time in microseconds to sleep after each request [0]
--oltp-table-name=STRING name of test table [sbtest]
--oltp-table-size=N number of records in test table [10000]
--oltp-dist-type=STRING random numbers distribution {uniform,gaussian,special} [special]
--oltp-dist-iter=N number of iterations used for numbers generation [12]
--oltp-dist-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--oltp-dist-res=N percentage of 'special' values to use (for special distribution) [75]

General database options:

--db-driver=STRING specifies database driver to use ('help' to get list of available drivers)
--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]


Compiled-in database drivers:
mysql - MySQL driver

mysql options:
--mysql-host=[LIST,...] MySQL server host [localhost]
--mysql-port=N MySQL server port [3306]
--mysql-socket=STRING MySQL socket
--mysql-user=STRING MySQL user [sbtest]
--mysql-password=STRING MySQL password []
--mysql-db=STRING MySQL database name [sbtest]
--mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
--mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto]
--mysql-ssl=[on|off] use SSL connections, if available in the client library [off]
--myisam-max-rows=N max-rows parameter for MyISAM tables [1000000]
--mysql-create-options=STRING additional options passed to CREATE TABLE [] 

補正済みそう確認し、その最初を作成するか、またはあなたが好むものをデータベース定義sbtestデータベースを見つけることを期待しています。 
  • 補正済み - テスト= OLTPヘルプ|グレップsbtest
    - テストテーブルのOLTPテーブル名=文字列名[sbtest]
    - mysqlのユーザ= STRINGのMySQLユーザ[sbtest]
    - のmysql-DB = STRING MySQLデータベース名は[sbtest]

#補正済み - テスト= OLTP - mysqlのホスト= localhostと - mysqlのユーザ=ルート - のmysql-パスワード= <password here> - mysqlのテーブルエンジン= InnoDBの準備 

#補正済み - テスト= OLTP - mysqlのホスト= localhostと - mysqlのユーザ=ルート - のmysql-パスワード= <password here> - mysqlのテーブルエンジン= InnoDBは - NUM-スレッド= 25ラン

テストの実行として、あなたの結果に目と同様、データベースを保持。 



Apacheのベンチマーク &| | 
WWW :: Mechanizeの:: Firefoxの 

キーはここに奪うことはベンチマークアプリケーションとプロセスのアーキテクチャだけでなく、単一の要因には、これらのツールを使用することです。 

あなたは20,000ユーザーにあなたのウェブフォームに記入する時間を持つことが予想される場合たとえば、あなたはベンチマークアプリケーションがあることを処理する必要があります。 あなたがトークンを渡すことで、ほんの一例のために、記事を模倣するために、上記のツールを使用してから、アプリケーション上の所定の位置にあるコードをテストすることができます。 このようなテストは、コードベースをテストしますと場所における適切なロギング(あなたもトークンでオンにできる)を使用すれば、開発者、DBA、システムが構築されている方法もテストすることができます。 

コンセプトの非常に簡単な例: 

あなたはそれをベンチマークすることができるのelinksでURLを開くことができます。 

elinks http://www.google.com/search?ie=ISO-8859-1\&hl=en\&source=hp\&q=mysql

# ab -n 10 -c 2 http://www.google.com/search?ie=ISO-8859-1\&hl=en\&source=hp\&q=mysql 

もちろん、あなたがあなたのアプリケーションがどのように応答するかをテストするために、はるかに高いレベルでシステムに対してこれを実行するだろう。