Panasonic Youth rob sanheim writes about software, business, ruby, music, stuff and things



Posted
19 May 2007 @ 1pm

Tagged
Conference, Linux, Rails, RailsConf, Ruby, Scalability

Discuss

RailsConf 2007 - Memcaching Rails - Chris Wansrath

  • Chris Wanstrath helped scaling gamespot
  • had to turn off gzipping to avoid burning the cpus
  • 3000 req/seconds
  • 50M pages in the day, no downtime
  • Chris is a sloppy programmer (jk)
  • a distributed hash with no each or keys – just get and set
  • written in c – fast
  • at first – you dont need memcached – YAGNI
  • unless you really do need it - you have a millions of views, you have a huge DB, you have really ugly sql
  • the standard pattern—try the cache first, if its not there, grab it from the DB and set it in the cache
  • use memcached-client, not ruby-memcache
  • cache-fu = acts_as-cache 2.0
  • don’t use DNS names for the servers – always use ip’s
  • expire_cache – issues a delete to the cache
  • get_cache – duh, grab from the cache
  • so after_save :expire_cache
  • you dont ever cache nil – since that screws ruby. cache_fu will cache false behind the scenes
  • get the DB down to 0.0%
  • Model.cached(:finder)—wraps the idiom of caching a custom finder
  • can do Model.get_cache(1,2,3) to do a get_multi call to memcached ( ie get many objects in parallel)
  • can do a before_filter to force all cache misses when a url gets a magic query string
  • but be careful – don’t crash your site
  • use reset_cache!
  • need :version to invalidate old version of AR models—otherwise you get screwed when you do a migration
  • libketama – developed by lastfm guys so you can throw memcache servers in and out w/o invalidating all your keys
  • the perl client already handles this under the covers, the ruby client doesn’t
  • someone should implement libketama in ruby, to make big memcached installations safer

No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment

Portland RailsConf 2007 brain dump In Israel