Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Using RAMdisk to speed up MySQL? Can I?

11:26 pm on Jan 13, 2009 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 21, 2004
votes: 0

Can I use Ram Disk to load entire db file into memory to speed up database?


11:31 pm on Jan 13, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
votes: 0

A quick Google search on mysql +"ram disk" shows it's indeed possible and that lots of folks are doing it.
11:45 pm on Jan 15, 2009 (gmt 0)

Full Member

10+ Year Member

joined:May 11, 2004
posts: 278
votes: 0

Hmmm... what happens after server reboot?

MySQL allows in-memory tables, that should be a better option.

IMHO one should speed-up database by good database design and preventing program from using it whenewer possible (i.e. use disk-level cache for rarely-changing pages).

12:14 am on Jan 16, 2009 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 2

Morgenhund is bringing up good discussion ... why exactly are you looking at RAMdisk to speed up your database? What are the issues, exactly?
2:02 pm on Jan 17, 2009 (gmt 0)

New User

5+ Year Member

joined:Aug 14, 2008
posts: 1
votes: 0

I doubt you see any performance benefit from using a RAM-disk if your table-engine is InnoDB. If you're using MyISAM for the relevant table, you may see some benefits, but its still very likely that your hottest tables indexes are in the key cache and the data in the system's disk cache.

Apart from that, you may find that MySQL's memory-table also doesn't provide any noticable performance benefit, or even some degredation if you're going to store dynamic rows in it.

If you can cache the (processed) data, I'd look at that. Especially a system like memcached or similar environments are quite easy to use and can be very fast. Also keep in mind that a cache can already be beneficial if you have to reproduce your data every second... Which is, normally, quite rare, you can normally get away with at least one minute.

3:02 pm on Jan 17, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 17, 2002
votes: 6

Definitely not worth doing for continuously writable databases - read only databases will only see a benefit.

But wait. Mysql and your O/S should be caching the files in ram anyway so there is no need for a ramdrive here. All you need to do is ensure you have plenty of ram and tune with something like

MySQLTuner by Major Hayden

Ramdrives should be used for storing legacy databases, processing of temporary files and indexes, session files, files you want to permanently cache which may not be cachable via the o/s or apache.

A few more inexpensive ways of increasing performance (assuming linux / apache / mysql)

Have two disks but don't mirror them. One disk is used for the o/s and the other just for the database files.

Set log files to absolute minimum. Don't log image files, .js etc.

Remove all unecessary services from starting up.

Turn off noatime on the volumes.

Set disk acoustic level to fast / loud.

8:37 pm on Jan 17, 2009 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 21, 2004
votes: 0

Many thanks for all of you.

Yes, it is basically a read only database. WRITE occurs only if administrators (3 persons) do that.

If I do not see big benefits by loading database file into memory, I will then load all static files used by the application to memory, hopefully that makes some difference.

Thank you!

6:46 pm on Jan 28, 2009 (gmt 0)

New User

5+ Year Member

joined:Jan 14, 2009
votes: 0

You may want to check into memcached. This was designed for this purpose. It has many APIs and runs well on several clusters I work on.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members