SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Creating High Availability Services for Your
Memcached Environment
Presented by:
         Bill Takacs – Director, Product Management


25 August 2009
Agenda
     • Overview of Memcached


     • High Availability defined


     • Why HA Memcached


     • Options for HA Memcached


     • Gear6 Solution



2 : Copyright 2009 Gear6 Inc.
Memcached

             “A high performance, distributed memory object
             caching 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 Live Journal

     • Significantly reduced database load

     • Perfect for web sites with high database load

     • In use by Facebook, Twitter, MyYearBook, others

3 : Copyright 2009 Gear6 Inc.
More on Memcached

     • Takes advantage of available DRAM

     • Open source

     • Distributed under BSD license

     • Server - Current version is 1.4
           » http://www.danga.com/memcached/download.bml

     • Many Clients
           » http://code.google.com/p/memcached/wiki/Clients


4 : Copyright 2009 Gear6 Inc.
How Does Memcached Work?

                                • Client - Server

                                • Hash Function

                                • Memcached
                                  » Two stage
                                  » Key / value pair




5 : 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




6 : 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”
           » LRU “evictions” need not be common

     • Threads? Yes



7 : Copyright 2009 Gear6 Inc.
Memcached Clients

     • Client hashes key to server list

     • Serializes the object

     • Many client libraries

     • Authentication




8 : Copyright 2009 Gear6 Inc.
Commands

     • Storage commands:
           » Set / Add / Replace /
             Append / Prepend / CAS


     • Retrieval commands:
           » Get / Gets

     • Delete / increment /
       decrement

     • Stats


9 : Copyright 2009 Gear6 Inc.
High Availability
     • High availability: System
       design and implementation
       that ensures a certain
       absolute degree of
       operational continuity
       during a given measurement
       period.

     • Organizations
           » OpenSAF Foundation
           » SAFourm


     • HA for Memcache

10 : Copyright 2009 Gear6 Inc.
Key Concepts
     • Clustering

     • Failover

     • Replication




11 : Copyright 2009 Gear6 Inc.
The case for HA Memcache
     • What Memcache is NOT:
           »   A persistent data store
           »   A database
           »   Application specific
           »   Clustered
           »   A large object cache


     • The intent is if its not in cache hit the DB

     • Great when your site’s traffic is small

     • Let’s look at the evolution of a site


12 : Copyright 2009 Gear6 Inc.
The Beginning



                                            Web Servers


                                  MySQL
                                 Database




13 : Copyright 2009 Gear6 Inc.
Web traffic grows



                                            Memcached     Web Servers
                                                    Memcached
                                  MySQL                     Memcached
                                 Database




           Dynamic content:

           Result: Site slows down or worse site unavailable



14 : Copyright 2009 Gear6 Inc.
Add Memcached as traffic increases
                                                       Web Servers




                          MySQL
                                    Memcached
                         Database
                                           Memcached




      Increases performance but as the site grows so does Memcached




15 : Copyright 2009 Gear6 Inc.
Even more traffic

                                                                     Web Servers




                MySQL
               Databases


                                                 Memcached

                                                 Memcached   Memcache Server(s)
                                                 Memcached



                                 Reliance on memcached for performance




16 : Copyright 2009 Gear6 Inc.
Options for HA Memcached


     Not Many…

     • DIY

     • Or - Find a solution that leverages memcached that
         has high availability features




17 : Copyright 2009 Gear6 Inc.
Consistent Hashing
     • Why?

     • How does it work?

     • Where




18 : Copyright 2009 Gear6 Inc.
Consistent Hashing - Example
     • PHP – Flexihash – code.google.com/p/flexihash
     <?php
     $hash = new Flexihash();
     // bulk add
     $hash->addTargets(array('cache-1', 'cache-2', 'cache-3'));

     // simple lookup
     $hash->lookup('object-a'); // "cache-1"
     $hash->lookup('object-b'); // "cache-2"

     // add and remove
     $hash
      ->addTarget('cache-4')
      ->removeTarget('cache-1');

     // lookup with next-best fallback (for redundant writes)
     $hash->lookupList('object', 2); // ["cache-2", "cache-4"]

     // remove cache-2, expect object to hash to cache-4
     $hash->removeTarget('cache-2');
     $hash->lookup('object'); // "cache-4"



19 : Copyright 2009 Gear6 Inc.
Replication
     • How
           » Repcache
           » Libmemcached


     • Why
           » Two datacenters – master / slave dc’s
           » Keys stored on multiple machines to make them ‘more”
             available




20 : Copyright 2009 Gear6 Inc.
Replication - Repcache Example
     • Downloaded the memcached-(version)-repcached-
       (version).tar.gz source and simply compiled it.
     ./configure --enable-replication
     make
     sudo make install

     Start two instances of memcached on ports 11211 & 11222

     btak@csn07:~/php$ memcached -p 11211 -m 64 -x 127.0.0.1 -v
     replication: connect (peer=127.0.0.1:11212)
     replication: marugoto copying
     replication: close
     replication: listen

     btak@csn07:~/php$ memcached -p 11222 -m 64 -x 127.0.0.1 -v
     replication: connect (peer=127.0.0.1:11212)
     replication: marugoto copying
     Replication: start

21 : Copyright 2009 Gear6 Inc.
Replication – Repcache Example Cont
     Now set and get a value on instance on   Connect to port 11222 and try getting
       port 11211                               this value

     btak@csn07:~$ telnet localhost 11211     btak@csn07:~$ telnet localhost 11222
     Trying 127.0.0.1...                      • Trying 127.0.0.1...
     Connected to localhost.                  • Connected to localhost.
     Escape character is '^]'.                • Escape character is '^]'.
     set hello 0 0 5                          • get hello
     world                                    • VALUE hello 0 5
     STORED                                   • world
     get hello                                • END
     VALUE hello 0 5
     world
     END




22 : Copyright 2009 Gear6 Inc.
Replication – Repcache Example Cont
     Suppose server on 11211 goes down    Let’s see if its replicated on 11211

     On port 11211                        btak@csn07:~$ telnet localhost 11211
     Killed                               Trying 127.0.0.1...
     btak@csn07:~/php$ memcached -11211   Connected to localhost.
        -m 64 -x 127.0.0.1 -v             Escape character is '^]'.
     replication: connect                 get hello
        (peer=127.0.0.1:11222)            VALUE hello 0 5
     replication: marugoto copying        world
     replication: start                   END
                                          get key
     On port 11222
                                          VALUE key 0 5
     <---snip
                                          myval
     replication: close
                                          END
     replication: listen
     replication: accept
     replication: marugoto start
     replication: marugoto 2
     replication: marugoto owari
     <---snip-->

23 : Copyright 2009 Gear6 Inc.
Clustering
     • www.linux-ha.org

     • Provides high availability clustering solution

     • Can enable memcached cluster

     • Combine with consistent hashing




24 : 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

          • Support for multi-tenancy

          • Disruption free
            software upgrades

          • 100% client compatible


25 : Copyright 2009 Gear6 Inc.
References
     • 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
       _libketama_-_a_consistent_hashing_algo_for_memcache_clients

     • http://bazaar.launchpad.net/~libmemcached-
       developers/libmemcached/trunk/revision/539




26 : Copyright 2009 Gear6 Inc.
Questions?



                                 Thank you for attending
          “Creating High Availability Services for Your Memcached
                     Environment presented” by Gear6




                                        Bill Takacs
                                           Gear6
                                   salesinfo@gear6.com
                                      +1 650 587 7118

27 : Copyright 2009 Gear6 Inc.

Weitere ähnliche Inhalte

Was ist angesagt?

[D35] インメモリーデータベース徹底比較 by Komori
[D35] インメモリーデータベース徹底比較 by Komori[D35] インメモリーデータベース徹底比較 by Komori
[D35] インメモリーデータベース徹底比較 by Komori
Insight Technology, Inc.
 
Scaling Redis To 1M Ops/Sec: Jane Paek
Scaling Redis To 1M Ops/Sec: Jane PaekScaling Redis To 1M Ops/Sec: Jane Paek
Scaling Redis To 1M Ops/Sec: Jane Paek
Redis Labs
 

Was ist angesagt? (20)

Snowflakeって実際どうなの?数多のDBを使い倒した猛者が語る
Snowflakeって実際どうなの?数多のDBを使い倒した猛者が語るSnowflakeって実際どうなの?数多のDBを使い倒した猛者が語る
Snowflakeって実際どうなの?数多のDBを使い倒した猛者が語る
 
Cephのベンチマークをしました
CephのベンチマークをしましたCephのベンチマークをしました
Cephのベンチマークをしました
 
[Gridgain]인메모리컴퓨팅 및 국내레퍼런스 소개
[Gridgain]인메모리컴퓨팅 및 국내레퍼런스 소개 [Gridgain]인메모리컴퓨팅 및 국내레퍼런스 소개
[Gridgain]인메모리컴퓨팅 및 국내레퍼런스 소개
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability Tutorial
 
HA環境構築のベスト・プラクティス
HA環境構築のベスト・プラクティスHA環境構築のベスト・プラクティス
HA環境構築のベスト・プラクティス
 
[D35] インメモリーデータベース徹底比較 by Komori
[D35] インメモリーデータベース徹底比較 by Komori[D35] インメモリーデータベース徹底比較 by Komori
[D35] インメモリーデータベース徹底比較 by Komori
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
 
パブリッククラウド(AWS/Azure)のバックアップもVeeamで決まり! Veeam最新プロダクトご紹介セミナー
パブリッククラウド(AWS/Azure)のバックアップもVeeamで決まり! Veeam最新プロダクトご紹介セミナーパブリッククラウド(AWS/Azure)のバックアップもVeeamで決まり! Veeam最新プロダクトご紹介セミナー
パブリッククラウド(AWS/Azure)のバックアップもVeeamで決まり! Veeam最新プロダクトご紹介セミナー
 
AWS EMR Cost optimization
AWS EMR Cost optimizationAWS EMR Cost optimization
AWS EMR Cost optimization
 
ログ解析基盤におけるストリーム処理パイプラインについて
ログ解析基盤におけるストリーム処理パイプラインについてログ解析基盤におけるストリーム処理パイプラインについて
ログ解析基盤におけるストリーム処理パイプラインについて
 
What's New in MySQL 5.7 InnoDB
What's New in MySQL 5.7 InnoDBWhat's New in MySQL 5.7 InnoDB
What's New in MySQL 5.7 InnoDB
 
スケーラブルなシステムのためのHBaseスキーマ設計 #hcj13w
スケーラブルなシステムのためのHBaseスキーマ設計 #hcj13wスケーラブルなシステムのためのHBaseスキーマ設計 #hcj13w
スケーラブルなシステムのためのHBaseスキーマ設計 #hcj13w
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelines
 
Scaling Redis To 1M Ops/Sec: Jane Paek
Scaling Redis To 1M Ops/Sec: Jane PaekScaling Redis To 1M Ops/Sec: Jane Paek
Scaling Redis To 1M Ops/Sec: Jane Paek
 
PostgreSQL DBのバックアップを一元化しよう
PostgreSQL DBのバックアップを一元化しようPostgreSQL DBのバックアップを一元化しよう
PostgreSQL DBのバックアップを一元化しよう
 
Cassandra & puppet, scaling data at $15 per month
Cassandra & puppet, scaling data at $15 per monthCassandra & puppet, scaling data at $15 per month
Cassandra & puppet, scaling data at $15 per month
 
【Veeam基礎】簡単解説!バックアップ可能な環境や機能をご紹介
【Veeam基礎】簡単解説!バックアップ可能な環境や機能をご紹介【Veeam基礎】簡単解説!バックアップ可能な環境や機能をご紹介
【Veeam基礎】簡単解説!バックアップ可能な環境や機能をご紹介
 
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
 
Apache tinkerpopとグラフデータベースの世界
Apache tinkerpopとグラフデータベースの世界Apache tinkerpopとグラフデータベースの世界
Apache tinkerpopとグラフデータベースの世界
 
さいきんの InnoDB Adaptive Flushing (仮)
さいきんの InnoDB Adaptive Flushing (仮)さいきんの InnoDB Adaptive Flushing (仮)
さいきんの InnoDB Adaptive Flushing (仮)
 

Ähnlich wie Implementing High Availability Caching with Memcached

Gear6 Webinar - MySQL Scaling with Memcached
Gear6 Webinar - MySQL Scaling with MemcachedGear6 Webinar - MySQL Scaling with Memcached
Gear6 Webinar - MySQL Scaling with Memcached
Gear6
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010
Mark Atwood
 
Improving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with MemcachedImproving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with Memcached
Acquia
 

Ähnlich wie Implementing High Availability Caching with Memcached (20)

Gear6 Webinar - MySQL Scaling with Memcached
Gear6 Webinar - MySQL Scaling with MemcachedGear6 Webinar - MySQL Scaling with Memcached
Gear6 Webinar - MySQL Scaling with Memcached
 
Gear6 and Scaling Website Performance: Caching Session and Profile Data with...
Gear6 and Scaling Website Performance:  Caching Session and Profile Data with...Gear6 and Scaling Website Performance:  Caching Session and Profile Data with...
Gear6 and Scaling Website Performance: Caching Session and Profile Data with...
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010
 
The New MariaDB Offering - MariaDB 10, MaxScale and more
The New MariaDB Offering - MariaDB 10, MaxScale and moreThe New MariaDB Offering - MariaDB 10, MaxScale and more
The New MariaDB Offering - MariaDB 10, MaxScale and more
 
Couchdb + Membase = Couchbase
Couchdb + Membase = CouchbaseCouchdb + Membase = Couchbase
Couchdb + Membase = Couchbase
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
 
OpenSolaris Web Stack MySQL BOF
OpenSolaris Web Stack MySQL BOFOpenSolaris Web Stack MySQL BOF
OpenSolaris Web Stack MySQL BOF
 
MariaDB on Docker
MariaDB on DockerMariaDB on Docker
MariaDB on Docker
 
The New MariaDB Offering: MariaDB 10, MaxScale and More
The New MariaDB Offering: MariaDB 10, MaxScale and MoreThe New MariaDB Offering: MariaDB 10, MaxScale and More
The New MariaDB Offering: MariaDB 10, MaxScale and More
 
Improving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with MemcachedImproving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with Memcached
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling Out
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive
 
Oracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and HowOracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and How
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentation
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
 
Introduction to MariaDB
Introduction to MariaDBIntroduction to MariaDB
Introduction to MariaDB
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
The Complete MariaDB Server tutorial
The Complete MariaDB Server tutorialThe Complete MariaDB Server tutorial
The Complete MariaDB Server tutorial
 

Mehr von Gear6

Mehr von Gear6 (6)

Evolution of a Memcached Deployment Webinar 2010 01 13
Evolution of a Memcached Deployment Webinar 2010 01 13Evolution of a Memcached Deployment Webinar 2010 01 13
Evolution of a Memcached Deployment Webinar 2010 01 13
 
Introduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for CloudIntroduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for Cloud
 
Cloud Scaling with Memcached
Cloud Scaling with MemcachedCloud Scaling with Memcached
Cloud Scaling with Memcached
 
Why Memcached?
Why Memcached?Why Memcached?
Why Memcached?
 
Memcached and the Rise of the Dynamic Web
Memcached and the Rise of the Dynamic WebMemcached and the Rise of the Dynamic Web
Memcached and the Rise of the Dynamic Web
 
Gear6 Web Cache Overview
Gear6 Web Cache OverviewGear6 Web Cache Overview
Gear6 Web Cache Overview
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Implementing High Availability Caching with Memcached

  • 1. Creating High Availability Services for Your Memcached Environment Presented by: Bill Takacs – Director, Product Management 25 August 2009
  • 2. Agenda • Overview of Memcached • High Availability defined • Why HA Memcached • Options for HA Memcached • Gear6 Solution 2 : Copyright 2009 Gear6 Inc.
  • 3. Memcached “A high performance, distributed memory object caching 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 Live Journal • Significantly reduced database load • Perfect for web sites with high database load • In use by Facebook, Twitter, MyYearBook, others 3 : Copyright 2009 Gear6 Inc.
  • 4. More on Memcached • Takes advantage of available DRAM • Open source • Distributed under BSD license • Server - Current version is 1.4 » http://www.danga.com/memcached/download.bml • Many Clients » http://code.google.com/p/memcached/wiki/Clients 4 : Copyright 2009 Gear6 Inc.
  • 5. How Does Memcached Work? • Client - Server • Hash Function • Memcached » Two stage » Key / value pair 5 : Copyright 2009 Gear6 Inc.
  • 6. 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 6 : Copyright 2009 Gear6 Inc.
  • 7. 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” » LRU “evictions” need not be common • Threads? Yes 7 : Copyright 2009 Gear6 Inc.
  • 8. Memcached Clients • Client hashes key to server list • Serializes the object • Many client libraries • Authentication 8 : Copyright 2009 Gear6 Inc.
  • 9. Commands • Storage commands: » Set / Add / Replace / Append / Prepend / CAS • Retrieval commands: » Get / Gets • Delete / increment / decrement • Stats 9 : Copyright 2009 Gear6 Inc.
  • 10. High Availability • High availability: System design and implementation that ensures a certain absolute degree of operational continuity during a given measurement period. • Organizations » OpenSAF Foundation » SAFourm • HA for Memcache 10 : Copyright 2009 Gear6 Inc.
  • 11. Key Concepts • Clustering • Failover • Replication 11 : Copyright 2009 Gear6 Inc.
  • 12. The case for HA Memcache • What Memcache is NOT: » A persistent data store » A database » Application specific » Clustered » A large object cache • The intent is if its not in cache hit the DB • Great when your site’s traffic is small • Let’s look at the evolution of a site 12 : Copyright 2009 Gear6 Inc.
  • 13. The Beginning Web Servers MySQL Database 13 : Copyright 2009 Gear6 Inc.
  • 14. Web traffic grows Memcached Web Servers Memcached MySQL Memcached Database Dynamic content: Result: Site slows down or worse site unavailable 14 : Copyright 2009 Gear6 Inc.
  • 15. Add Memcached as traffic increases Web Servers MySQL Memcached Database Memcached Increases performance but as the site grows so does Memcached 15 : Copyright 2009 Gear6 Inc.
  • 16. Even more traffic Web Servers MySQL Databases Memcached Memcached Memcache Server(s) Memcached Reliance on memcached for performance 16 : Copyright 2009 Gear6 Inc.
  • 17. Options for HA Memcached Not Many… • DIY • Or - Find a solution that leverages memcached that has high availability features 17 : Copyright 2009 Gear6 Inc.
  • 18. Consistent Hashing • Why? • How does it work? • Where 18 : Copyright 2009 Gear6 Inc.
  • 19. Consistent Hashing - Example • PHP – Flexihash – code.google.com/p/flexihash <?php $hash = new Flexihash(); // bulk add $hash->addTargets(array('cache-1', 'cache-2', 'cache-3')); // simple lookup $hash->lookup('object-a'); // "cache-1" $hash->lookup('object-b'); // "cache-2" // add and remove $hash ->addTarget('cache-4') ->removeTarget('cache-1'); // lookup with next-best fallback (for redundant writes) $hash->lookupList('object', 2); // ["cache-2", "cache-4"] // remove cache-2, expect object to hash to cache-4 $hash->removeTarget('cache-2'); $hash->lookup('object'); // "cache-4" 19 : Copyright 2009 Gear6 Inc.
  • 20. Replication • How » Repcache » Libmemcached • Why » Two datacenters – master / slave dc’s » Keys stored on multiple machines to make them ‘more” available 20 : Copyright 2009 Gear6 Inc.
  • 21. Replication - Repcache Example • Downloaded the memcached-(version)-repcached- (version).tar.gz source and simply compiled it. ./configure --enable-replication make sudo make install Start two instances of memcached on ports 11211 & 11222 btak@csn07:~/php$ memcached -p 11211 -m 64 -x 127.0.0.1 -v replication: connect (peer=127.0.0.1:11212) replication: marugoto copying replication: close replication: listen btak@csn07:~/php$ memcached -p 11222 -m 64 -x 127.0.0.1 -v replication: connect (peer=127.0.0.1:11212) replication: marugoto copying Replication: start 21 : Copyright 2009 Gear6 Inc.
  • 22. Replication – Repcache Example Cont Now set and get a value on instance on Connect to port 11222 and try getting port 11211 this value btak@csn07:~$ telnet localhost 11211 btak@csn07:~$ telnet localhost 11222 Trying 127.0.0.1... • Trying 127.0.0.1... Connected to localhost. • Connected to localhost. Escape character is '^]'. • Escape character is '^]'. set hello 0 0 5 • get hello world • VALUE hello 0 5 STORED • world get hello • END VALUE hello 0 5 world END 22 : Copyright 2009 Gear6 Inc.
  • 23. Replication – Repcache Example Cont Suppose server on 11211 goes down Let’s see if its replicated on 11211 On port 11211 btak@csn07:~$ telnet localhost 11211 Killed Trying 127.0.0.1... btak@csn07:~/php$ memcached -11211 Connected to localhost. -m 64 -x 127.0.0.1 -v Escape character is '^]'. replication: connect get hello (peer=127.0.0.1:11222) VALUE hello 0 5 replication: marugoto copying world replication: start END get key On port 11222 VALUE key 0 5 <---snip myval replication: close END replication: listen replication: accept replication: marugoto start replication: marugoto 2 replication: marugoto owari <---snip--> 23 : Copyright 2009 Gear6 Inc.
  • 24. Clustering • www.linux-ha.org • Provides high availability clustering solution • Can enable memcached cluster • Combine with consistent hashing 24 : Copyright 2009 Gear6 Inc.
  • 25. About Gear6 • First and leading provider of Memcached solutions • Memcached solution including • High density • High Availability • Advanced memory management • Enhanced reporting capabilities • Support for multi-tenancy • Disruption free software upgrades • 100% client compatible 25 : Copyright 2009 Gear6 Inc.
  • 26. References • 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 _libketama_-_a_consistent_hashing_algo_for_memcache_clients • http://bazaar.launchpad.net/~libmemcached- developers/libmemcached/trunk/revision/539 26 : Copyright 2009 Gear6 Inc.
  • 27. Questions? Thank you for attending “Creating High Availability Services for Your Memcached Environment presented” by Gear6 Bill Takacs Gear6 salesinfo@gear6.com +1 650 587 7118 27 : Copyright 2009 Gear6 Inc.