Robert Oliver from OCS Solutions on the Best ActiveRecord and Fragment Cache Store

Robert Oliver of OCS Solutions was one of the Super-Aweomse-Rails-Wizards chosen for the Wisdom of Rails Wizards Study and was kind share some of his expertise for our questions re: Best ActiveRecord and Fragment Cache Store.

Side note: We’ve been hosting several dedicated servers with OCS Solutions at SproutIt.com, with great success!

Original question text in blockquotes, Robert’s response inline.

OS: some flavor of linux or bsd (obviously? =)

FreeBSD or Gentoo for me :)

For ActiveRecord object pulls, would you mind rating the following (1-3/X, in order of fastest to slowest) in terms of mean response time?

You want SATA probably, top of the line, RAID 5. Tune system parameters to pull the most data at a time from the drive as RAID-5 works better in large reads. Either way tho, this is your fastest config in all likelihood.

Definitely MySQL with 2 GB allocated, with testing of performance variables and tuning my.ini per results. This means you have to run it untweaked for a bit to see what the most expensive queries are, how big they are, etc. There is NO one size fits all my.ini.

* Memcached - 2GB of memory dedicated to memcache

With 2 GB of MySQL and 2 GB of memcached, what does that leave on a 4 GB machine? I’d go 1 GB as the disk cache needs some room, as well as kernel and other processes. EIther that, or go 2 GB here and reduce MySQL usage to 1GB.

Of the above, the best thing you can do is tune MySQL properly. This will give you more performance increase than almost any other thing you can do. Of course, RAID-5 doesn’t hurt either, that’s your best read performance. Writing isn’t bad either, and the data redundancy is good.

For cached HTML fragments, would you mind rating the following (1-3/X, in order of fastest to slowest) in terms of mean response time?
* Filestore (top of the line hard-drives, SCSI or SATA, whatever’s faster these days =)

Same as above.

* Memcached - 2GB of memory dedicated to memcache

Go for the 2 GB here

* Storing fragments as rows in a MySQL database (2-3GB of memory allocated for a 20GB+ database, usually maxing out memory usage as is)

MySQL in some configs is faster, but you may also want to consider just laying the files out in indexed directories, like:

01/
02/
03/
04/

not unlike a mail queue. Small data will do better in MySQL, larger in files. Again, your my.ini weights heavily in this scenario.

For the cached HTML fragments, let’s assume that the most GB of HTML data we’d ever need to actively cache at anytime is 2GB.

What’s the average though? Most HTML fragments would be less than 100kb, so MySQL is probably your best option here. If the items are consistently over 1M, then file storage seems the best.

If you go the file/dir route, write a C++ extension to Ruby handle it. You’ll get more horsepower with this over Ruby’s slow I/O.

1 Response to “Robert Oliver from OCS Solutions on the Best ActiveRecord and Fragment Cache Store”


  1. 1 On Web Apps » Blog Archive » Wisdom of Rails Wizards Study in Best ActiveRecord and Fragment Caching Store Pingback on Dec 19th, 2006 at 7:36 am
Comments are currently closed.