隨著互聯網的不斷發展,數據庫的高并發性能越來越成為熱門話題,mysql數據庫的高并發性能也受到越來越多的關注。
那么,如何提高mysql數據庫的高并發性能呢?下面我們從以下幾個方面進行探討。
一、數據庫的連接數
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
innodb_flush_neighbors = 0
innodb_thread_concurrency = 64
innodb_concurrency_tickets = 2000
innodb_purge_threads = 4
innodb_adaptive_flushing_lwm = 10
innodb_adaptive_flushing = on
innodb_flush_method = O_DIRECT
二、sql語句的優化
CREATE INDEX idx_order_paytime ON orders(pay_time);
CREATE INDEX idx_order_delivery ON orders(delivery_id);
CREATE INDEX idx_order_status ON orders(status);
CREATE INDEX idx_order_uid_goodsid ON orders(uid,goods_id);
三、mysql的集群
my.cnf:
[mysqld]
port = 3306
pid-file = /usr/local/mysql/var/mysql.pid
socket = /usr/local/mysql/var/mysql.sock
datadir = /usr/local/mysql/data
log_error = /usr/local/mysql/data/mysql_error.log
character_set_server = utf8mb4
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
port = 3306
socket = /usr/local/mysql/var/mysql.sock
use-remote-mysql = true
mysql_access_cache = off
ndbd.ccnf
[ndbd default]
exclude_ips=118.17.1.1,118.17.1.2
connectstring=118.17.1.1,118.17.1.2
DataDir=/usr/local/mysql/mysql-cluster
ServerPort=2203
[ndb_mgmd]
hostname=118.17.1.1
datadir=/usr/local/mysql/mysql-cluster
[ndbd]
hostname=118.17.1.1
datadir=/usr/local/mysql/mysql-cluster
[ndbd]
hostname=118.17.1.2
datadir=/usr/local/mysql/mysql-cluster
[mysqld]
hostname=118.17.1.1
[mysqld]
hostname=118.17.1.2
以上就是mysql數據庫高并發性能的一些優化方法,希望可以對大家有所幫助。
上一篇css動畫 小球組成字體
下一篇css動畫skew效果