提升mysql性能的关键参数之innodb_buffer_pool_size、innodb_buffer_pool_instances。
首先我们先看一下,我的电脑(i3-3220,4G内存,没有配置innodb_buffer_pool_size参数的情况下,抛开程序的性能,经过1个线程-8个线程的测试结果)环境下,大家可以看到如下的图,线程并发情况下,时间不断的攀升,这让人好苦恼,说好的高性能,高并发呢?
结果:
不过经过一个多星期的努力,不经意间,我在同事的电脑上发现,同样的代码测试后,时间和我的不是一个等量级的,要比我的电脑快很多,他的电脑(其他条件等同,CPU为i3-4150),8个商品8000挂单下能达到135ms,首先说明CPU的提升对程序处理来说是非常有效果的,但是依然在高并发的情况下,表现的很差劲。
时至今日,通过比对mysql的配置文件my.ini,不经意间,我们发现innodb_buffer_pool_size在8M和48M的配置下,性能简直就不在一个等级上,OK,那就继续调查吧,最终得出如下结论
innodb_buffer_pool_size=2G innodb_buffer_pool_instances=1详细的解释,可以看如下介绍
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this # parameter up to 80% of the machine physical memory size. Do not set it # too large, though, because competition of the physical memory may # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high.
不过经过一个多星期的努力,不经意间,我在同事的电脑上发现,同样的代码测试后,时间和我的不是一个等量级的,要比我的电脑快很多,他的电脑(其他条件等同,CPU为i3-4150),8个商品8000挂单下能达到135ms,首先说明CPU的提升对程序处理来说是非常有效果的,但是依然在高并发的情况下,表现的很差劲。
时至今日,通过比对mysql的配置文件my.ini,不经意间,我们发现innodb_buffer_pool_size在8M和48M的配置下,性能简直就不在一个等级上,OK,那就继续调查吧,最终得出如下结论
innodb_buffer_pool_size=2G innodb_buffer_pool_instances=1详细的解释,可以看如下介绍
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this # parameter up to 80% of the machine physical memory size. Do not set it # too large, though, because competition of the physical memory may # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high.
所以,推荐如下,mysql在高并发读写情况下,并且为innodb数据表时,请设置
innodb_buffer_pool_size=2G innodb_buffer_pool_instances=1
不过经过一个多星期的努力,不经意间,我在同事的电脑上发现,同样的代码测试后,时间和我的不是一个等量级的,要比我的电脑快很多,他的电脑(其他条件等同,CPU为i3-4150),8个商品8000挂单下能达到135ms,首先说明CPU的提升对程序处理来说是非常有效果的,但是依然在高并发的情况下,表现的很差劲。
时至今日,通过比对mysql的配置文件my.ini,不经意间,我们发现innodb_buffer_pool_size在8M和48M的配置下,性能简直就不在一个等级上,OK,那就继续调查吧,最终得出如下结论
innodb_buffer_pool_size=2G innodb_buffer_pool_instances=1详细的解释,可以看如下介绍
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this # parameter up to 80% of the machine physical memory size. Do not set it # too large, though, because competition of the physical memory may # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high.
所以,推荐如下,mysql在高并发读写情况下,并且为innodb数据表时,请设置
innodb_buffer_pool_size=2G innodb_buffer_pool_instances=1