Bill Shupp Software engineer, photographer, musician, space geek

10Feb/100

MogileFS, Zend Framework, Boobs, and Kittens

An upcoming side project of mine requires the use of MogileFS and Zend Framework.  MogileFS is an open source distributed file system, meant to scale up to many millions of files without a single point of failure.  It's currently used by the likes of Digg and last.fm.

Though I was already familiar with using MogileFS clients in php and python at work, the operations team actually runs the servers.   I wanted to get some experience with managing MogileFS itself (trackers, mogstored, mysql), and hopefully have a better understanding of how it all worked together.  While I was already familiar with Zend Framework, I'd never used it to serve images.  So, I figured I should build a quick prototype using both.  But what to build?  I decided to take inspiration from the notorious http://explosionsandboobs.com, but put my own spin on it.  The result?

http://boobsandkittens.com

Bear in mind that the above URL is on my inexpensive Slicehost VPS, and can be slow at times.  This is a really simple application that allowed me to do a few things:

  • scrape some content from google images search
  • store them in MogileFS
  • render the stored images through ZF

The source is available here.  The scraper is pretty straight forward.  I just called it from the command line to save images to a directory.  Once saved to disk, I used the mogrify tool from Imagemagick to scale the images down to a height of 400 px max, and visually removed the worst of the images (it's relatively SFW).  Next, I inserted those images into MogileFS with insertImage.php.  There are only two real action controllers, the index page and image renderer.  The latter was really the only thing to learn on the php side of this project.  The key there was disabling the layout and view rendering, as well as setting the appropriate image information in the response object (content-type, content-length, and the content itself).  Since most of the logic is in the model, the action controllers are pretty skinny.  I used memcache to store db queries and the images from MogileFS to help offset the performance of a cheap VPS.  Since Zend Framework doesn't ship with a MogileFS client, I used the PEAR one.

That's it.  Enjoy!

Please follow and like us:
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.