Your SlideShare is downloading. ×
0
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Kickin' Ass with Cache-Fu (with notes)

26,872

Published on

My memcached talk at RailsConf 2007 (with notes).

My memcached talk at RailsConf 2007 (with notes).

Published in: Technology
1 Comment
37 Likes
Statistics
Notes
  • There's also a version without notes: http://www.slideshare.net/err/kickin-ass-with-cachefu-without-notes/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
26,872
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1,557
Comments
1
Likes
37
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. CHRIS WANSTRATH ERR FREE [ http://errfree.com ] today i want to talk about...
  • 2. Video games! I’m a long time gamer Or, specifically....
  • 3. E3. E3 = Electronics Entertainment Expo - Biggest annual video game conference up through 2006 - Every May - 60,000 - 80,000 industry people - Publishers spend millions - Staples Center in LA - Blogs, magazines, crappy cable TV shows, websites - The two biggest gaming websites are...
  • 4. IGN, owned by News Corp, who also owns MySpace Super good at SEO and breaking news The other one is...
  • 5. GameSpot, owned by CNET GS gets 1.5m uniques a day, over 15m pageviews Here’s the obligatory alexa graph...
  • 6. The spikes are E3 Twitter’s catching up! Okay, so I used to work for GameSpot....
  • 7. funnier if you can see how long my hair is now. and, how not nerdy i am.
  • 8. I was a PHP developer for GameSpot - Hubs - Tagging system - User videos - User profiles Last year I convinced my boss to send me to E3...
  • 9. I got sent down because of Rails, but that’s another story - Booth between Nintendo and Sony. - Microsoft was in another hall. - Unveiling of Wii & PS3 Our booth had a studio attached to it ($400k on new eq) and a bunch of computers inside it...
  • 10. - I sat at one of these computers - The editors would run around writing stories and interviewing people and playing games - GS had exclusive right to internet streaming of sony and nintendo conferences - Nintendo.com and Sony.com were pointing at Gamespot for press conference streaming - Also streamed Microsoft (they streamed on Xbox Live too) - Live blogging (twittering) from the press conferences for kids at school - Imagine million of teenage boys constantly hitting refresh...
  • 11. - We used Netscalers -- switch, firewall, and “accelerator” - Normally our Netscalers would gzip outgoing requests - Had to turn o gzip compression because Netscalers’ CPUs were running so hot - Couldn’t gzip and serve requests fast enough - 3000 req/sec - ~70 app servers - ~15 database servers - apache2, php4 w/APC - when the smoke cleared...
  • 12. 50,000,000 pages no downtime pretty cool, but how?
  • 13. memcached. thanks, in a large part, to memcached this is what my talk is really about...
  • 14. Memcaching Rails CHRIS WANSTRATH ERR FREE [ http://errfree.com ] memcaching rails i will talk about: - what memcached is - when and where to use it - tricks, code - libraries, tools, and hopefully answer questions please ask questions whenever i promise i cant answer them all. also: i don’t want you guys to think that i think i’m an expert i’m more of a foot soldier, or a ninja i’m oficially renaming this session...
  • 15. Memcaching Rails CHRIS WANSTRATH ERR FREE [ http://errfree.com ]
  • 16. chris wanstrath railsconf 2007 kickin’ ass with cache-fu kickin ass with cache-fu what is memcached...
  • 17. {} conceptually, it’s like a hash...
  • 18. class Memcache Hash undef :each, :keys end a hash that... you can’t enumerate over you can’t find all the keys for you can still GET, SET, and DELETE keys...
  • 19. class Memcache DRbHash undef :each, :keys end distributed by distributed, we mean you start a daemon on each app server keys are stored on dierent servers transparently, quickly let’s look at a daemon...
  • 20. $ memcached -vv 3 server listening 7 new client connection 7 get app-test:Story:1 7 END 7 set app-test:Story:2 0 7 STORED 7 delete app-test:Story:1 7 DELETED here is some sample debugging output single memcache daemon, getting, setting, deleting truncated but you get the idea
  • 21. $ memcached -vv 3 server listening 7 new client connection 7 get app-test:Story:1 7 END 7 set app-test:Story:2 0 7 STORED 7 delete app-test:Story:1 7 DELETED developed by...
  • 22. livejournal alleviate database stress they were growing too fast, couldnt scale their databases you can distribute reads but everyone needs to write, which can block hdd too slow -- avoid sql queries / disk access by caching in RAM cache anything: generated images, intense number crunching, html, whatever fast, C, non-blocking IO, O(1) lookups scales -- drop in a new daemon and youre good to go it’s also used by...
  • 23. these guys chowhound serves about .5m pages a day in, of course, rails...
  • 24. you’ve got a rails site should you use memcached?
  • 25. YAGNI ya ain’t gonna need it none of the big guys built memcache into their infrastructure (just ask twitter) build it in later focus on your app first in small apps it is slower than sql hardware is the real special sauce memcached wont help if you cant keep up with the IO requests you probably don’t need memcache...
  • 26. UYRDNI er-den-ee...
  • 27. UYRDNI (unless you really do need it) this would be: - millions of hits - millions of rows - millions of both if you’re getting these, you can use memcached to help with the heavy lifting...
  • 28. before we get ahead of ourselves, we need to look at the basic pattern...
  • 29. class Presentation ActiveRecord::Base def self.get_cache(id) if data = @cache.get(id) data

×