Episode 92: Memcache

Play

Learn how to speed up your sites with Memcache.

News/Follow-Ups – 01:05

  • Another A/B split tester released – Optimizely

Geek Tools – 03:51

Webapps – 07:42

Memcache – 14:09

  • What is it?
    • Short term memory for web applications
    • Distributed
    • Released in 2003 by Brad Fitzpatrick for his website LiveJournal
  • Why?
    • Most commonly used to take the load off your database, which is usually the biggest performance bottle neck in web applications
  • Who?
    • Facebook
    • Twitter
    • Youtube
    • Wikipedia
    • Reddit
  • How?
    • Example
      • When user logs in store user info in memcache
      • Retrieve user information throughout the app from memcache, if the user changes his/her name/pricing plan etc, just delete the cache.
    • What happens when it is full
      • When the table is full, subsequent inserts cause older data to be purged LRU (Least Recently Used)
    • You need to use memcached as a transitory cache, meaning you cannot assume the data will still be in there when you need it.
    • Values can only be 1mb large
    • Each client knows all servers; the servers do not communicate with each other.
  • Security
    • By default there is no authentication or security. ¬†Optional support for SASL exists.
  • When not to use Memcached
    • When your objects are over 1mb
    • When you have keys larger than 250chars
    • You are running in an insecure environment
    • Before you have profiled your code and done data normalization
  • Clients for
    • Perl, C, C#, PHP, Python, Java, Ruby

Leave a Reply