我正在運行一個插入很多行的應用程式,我們遇到了一些低性能.所以我開始使用sysbench和oltp_insert.lua對Galera集群進行基準測驗(實際上使用隨機密鑰插入).
群集的性能非常糟糕.
用同樣的測驗:
>作為一個獨立的資料庫,我可以執行大約35000 tps>使用Galera多主機,性能為:350 tps
表結構是這樣的:
Table: sbtest1
Create Table: CREATE TABLE `sbtest1` (
`id` int(11) NOT NULL,
`k` int(11) NOT NULL DEFAULT '0',
`c` char(120) NOT NULL DEFAULT '',
`pad` char(60) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `k_1` (`k`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
到目前為止我嘗試了什么(沒有成功):
>增加wsrep_slave_threads = 16>無論我使用多少個客戶端執行緒,TPS仍然是350(看起來事務是由DB以某種方式序列化的)>設定wsrep_sync_wait = 0(雖然我執行沒有讀取)> db不使用binlog,它未啟用.
組態:
[mysqld]
binlog_format=ROW
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
datadir=/var/lib/mysql
innodb_buffer_pool_size = 300MB
innodb_large_prefix=1
innodb_file_format=Barracuda
transaction-isolation = READ-COMMITTED
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_slave_threads = 16
wsrep_max_ws_rows=131072
wsrep_max_ws_size=1073741824
wsrep_convert_LOCK_to_trx=0
wsrep_causal_reads=OFF
wsrep_sst_method=xtrabackup-v2
uj5u.com熱心網友回復:
我遇到了同樣的問題.首先要檢查以下變數:select @@innodb_flush_log_at_trx_commit;
select @@sync_binlog;
將innodb_flush_log_at_trx_commit設定為2并將sync_binlog設定為0將顯著提高性能.
原因在于認證機制和多主機行為的本質.插入將非常慢,因為為了提交事務集群將確保在每個節點提交時重繪所有日志.
請確保您的快取適合RAM以及以下查詢:
select ((@@thread_stack +@@binlog_cache_size +@@read_buffer_size + @@read_rnd_buffer_size +@@sort_buffer_size +@@join_buffer_size + @@global.net_buffer_length +@@global.query_prealloc_size + @@binlog_stmt_cache_size) * @@max_connections + (@@query_cache_size + @@innodb_buffer_pool_size + @@innodb_log_buffer_size + @@key_buffer_size))/(1024*1024);
uj5u.com熱心網友回復:
我用oltp_insert測驗tps只有單機的1/20,性能太撇了轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/135934.html
標籤:其他技術討論專區
下一篇:資料結構-字串的統計相關操作
