Presentation is loading. Please wait.

Presentation is loading. Please wait.

memcached: an in-depth discussion about caching.

Similar presentations


Presentation on theme: "memcached: an in-depth discussion about caching."— Presentation transcript:

1 memcached: an in-depth discussion about caching.

2 Who am I? Michael Tougeron
Senior Software Engineer & Engineering Manager for CNET Entertainment “Games” (GameSpot.com, GameFaqs.com, SportsGamer.com, and GameRankings.com) I mumble, go off-topic, & skip around. Feel free to stop me.

3 What is memcached? A distributed memory caching system that runs on one or more Linux servers. Fast connections & data retrieval Clients exist for PHP, Perl, Python, Java, C#, C & Ruby; even has database extensions You could write your own client if you need to From a ‘pages served’ perspective, gamefaqs is the biggest, with gs a close second. Just goes to show that how to play the games is more interesting than news about the games. TV is a close third place follwed by mp3 and then the newer sites filmspot and sportsgamer. Very differnet audiences for each site - eg: for gamespot we can safely assume a 1027x768 resolution, where for tv 800 x 600 is the norm. Audience makes a huge difference. Also, the sites each have a HUGE amount of data. They are very broad topics, and each page that we show tends to aggregate a lot of information. Our pages tend to be very ‘heavy’ with data base calls. So how do we support it?

4 What can I use it for? GameSpot uses memcached for:
Faux temporary session handler An alternative to MySQL memory tables (for non-critical data) A caching layer to limit the connections & queries that hit the databases It’s faster than MySQL query cache A trigger for per-www server events Your imagination here? From a ‘pages served’ perspective, gamefaqs is the biggest, with gs a close second. Just goes to show that how to play the games is more interesting than news about the games. TV is a close third place follwed by mp3 and then the newer sites filmspot and sportsgamer. Very differnet audiences for each site - eg: for gamespot we can safely assume a 1027x768 resolution, where for tv 800 x 600 is the norm. Audience makes a huge difference. Also, the sites each have a HUGE amount of data. They are very broad topics, and each page that we show tends to aggregate a lot of information. Our pages tend to be very ‘heavy’ with data base calls. So how do we support it?

5 PHP Client options PHP has built-in memcached functions
Faster since it doesn’t need to compile at run-time Cannot customize functionality Not clear which versions support it A custom PHP class that uses sockets Slower, but do you really see a difference? Can customize interaction with memcached daemon

6 GameSpot uses a PHP class
We’ve added functionality to track whether or not data has been returned from memcached Allows us to distinguish between ‘falsy’ values vs no data stored in memcached This is important for data elements where 0 or false values are appropriate data points to store

7 What’s this class look like?

8 Create a wrapper to the memcached client
Allows you to add flags defining interaction Debug flag Clear cache elements for the page Load page not using cache Semaphore/Mutex Again, your imagination goes here.

9 What’s the wrapper class look like?

10 Potential issues with memcached
Need to track cache keys so that you can clear the cache when the data has been updated No wildcard matches. No, there probably won’t ever be. Yes, we’ve asked.  Need to create a tool to see values stored in memcached so that you can troubleshoot If all servers are not using the same pool of memcached servers, you can get weird data results If memcached servers are reset, the site will probably run slow until keys are recreated (takes GameSpot 10 to 15+ minutes)

11 Questions? Sources: Danga: http://www.danga.com/memcached/
PHP: LiveJournal Plugin: Ryan T. Dean Various CNET developers: Contact me: Michael Tougeron (aka Mike or Touge)


Download ppt "memcached: an in-depth discussion about caching."

Similar presentations


Ads by Google