SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...
Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...
Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...
HostedbyConfluent
 
Introduction to Streaming Analytics
Introduction to Streaming AnalyticsIntroduction to Streaming Analytics
Introduction to Streaming Analytics
Guido Schmutz
 
Expose your event-driven data to the outside world using webhooks powered by ...
Expose your event-driven data to the outside world using webhooks powered by ...Expose your event-driven data to the outside world using webhooks powered by ...
Expose your event-driven data to the outside world using webhooks powered by ...
HostedbyConfluent
 

La actualidad más candente (20)

Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...
Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...
Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...
 
Processing Semantically-Ordered Streams in Financial Services
Processing Semantically-Ordered Streams in Financial ServicesProcessing Semantically-Ordered Streams in Financial Services
Processing Semantically-Ordered Streams in Financial Services
 
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
 
Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?
 
How Uber scaled its Real Time Infrastructure to Trillion events per day
How Uber scaled its Real Time Infrastructure to Trillion events per dayHow Uber scaled its Real Time Infrastructure to Trillion events per day
How Uber scaled its Real Time Infrastructure to Trillion events per day
 
Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...
Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...
Apache Pinot Case Study: Building Distributed Analytics Systems Using Apache ...
 
Distributed Tracing for Kafka with OpenTelemetry with Daniel Kim | Kafka Summ...
Distributed Tracing for Kafka with OpenTelemetry with Daniel Kim | Kafka Summ...Distributed Tracing for Kafka with OpenTelemetry with Daniel Kim | Kafka Summ...
Distributed Tracing for Kafka with OpenTelemetry with Daniel Kim | Kafka Summ...
 
Introduction to Streaming Analytics
Introduction to Streaming AnalyticsIntroduction to Streaming Analytics
Introduction to Streaming Analytics
 
AWS re:Invent 2016: Deep Dive on Amazon Aurora (DAT303)
AWS re:Invent 2016: Deep Dive on Amazon Aurora (DAT303)AWS re:Invent 2016: Deep Dive on Amazon Aurora (DAT303)
AWS re:Invent 2016: Deep Dive on Amazon Aurora (DAT303)
 
0-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 2019
0-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 20190-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 2019
0-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 2019
 
Expose your event-driven data to the outside world using webhooks powered by ...
Expose your event-driven data to the outside world using webhooks powered by ...Expose your event-driven data to the outside world using webhooks powered by ...
Expose your event-driven data to the outside world using webhooks powered by ...
 
Kafka At Scale in the Cloud
Kafka At Scale in the CloudKafka At Scale in the Cloud
Kafka At Scale in the Cloud
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka Streams
 
Kafka at Peak Performance
Kafka at Peak PerformanceKafka at Peak Performance
Kafka at Peak Performance
 
DAT202_Getting started with Amazon Aurora
DAT202_Getting started with Amazon AuroraDAT202_Getting started with Amazon Aurora
DAT202_Getting started with Amazon Aurora
 
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!
 
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
 
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraApache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native Era
 
Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2
 

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

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

Más de Gear6

Más de 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

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.