MySql on a RAM disk for super fast performance with the innodb storage engine

In a development environment, having a super fast database can be immensely helpful. If you are not lucky enough to already have an SSD in your system, you need to make yourself a RAMDisk.

I had a system with 6 gig of RAM. I allocated 500 meg for a RAM Disk. You can create one with one of the several RAMDisk programs out there. There are few which are freeware as well.

In MySql, you’ll need to edit your my.cnf to use data files located in a folder on the RAM Drive. Stop your DB, copy the existing DB files to the folder in the RAM Drive. The edited my.cnf should point to this folder. That’s all.

Note that you could also use a different storage engine – but that changes how the database works with respect to transactions and probably other things so I wouldn’t recommend this.

I managed to cut down DB build time from around 2 minutes to under 10 seconds!

I was also able to reveal a ConcurrentModificationException thanks to the DB/disk not being a bottleneck anymore when running some stress tests.

Go, give it a try today!



Tags: ,
This entry was posted on Sunday, January 8th, 2012 at 1:25 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

2 Responses to “MySql on a RAM disk for super fast performance with the innodb storage engine”

  1. cucu

    Have you tried using MEMORY tables? It’s a bit like a MySQL-supported ramdisk. I use them a lot, due to performance reasons, but I don’t know which is the fastest method:
    – MEMORY table
    – MyISAM on ramdisk
    – InnoDB on ramdisk (if possible at all)

  2. shawn wang

    The value for InnoDB on ramdisk lies here :

    Transaction !