Why Memcached?
Upcoming SlideShare
Loading in...5
×
 

Why Memcached?

on

  • 15,766 views

Memcached is a powerful open source distributed memory caching system and has become the de-facto standard for the web caching tier. 17 of the top 20 most trafficked sites - including Facebook, ...

Memcached is a powerful open source distributed memory caching system and has become the de-facto standard for the web caching tier. 17 of the top 20 most trafficked sites - including Facebook, Twitter, Digg and Wikipedia - depend on Memcached to enhance their user experience by increasing website performance. In this presentation covers the basics of memcached, what it is and how it’s used. Includes some real world architectures of leading web sites and their implementation of memcached. The accompanying recorded webinar can be accessed here: http://www.gear6.com/why-memcached

Statistics

Views

Total Views
15,766
Views on SlideShare
15,713
Embed Views
53

Actions

Likes
27
Downloads
396
Comments
1

11 Embeds 53

http://www.slideshare.net 32
http://www.techgig.com 8
http://jiyongcheng.com 3
http://localhost 3
http://www.desarrollowm.com 1
http://timesjobs.techgig.com 1
http://www.linkedin.com 1
http://techgig.in 1
http://1.arron.sinaapp.com 1
http://webcache.googleusercontent.com 1
http://www.slideee.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • black and green
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Why Memcached? Why Memcached? Presentation Transcript

  • Why Memcached? Presented by: Bill Takacs – Director, Product Management September 2009
  • Agenda • Ri of th dynamic web Rise f the d i b • Memcached • The web architecture • The evolution of a dynamic site and Memcached • Gear6 solution 2 : Copyright 2009 Gear6 Inc.
  • The Web: What’s Changed? • Population • Traffic • Content and applications 3 : Copyright 2009 Gear6 Inc.
  • Web Growth: Population Forrester: 2 2 billion people online globally by 2013 2.2 4 : Copyright 2009 Gear6 Inc.
  • Web Growth: Traffic Cisco: “Annual global IP traffic Annual will exceed two-thirds of a zettabyte ( (667 exabytes) in four y y ) years” [by 2013] Source: Cisco Visual Networking Index, 9 June 2009 5 : Copyright 2009 Gear6 Inc.
  • Web Growth: Application & Content Entertainment Social networking Static Media Dynamic Communication Community-generated content 6 : Copyright 2009 Gear6 Inc.
  • But growth can be Growth can be painful painful (VERY)
  • Clients Internet CDN ➜ Industry standard servers replaced proprietary SMP ➜ Shift to dynamic content puts strain on origin sites Interface ➜ Most sites (over 65%) based on LAMP or JAVA Balancer Proxy Load Net Web W Se ervers Apac che, Nginx, Lighttpd L Web Stack App A Se ervers Web Architecture PHP, Java, Rails, C C, ) Per Python rl, Database MySQL, M Pos stgreSQL ( 8 : Copyright 2009 Gear6 Inc. Stora Stora Stora Stora age Interfac age Interfac age Interfac age Interfac ce: ce: ce: ce: file, block, FC, SCS file, block, FC, SCS file, block, FC, SCS file, block, FC, SCS SI SI SI SI Storage
  • What to do? 9 : Copyright 2009 Gear6 Inc.
  • Clients Internet CDN Interface Balancer Proxy Load Net Webb Serve ers Cache Servers New Caching Architecture Memcached Apache, N Nginx, Lighttp pd Web S k W b Stack Appp Serve ers PHP, Java, R Rails, C, Perl, Pyt thon for Scaling Out Databa ase MySQL, PostgreS SQL 10 : Copyright 2009 Gear6 Inc. Storage Interface: Storage Interface: Storage Interface: Storage Interface: file, block, FC, SCSI Storage
  • Memcached: Pillar of Web 2.0 Architecture “Everything runs from memory in Web 2.0” Evan Weaver, Twitter, March 2009 11 : Copyright 2009 Gear6 Inc.
  • The Fix: Memcached “A high performance, distributed memory object caching g p , y j g system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load” Ref: http://www.danga.com/memcached/ • Big hash table • Created by Danga Interactive for LiveJournal • Significantly reduced database load • Perfect for web sites with high database load • In use by Facebook, Twitter, myYearbook, others 12 : Copyright 2009 Gear6 Inc.
  • More on Memcached • Takes advantage of available DRAM • Open source Ope sou ce • Distributed under BSD license • Server - Current version is 1.2.8 » http://www.danga.com/memcached/download.bml • M Many clients li t » http://code.google.com/p/memcached/wiki/Clients 13 : Copyright 2009 Gear6 Inc.
  • Why Memcached with MySQL? • Scale-out of dynamic web sites y • Page loads • Efficient resource utilization • Support for dozens to hundreds of nodes • Open source 14 : Copyright 2009 Gear6 Inc.
  • How Does Memcached Work? • Client - Server • H h Function Hash F ti • Memcached » Two stage 15 : Copyright 2009 Gear6 Inc.
  • Memcached Server • Slab allocator • Libevent based • Simple Protocol (no XML) • Server has internal hash table • Servers are dumb – they don’t know about each other 16 : Copyright 2009 Gear6 Inc.
  • Memcached Server • Limits » Key size = (250 bytes) » 1MB Limit » 32bit/64bit (maximum size of process) • LRU » Least recently accessed items are cycled out » One LRU exists per “slab class” slab class » LRU “evictions” need not be common • Threads? Yes 17 : Copyright 2009 Gear6 Inc.
  • Memcached Clients • Client hashes key to server list • Serializes t e object Se a es the • Many client libraries y • Authentication 18 : Copyright 2009 Gear6 Inc.
  • What about….. • Redundancy • Failover 19 : Copyright 2009 Gear6 Inc.
  • Consistent Hashing • Why? • How does it work? 20 : Copyright 2009 Gear6 Inc.
  • Commands • Storage commands: » Set / Add / Replace / Append / Prepend / CAS • Retrieval commands: » Get / Gets • Delete / increment / decrement • Stats 21 : Copyright 2009 Gear6 Inc.
  • Memcached UDFs for MySQL • Suite of functions that work with Memcached and MySQL • Leverage power of SQL Engine • Combine tasks mySQL • Open source application pp 22 : Copyright 2009 Gear6 Inc.
  • Putting it all together Client 1 Client-1 Client 2 Client-2 Client 3 Client-3 C Server X Server Y Server Z Key = value y Foo = seattle 23 : Copyright 2009 Gear6 Inc.
  • Evolution of a Dynamic Site #1 A day in the life of a growing web service Event: Site has growth in number of users, sessions, Action: Replicate database page views and apps, causing (and/or add more app servers) excessive read load on DB App Server App Server App Server App Server App Server App Server App Server App Server App Server write read write … write read read MySQL MySQL MySQL 24 : Copyright 2009 Gear6 Inc.
  • Evolution of a Dynamic Site #2 A day in the life of a growing web service Event: Individual caches on the Action: Add memcached server app/db servers are on servers with underutilized overwhelmed from chaotic, non- memory resources… results in deterministic content access even fewer reads to database memcached memcached memcached App Server App Server App Server App Server App Server App Server memcached memcached memcached App Server App Server App Server App Server App Server App Server write it … write it write it … write it read read read read MySQL MySQL MySQL MySQL 25 : Copyright 2009 Gear6 Inc.
  • Evolution of a Dynamic Site #3 A day in the life of a growing web service Event: Memcached needs more memory resources than Action: Move Memcached what are available on other servers to dedicated servers (shared) servers memcached memcached memcached App Server App Server App Server App Server App Server App Server memcached memcached memcached App Server App Server App Server App Server App Server App Server memcached memcached … memcached write … write write … write read read read read MySQL MySQL MySQL MySQL 26 : Copyright 2009 Gear6 Inc.
  • What Memcached is NOT: A persistent data store A database Application-specific A large object cache Fault-tolerant or highly available 27 : Copyright 2009 Gear6 Inc.
  • Memcached: Best Practices • Use with MySQL :-) y Q ) • Use on 64-bit servers • Cache “expensive operations” • Cache bi-directionally ( (read/write) ) • Design to withstand failures gracefully • Use consistent hashing 28 : Copyright 2009 Gear6 Inc.
  • Memcached: Best Practices (cont’d) • Careful with numbers of connections » Peak » Transitions • Evictions » Segment Memcached data into separate pools • O ti i sizing: instances and pools Optimize i i i t d l • Instrumentation 29 : Copyright 2009 Gear6 Inc.
  • Memcache Use Cases Site Type Repeatable Use Social networking Profile caching Content aggregation HTML/page caching Ad targeting Cookie/profile tracking Gaming and entertainment Session caching Location-based services DB query scaling Relationship R l ti hi Session caching S i hi E-commerce Session and HTML caching 30 : Copyright 2009 Gear6 Inc.
  • Use Case Example: Session Management • 4m+ daily visitors Web Servers • 15k hits/sec • 6k updates/sec Application S Servers with • Tens of thousands of Memcached Clients concurrent connections Memcached Servers • S Session tracked and ads i t k d d d are placed in accordance to session MySQL Servers 31 : Copyright 2009 Gear6 Inc.
  • Useful Memcached Tools p advanced reporter Track hot keys and clients in Memcached wireshark Dissect and analyze Memcached network traffic brutis Size and test changes to memcache clusters statsproxy View buffered Memcached stats in your browser cacti Graph and analyze Memcached statistics 32 : Copyright 2009 Gear6 Inc.
  • Statsproxy + Cacti Templates To use the cacti templates for memcached with statsproxy, you either need to modify the templates to use port 8080 or change the statsproxy config to use port 11211 33 : Copyright 2009 Gear6 Inc.
  • About Gear6 • First and leading provider of Memcached solutions • Memcached solution including • High density • High availability • Advanced memory management • Enhanced reporting capabilities biliti • Support for multi-tenancy • Disruption free software upgrades • 100% c e t co pat b e 00% client compatible 34 : Copyright 2009 Gear6 Inc.
  • Questions? Thank you for attending our webinar “Why Memcached” Bill Takacs Gear6 salesinfo@gear6.com +1 650 587 7118 and please visit our web site at: www.gear6.com 35 : Copyright 2009 Gear6 Inc.
  • References • Danga.com • Highscalability.com • Dev.gear6.com • Groups.google.com/group/memcached • Code.google.com/p/memcached • Twitter.com/gearsix • Cacti.net • Wireshark.org • http://dev.mysql.com/doc/mysql-ha-scalability/en/ha-memcached-using- deployment.html • http://dev.mysql.com/doc/mysql-ha-scalability/en/ha-memcached-using- hashtypes.html • http://jayant7k.blogspot.com/2009/04/memcached-replication.html • http://www.lexemetech.com/2007/11/consistent-hashing.html • http://www8.org/w8-papers/2a- webserver/caching/paper2.htmlhttp://www.last.fm/user/RJ/journal/2007/04/10/rz_l ibketama_-_a_consistent_hashing_algo_for_memcache_clients • http://bazaar.launchpad.net/~libmemcached- http://bazaar launchpad net/~libmemcached developers/libmemcached/trunk/revision/539 36 : Copyright 2009 Gear6 Inc.