mysql innodb_sort_buffer_size_mysql优化---第7篇:参数 innodb_buffer_pool_instances设置

摘要:1 innodb_buffer_pool_instances可以开启多个内存缓冲池,把需要缓冲的数据hash到不同的缓冲池中,这样可以并行的内存读写。

2 innodb_buffer_pool_instances参数显著的影响测试结果,特别是非常高的 I/O 负载时。

3 实验环境下,innodb_buffer_pool_instances=8在很小的 buffer_pool 大小时有很大的不同,而使用大的

buffer_pool 时,innodb_buffer_pool_instances=1的表现最棒。

1 定义

The number of regions that the InnoDB buffer

pool is divided into. For systems with buffer pools in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency, by reducing contention as different threads read and write to cached pages. Each page that is stored

in or read from the buffer pool is assigned to one of the buffer pool instances randomly, using a hashing function. Each buffer pool manages its own free lists, flush lists, LRUs, and all other data structures connected to a buffer pool, and is protected by

its own buffer pool mutex.

This option takes effect only when you set the innodb_buffer_pool_size to

a size of 1 gigabyte or more. The total size you specify is divided among all the buffer pools. For best efficiency, specify a combination ofinnodb_buffer_pool_instances and innodb_buffer_pool_size so

that each buffer pool instance is at least 1 gigabyte.

测试日期: Oct-2012

测试目的: 测试 MySQL 5.6.7 的表现

硬件换

服务器: Dell PowerEdge R710

CPU: 2x Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz

内存: 192GB(这个内存太猛了)

存储: Very Fast PCIe Flash Card

文件系统: ext4

软件

操作系统: CentOS 6.3

MySQL 版本: 5.6.7-RC

测试规范

测试工具: tpcc-mysql

测试数据: 2500W (~250GB of data)

测试时间: 总共测试 4000 秒,但只取最后的 2000 秒,避免因为冷启动的问题导致测试结果不准确

不同的测试参数: 使用几组不同的 innodb_buffer_pool_size:13, 25, 50, 75, 100, 125GB ,innodb_buffer_pool_instances: 1

and 8, and innodb_log_file_size: 2x4GB and 2x8GB.

测试结果:

第一个结果使用的事 2x4GB 的 InnoDB 日志文件:

我们可看出当 innodb_buffer_pool_instances=8 在很小的 buffer_pool 大小时有很大的不同,而使用大的 buffer_pool 时,innodb_buffer_pool_instances=1 的表现最棒。

测试结果在大的 buffer_pool 时是很稳定的,原因是 InnoDB 使用异步 flush 模式,在新的 InnoDB flush 机制下以前的问题已经修复。不过 Dimitry 告诉我需要一个更大的 InnoDB 日志文件来获得更稳定的结果。

下面是 2x4GB vs 2x8GB innodb 日志文件大小的比较:

很显然,使用更大的日志文件,测试结果更稳定!

结论:

innodb_buffer_pool_instances 参数显著的影响测试结果,特别是非常高的 I/O 负载时。

在 MySQL 5.6 ,最终是可以获得非常稳定的吞吐,但自适应的 flush 机制仍需较大的日志文件。

MySQL 配置如下:

01

[mysqld]

02

gdb

03

04

innodb_file_per_table

=true

05

innodb_data_file_path

= ibdata1:100M:autoextend

06

innodb_flush_method

= O_DIRECT

07

innodb_log_buffer_size

= 256M

08

09

innodb_flush_log_at_trx_commit

= 1

10

innodb_buffer_pool_size

= 125G

11

innodb_buffer_pool_instances=8

12

13

innodb_log_file_size

= 4G

14

innodb_log_files_in_group

= 2

15

#####plugin

options

16

innodb_read_io_threads

= 16

17

innodb_write_io_threads

= 16

18

innodb_io_capacity

= 20000

19

innodb_io_capacity_max

= 40000

20

21

22

#not

innodb options (fixed)

23

port

= 3306

24

back_log

= 50

25

max_connections

= 2000

26

max_prepared_stmt_count=500000

27

max_connect_errors

= 10

28

table_open_cache

= 2048

29

max_allowed_packet

= 16M

30

binlog_cache_size

= 16M

31

max_heap_table_size

= 64M

32

sort_buffer_size

= 4M

33

join_buffer_size

= 4M

34

thread_cache_size

= 1000

35

query_cache_size

= 0

36

query_cache_type

= 0

37

ft_min_word_len

= 4

38

thread_stack

= 192K

39

tmp_table_size

= 64M

40

41

server-id =

10

42

#***

MyISAM Specific options

43

key_buffer_size

= 8M

44

read_buffer_size

= 1M

45

read_rnd_buffer_size

= 4M

46

bulk_insert_buffer_size

= 8M

47

myisam_sort_buffer_size

= 8M

48

myisam_max_sort_file_size

= 10G

49

myisam_repair_threads

= 1

50

myisam_recover

51

user=root

52

skip-grant-tables

转自:http://www.phpchina.com/archives/view-41968-1.html

你可能感兴趣的:(mysql)