SlideShare a Scribd company logo
1 of 27
Download to read offline
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.

More Related Content

What's hot

High Availability for OpenStack
High Availability for OpenStackHigh Availability for OpenStack
High Availability for OpenStackKamesh Pemmaraju
 
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA ArchitectureCeph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA ArchitectureDanielle Womboldt
 
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...OpenStack Korea Community
 
Disaggregating Ceph using NVMeoF
Disaggregating Ceph using NVMeoFDisaggregating Ceph using NVMeoF
Disaggregating Ceph using NVMeoFShapeBlue
 
OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介VirtualTech Japan Inc.
 
ロードバランスへの長い道
ロードバランスへの長い道ロードバランスへの長い道
ロードバランスへの長い道Jun Kato
 
OpenStack 개요 및 활용 사례 @ Community Open Camp with Microsoft
OpenStack 개요 및 활용 사례 @ Community Open Camp with MicrosoftOpenStack 개요 및 활용 사례 @ Community Open Camp with Microsoft
OpenStack 개요 및 활용 사례 @ Community Open Camp with MicrosoftIan Choi
 
Ceph and RocksDB
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDBSage Weil
 
Bloat and Fragmentation in PostgreSQL
Bloat and Fragmentation in PostgreSQLBloat and Fragmentation in PostgreSQL
Bloat and Fragmentation in PostgreSQLMasahiko Sawada
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기NeoClova
 
OpenStack Quantum Intro (OS Meetup 3-26-12)
OpenStack Quantum Intro (OS Meetup 3-26-12)OpenStack Quantum Intro (OS Meetup 3-26-12)
OpenStack Quantum Intro (OS Meetup 3-26-12)Dan Wendlandt
 
[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험NHN FORWARD
 
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL GiantVitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL GiantMatt Lord
 
MySQL 初めてのチューニング
MySQL 初めてのチューニングMySQL 初めてのチューニング
MySQL 初めてのチューニングCraft works
 
Ceph RBD Update - June 2021
Ceph RBD Update - June 2021Ceph RBD Update - June 2021
Ceph RBD Update - June 2021Ceph Community
 
RedHat OpenStack Platform Overview
RedHat OpenStack Platform OverviewRedHat OpenStack Platform Overview
RedHat OpenStack Platform Overviewindevlab
 
2011年度 新3年生向け
2011年度 新3年生向け2011年度 新3年生向け
2011年度 新3年生向けYuki Takahashi
 
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方Toru Makabe
 
BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)
BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)
BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)NTT DATA Technology & Innovation
 

What's hot (20)

MongoDB Oplog入門
MongoDB Oplog入門MongoDB Oplog入門
MongoDB Oplog入門
 
High Availability for OpenStack
High Availability for OpenStackHigh Availability for OpenStack
High Availability for OpenStack
 
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA ArchitectureCeph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
 
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
 
Disaggregating Ceph using NVMeoF
Disaggregating Ceph using NVMeoFDisaggregating Ceph using NVMeoF
Disaggregating Ceph using NVMeoF
 
OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介OpenStackを使用したGPU仮想化IaaS環境 事例紹介
OpenStackを使用したGPU仮想化IaaS環境 事例紹介
 
ロードバランスへの長い道
ロードバランスへの長い道ロードバランスへの長い道
ロードバランスへの長い道
 
OpenStack 개요 및 활용 사례 @ Community Open Camp with Microsoft
OpenStack 개요 및 활용 사례 @ Community Open Camp with MicrosoftOpenStack 개요 및 활용 사례 @ Community Open Camp with Microsoft
OpenStack 개요 및 활용 사례 @ Community Open Camp with Microsoft
 
Ceph and RocksDB
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDB
 
Bloat and Fragmentation in PostgreSQL
Bloat and Fragmentation in PostgreSQLBloat and Fragmentation in PostgreSQL
Bloat and Fragmentation in PostgreSQL
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기
 
OpenStack Quantum Intro (OS Meetup 3-26-12)
OpenStack Quantum Intro (OS Meetup 3-26-12)OpenStack Quantum Intro (OS Meetup 3-26-12)
OpenStack Quantum Intro (OS Meetup 3-26-12)
 
[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험
 
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL GiantVitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
 
MySQL 初めてのチューニング
MySQL 初めてのチューニングMySQL 初めてのチューニング
MySQL 初めてのチューニング
 
Ceph RBD Update - June 2021
Ceph RBD Update - June 2021Ceph RBD Update - June 2021
Ceph RBD Update - June 2021
 
RedHat OpenStack Platform Overview
RedHat OpenStack Platform OverviewRedHat OpenStack Platform Overview
RedHat OpenStack Platform Overview
 
2011年度 新3年生向け
2011年度 新3年生向け2011年度 新3年生向け
2011年度 新3年生向け
 
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
 
BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)
BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)
BigtopでHadoopをビルドする(Open Source Conference 2021 Online/Spring 発表資料)
 

Similar to 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 MemcachedGear6
 
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...Gear6
 
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 InternetAchieve 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 InternetAchieve Internet
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010Mark Atwood
 
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 TutorialColin Charles
 
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 moreMariaDB Corporation
 
Couchdb + Membase = Couchbase
Couchdb + Membase = CouchbaseCouchdb + Membase = Couchbase
Couchdb + Membase = Couchbaseiammutex
 
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 CharlesNETWAYS
 
MariaDB on Docker
MariaDB on DockerMariaDB on Docker
MariaDB on DockerMariaDB plc
 
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 MoreMariaDB Corporation
 
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 MemcachedAcquia
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutSander Temme
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep DiveAmazon Web Services
 
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 HowSeth Miller
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentationNagesh Chinkeri
 
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 2016Colin Charles
 
Introduction to MariaDB
Introduction to MariaDBIntroduction to MariaDB
Introduction to MariaDBJongJin Lee
 
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 EnvironmentJean-François Gagné
 

Similar to 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
 
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
 
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
 

More from Gear6

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 13Gear6
 
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 CloudGear6
 
Cloud Scaling with Memcached
Cloud Scaling with MemcachedCloud Scaling with Memcached
Cloud Scaling with MemcachedGear6
 
Why Memcached?
Why Memcached?Why Memcached?
Why Memcached?Gear6
 
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 WebGear6
 
Gear6 Web Cache Overview
Gear6 Web Cache OverviewGear6 Web Cache Overview
Gear6 Web Cache OverviewGear6
 

More from 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
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
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 MenDelhi Call girls
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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 Nanonetsnaman860154
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
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
 

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.