My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
innodb_secondary_buffer_pool  

InnoDB, SSD, Flash, Cache, MySQL
Updated Dec 19, 2011 by jiangche...@gmail.com

New flash cache solution is here:
http://code.google.com/p/david-mysql-tools/wiki/Flash_Cache_For_InnoDB.
No plan to continue this project

Contact me if you wanna know more about this project or my support in using secondary buffer pool:
Mail: jiangchengyao@gmail.com
MSN: jiangchengyao@gmail.com

Introduction

Enable using flash memory or solid state drive(SSD) as innodb's secondary buffer pool.
This feature is much like flash cache in Oracle's Exadata

After enable this feature, innodb will add a new backgound thread, when the page was removed from the innodb buffer pool, InnoDB will move it to the flash memory or ssd storage if the thread is availible. When InnoDB read a new page which is not in the buffer pool, it will read the secondary buffer pool first. If the page is cached in secondary buffer pool, it will not read the disk. Because the high random read performance of flash memory or ssd, this will boost the database performance.

Sysbench OLTP benchmark

Server: Intel(R) Xeon Quad-Core E5405 2.00GHz X 2
Database: ~19G ( created by sysbench, row: 80000000 )
disk: 4 disk RAID 10 flash storage: Intel X25-M 80G SSD
test command:
sysbench --test=oltp --oltp-table-size=80000000 --oltp-read-only=off --init-rng=on --num-threads=16 --max-requests=0 --oltp-dist-type=uniform --max-time=7200 --mysql-user=root --mysql-socket=/tmp/mysql.sock --db-driver=mysql run

innodb_buffer_pool innodb_secondary_buffer_pool read-write(tps)
8G 0G 55.03
8G(sbtest on SSD) 0G 60.8
8G 30G 86.23

TPC-C benchmark

Server: Intel(R) Xeon Quad-Core E5405 2.00GHz X 2
Database: 9G ( created by tpcc_load, 100 warehouse )
disk: 4 disk RAID 10 flash storage: Intel X25-M 80G SSD

MySQL configuration:

| innodb_flush_log_at_trx_commit    | 1        |
| innodb_flush_method               | O_DIRECT |

tpcc-mysql: tpcc_start 127.0.0.1 tpcc root '123456' 10 16 1 7200

innodb_buffer_pool innodb_secondary_buffer_pool result(tpmC)
4G 30G 10543.02
4G(tpcc on SSD) 0 10771.2

Configuration

1. create the file on flash memory, we use this file as secondary buffer pool. (In windows, InnoDB will auto create this file)

[root@xen-server ~]# dd if=/dev/zero of=ib_sbpfile bs=16384 count=58880 
[root@xen-server ~]# chown mysql:mysql ib_sbpfile

2. edit the my.cnf file, add followings:

[mysqld]
innodb-secondary-buffer-pool-size=920M
innodb-secondary-buffer-pool-file=/flash/ib_sbpfile
innodb_secondary_buffer_pool_preload_table=tpcc.*:test.t

3. watch secondary buffer pool status using show innodb status\G:

mysql> show engine innodb status\G;
*************************** 1. row ***************************
......
----------------------
SECONDARY BUFFER POOL
----------------------
Secondary buffer pool size      58880
Free pages      126
LRU pages       58754
Page reads 971180, sync 548939, swap 490185
Secondary buffer pool hit rate 916 / 1000 (in 23.00 sec)
649.10 reads/s, 334.16 sync/s, 336.25 swap/s (in 23.00 sec)
......

4. new innodb status variables:

mysql> show global status like 'innodb_sec%';
+----------------------------------------------------+--------+
| Variable_name                                      | Value  |
+----------------------------------------------------+--------+
| Innodb_secondary_buffer_pool_reads                 | 269080 |
| Innodb_secondary_buffer_pool_sync                  | 201435 |
| Innodb_secondary_buffer_pool_swap                  | 214080 |
| Innodb_secondary_buffer_pool_make_young            | 269080 |
| Innodb_secondary_buffer_pool_skip_unuseful         | 9325   |
| Innodb_secondary_buffer_pool_skip_write_overloaded | 0      |
+----------------------------------------------------+--------+
6 rows in set (0.00 sec)

5. after enable innodb_secondary_buffer_pool_preload_table, you will see the following lines in .err file:

100329 11:09:55  InnoDB: preloading table tpcc.warehouse to secondary buffer pool.(0.00%)
100329 11:09:55  InnoDB: preloading table tpcc.item to secondary buffer pool.(0.00%)
100329 11:09:55  InnoDB: preloading table tpcc.new_orders to secondary buffer pool.(1.01%)
100329 11:09:55  InnoDB: preloading table tpcc.history to secondary buffer pool.(1.27%)
100329 11:09:55  InnoDB: preloading table tpcc.district to secondary buffer pool.(4.57%)
100329 11:09:55  InnoDB: preloading table tpcc.customer to secondary buffer pool.(4.57%)
100329 11:09:56  InnoDB: preloading table tpcc.order_line to secondary buffer pool.(25.85%)
100329 11:09:56  InnoDB: preloading table tpcc.orders to secondary buffer pool.(57.90%)
100329 11:09:57  InnoDB: preloading table tpcc.stock to secondary buffer pool.(60.12%)
100329 11:09:57  InnoDB: preloading to secondary buffer pool finish.

Next New Feature

  1. allow to pin the table into secondary buffer pool.
  2. add LRU aglorithm to secondary buffer pool.
  3. add secondary buffer pool status info to INFORMATION_SCHEMA.

Comment by oschina....@gmail.com, Apr 27, 2010
Comment by linu...@gmail.com, Oct 13, 2010

请问下,1:insert 或者delete执行时,数据是被刷新到缓存上,还是直接刷新到磁盘上 2:能否解释下 334.16 sync/s, 336.25 swap/s的含义,谢谢拉 我邮箱linuxyt@gmail.com

Comment by linu...@gmail.com, Oct 13, 2010

3:还问下,如果cache满了,他里面的准备flush的数据是直接删除,还是flush到后端的磁盘上。

Comment by wfz...@gmail.com, Apr 11, 2011

how can I use in percona xtraDB?

Comment by jypen...@gmail.com, Sep 10, 2011

我也想知道二楼提到的问题是怎么解决的? 我记得您在书中说过,SSD的写效率是很低的,我觉得应该是直接写磁盘吧!

再请问个问题,除了INNODB_BUFFER_POOL的页被删除时才将页刷到SSD外还有什么时候写SSD呢?


Sign in to add a comment
Powered by Google Project Hosting