SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Introduction to Memcached

Mark Atwood <matwood@gear6.com>
What is it?

     •open source
     •high performance
     •distributed
     •memory
     •object
     •cache
: Copyright 2009 Gear6 Inc.
How we got here


     •persistent app service processes
     •local variables
     •filesystem caching
     •database query caching
     •shared memory segment caching
     •apache server fragment caching



                              None of these scale OUT
: Copyright 2009 Gear6 Inc.
Scale out
     • Multiple machines access the same memcache
     • Multiple machines running the memcache

     • Buy more machines, not bigger machines

     • Each memcache node is a hash table
     • Memcache client library does consistent hashing
           » looks at key
           » computes hash
           » picks node




: Copyright 2009 Gear6 Inc.
What about the MySQL query cache?



     • A hack that makes poorly written PHP actually work
     • Heavy write load -> Fail
     • Heavy load -> Fail
     • Increasing CPU count -> Fail
     • Database server memory is precious, better spent on
       innodb buffer pool




: Copyright 2009 Gear6 Inc.
Where Memcached Fits


                                                                    Web Stack                                                       Net
                                                                                                                                 Interface
    Storage                                                                                                                                             Clients

                                                                     PHP, Java, Rails, C,
                                                                                                                                             Internet
                                                         Database




                                                                                                      Apache, Nginx,
                       Storage Interface:




                                                                                            Servers



                                                                                                                       Servers
                                                                       Perl, Python
                                            PostgreSQL
                                              MySQL,




                                                                                                                        Web
                                                                                              App
                                                                                                                                  Proxy
                                                                                                                                              CDN

                                                                                                                                  Load                  client cache
 Storage cache                                                                                                                   Balancer

                                                                          Cache Services
                                                                                            memcached




: Copyright 2009 Gear6 Inc.
Memcached: Technical Background
     • Written in C
     • DHT (Distributed Hash Table)                  Memcached
     • 2 Stage                                       Protocol Handler
           » Clients: hash key  server
           » Server: hash key  value
     • Slab Allocator, fast                               Hash
     • Eviction algorithm: LRU
     • Supported clients
           » Java, PHP, Ruby, Perl, Python, C, etc    Slab Manager
     • Key max size: max 250 bytes
     • Object max size: 1 MiB                         Item Manager
     • BSD like License




: Copyright 2009 Gear6 Inc.
Application Changes
     Application Requirements:
           » Modify calls to subsequent
             application logic or database by use
             of memcached client
           » Send requests to memcached server
           » Check application or db layer next
           » Update memcached

     Cons:
           » Requires coding
           » Generic
     Pros:
           »   Some app frameworks already
           »   Performance gains
           »   Back-end complexity reduction
           »   Generic

                                                    Source: MySQL.com


: Copyright 2009 Gear6 Inc.
When coding, think of places to use it
     • In Perl & Python, when you have a big dictionary /
       hash to keep track of work
     • Or a highly used big lookup table.
     • There are modules to “tie” memcache to your
       language’s dictionary API
     • If you are in C, and are wishing for good dictionary
     • To share state between processes




: Copyright 2009 Gear6 Inc.
Pattern: sessions
     • Keep session state in the memcache
     • Turnkey for PHP and for Django
           » pecl install pecl/memcache
           » Enable memcache session handler support? [yes] : yes


     • Win! Avoid sticky HTTP load balancing
     • Win! Avoid hot session table in database
           » often the #1 performance hotspot for web apps




: Copyright 2009 Gear6 Inc.
Pattern: rate limiting
     • Limit access speed
           »   to   login attempts
           »   to   page accesses
           »   to   API calls
           »   to   expensive operations

     • Key of $prefix.$sourceip.$currtime
     • Value of access count
     • Use ADD method to update
     • Use MGET method to retrieve
     • Use expiration to delete



: Copyright 2009 Gear6 Inc.
Pattern: SQL query cache
     • On every SQL query
     • SQL statement is the key
     • Result set is the value
     • Use expire to delete
     • Beware of inconsistancy, but it may be ok




: Copyright 2009 Gear6 Inc.
MySQL User Defined Functions
     • Access memcached from inside queries
     • And from inside stored procedures
     • Can implement the “check cache, then read from table”
       pattern from inside the SQL query, without having to
       rewrite the app
     • Ships with Drizzle DB




: Copyright 2009 Gear6 Inc.
Other things to keep in memcache
     • HTML fragments
     • Image thumbnails
     • Message headers & bodies
     • Unread message list
     • Unread message counter
     • Contact list
     • Work queues
     • API keys
     • Nonces
     • Gearman staged work
     • Remote data fetched over the web
     • Structured file read cache (Wafflegrid)

: Copyright 2009 Gear6 Inc.
Thank you!




                                  Mark Atwood
                                   Director of
                              Community Development
                              <matwood@gear6.com>

: Copyright 2009 Gear6 Inc.

Weitere ähnliche Inhalte

Was ist angesagt?

Memcached Code Camp 2009
Memcached Code Camp 2009Memcached Code Camp 2009
Memcached Code Camp 2009NorthScale
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixBruce Snyder
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQBruce Snyder
 
Distributed Caching Essential Lessons (Ts 1402)
Distributed Caching   Essential Lessons (Ts 1402)Distributed Caching   Essential Lessons (Ts 1402)
Distributed Caching Essential Lessons (Ts 1402)Yury Kaliaha
 
Red Hat Open Day JBoss Fuse
Red Hat Open Day JBoss FuseRed Hat Open Day JBoss Fuse
Red Hat Open Day JBoss FuseAdrian Gigante
 
Membase Introduction
Membase IntroductionMembase Introduction
Membase IntroductionMembase
 
Membase East Coast Meetups
Membase East Coast MeetupsMembase East Coast Meetups
Membase East Coast MeetupsMembase
 
Membase Meetup - Silicon Valley
Membase Meetup - Silicon ValleyMembase Meetup - Silicon Valley
Membase Meetup - Silicon ValleyMembase
 
From distributed caches to in-memory data grids
From distributed caches to in-memory data gridsFrom distributed caches to in-memory data grids
From distributed caches to in-memory data gridsMax Alexejev
 
AWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data CommonsAWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data CommonsHannes Mühleisen
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixBruce Snyder
 
An Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformAn Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformMongoDB
 
Caching technology comparison
Caching technology comparisonCaching technology comparison
Caching technology comparisonRohit Kelapure
 
Caching technology comparison
Caching technology comparisonCaching technology comparison
Caching technology comparisonRohit Kelapure
 
Membase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San FranciscoMembase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San FranciscoMembase
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 
캐시 분산처리 인프라
캐시 분산처리 인프라캐시 분산처리 인프라
캐시 분산처리 인프라Park Chunduck
 

Was ist angesagt? (20)

Memcached Code Camp 2009
Memcached Code Camp 2009Memcached Code Camp 2009
Memcached Code Camp 2009
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
 
Cassandra as Memcache
Cassandra as MemcacheCassandra as Memcache
Cassandra as Memcache
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQ
 
Distributed Caching Essential Lessons (Ts 1402)
Distributed Caching   Essential Lessons (Ts 1402)Distributed Caching   Essential Lessons (Ts 1402)
Distributed Caching Essential Lessons (Ts 1402)
 
Red Hat Open Day JBoss Fuse
Red Hat Open Day JBoss FuseRed Hat Open Day JBoss Fuse
Red Hat Open Day JBoss Fuse
 
Membase Introduction
Membase IntroductionMembase Introduction
Membase Introduction
 
Membase East Coast Meetups
Membase East Coast MeetupsMembase East Coast Meetups
Membase East Coast Meetups
 
Membase Meetup - Silicon Valley
Membase Meetup - Silicon ValleyMembase Meetup - Silicon Valley
Membase Meetup - Silicon Valley
 
From distributed caches to in-memory data grids
From distributed caches to in-memory data gridsFrom distributed caches to in-memory data grids
From distributed caches to in-memory data grids
 
AWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data CommonsAWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data Commons
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
An Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformAn Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media Platform
 
Sun Web Server Brief
Sun Web Server BriefSun Web Server Brief
Sun Web Server Brief
 
Caching technology comparison
Caching technology comparisonCaching technology comparison
Caching technology comparison
 
Caching technology comparison
Caching technology comparisonCaching technology comparison
Caching technology comparison
 
Membase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San FranciscoMembase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San Francisco
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
캐시 분산처리 인프라
캐시 분산처리 인프라캐시 분산처리 인프라
캐시 분산처리 인프라
 
Caching Strategies
Caching StrategiesCaching Strategies
Caching Strategies
 

Andere mochten auch

Making and Breaking Web Services with Ruby
Making and Breaking Web Services with RubyMaking and Breaking Web Services with Ruby
Making and Breaking Web Services with Rubyerr
 
Caching, Memcached And Rails
Caching, Memcached And RailsCaching, Memcached And Rails
Caching, Memcached And Railsguestac752c
 
Behind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling StorytimeBehind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling StorytimeSergeyChernyshev
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScriptdanwrong
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 

Andere mochten auch (8)

Making and Breaking Web Services with Ruby
Making and Breaking Web Services with RubyMaking and Breaking Web Services with Ruby
Making and Breaking Web Services with Ruby
 
Caching, Memcached And Rails
Caching, Memcached And RailsCaching, Memcached And Rails
Caching, Memcached And Rails
 
Memcached
MemcachedMemcached
Memcached
 
Behind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling StorytimeBehind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling Storytime
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
 
Caching
CachingCaching
Caching
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 

Ähnlich wie Memcached, presented to LCA2010

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
 
Scalable Resilient Web Services In .Net
Scalable Resilient Web Services In .NetScalable Resilient Web Services In .Net
Scalable Resilient Web Services In .NetBala Subra
 
Google App Engine At A Glance
Google App Engine At A GlanceGoogle App Engine At A Glance
Google App Engine At A GlanceStefan Christoph
 
HPC Web overview - Mobyle Workshop - September 28, 2012
HPC Web overview - Mobyle Workshop - September 28, 2012HPC Web overview - Mobyle Workshop - September 28, 2012
HPC Web overview - Mobyle Workshop - September 28, 2012Hervé Ménager
 
OSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabric
OSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabricOSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabric
OSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabricNETWAYS
 
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...Joonas Lehtinen
 
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...jaxconf
 
Gear6 Web Cache Overview
Gear6 Web Cache OverviewGear6 Web Cache Overview
Gear6 Web Cache OverviewGear6
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructureharendra_pathak
 
Facebook architecture
Facebook architectureFacebook architecture
Facebook architecturedrewz lin
 
Facebook architecture
Facebook architectureFacebook architecture
Facebook architecturemysqlops
 
Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01jgregory1234
 
Facebook的架构
Facebook的架构Facebook的架构
Facebook的架构yiditushe
 
OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...
OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...
OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...NETWAYS
 
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for WindowsFord AntiTrust
 

Ähnlich wie Memcached, presented to LCA2010 (20)

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...
 
Scalable Resilient Web Services In .Net
Scalable Resilient Web Services In .NetScalable Resilient Web Services In .Net
Scalable Resilient Web Services In .Net
 
Google App Engine At A Glance
Google App Engine At A GlanceGoogle App Engine At A Glance
Google App Engine At A Glance
 
HPC Web overview - Mobyle Workshop - September 28, 2012
HPC Web overview - Mobyle Workshop - September 28, 2012HPC Web overview - Mobyle Workshop - September 28, 2012
HPC Web overview - Mobyle Workshop - September 28, 2012
 
OSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabric
OSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabricOSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabric
OSDC 2017 - Christos Erotocritou - Apache ignite in-memory data fabric
 
Qcon
QconQcon
Qcon
 
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
 
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
 
Gear6 Web Cache Overview
Gear6 Web Cache OverviewGear6 Web Cache Overview
Gear6 Web Cache Overview
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
20080528dublinpt1
20080528dublinpt120080528dublinpt1
20080528dublinpt1
 
Facebook architecture
Facebook architectureFacebook architecture
Facebook architecture
 
Facebook architecture
Facebook architectureFacebook architecture
Facebook architecture
 
Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01
 
Facebook的架构
Facebook的架构Facebook的架构
Facebook的架构
 
slides (PPT)
slides (PPT)slides (PPT)
slides (PPT)
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...
OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...
OSMC 2023 | IGNITE: Serving Server-Side WASM with Web Awareness with NGINX Un...
 
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
 
Project Zero JavaOne 2008
Project Zero JavaOne 2008Project Zero JavaOne 2008
Project Zero JavaOne 2008
 

Mehr von Mark Atwood

How to get one of those Open Source jobs
How to get one of those Open Source jobsHow to get one of those Open Source jobs
How to get one of those Open Source jobsMark Atwood
 
Why is Open Source so Good: Thirty Years of Lessons Learned
Why is Open Source so Good: Thirty Years of Lessons LearnedWhy is Open Source so Good: Thirty Years of Lessons Learned
Why is Open Source so Good: Thirty Years of Lessons LearnedMark Atwood
 
Telephony with OpenShift Twilio and MongoDB
Telephony with OpenShift Twilio and MongoDBTelephony with OpenShift Twilio and MongoDB
Telephony with OpenShift Twilio and MongoDBMark Atwood
 
AMD Fusion12 Developer Summit: Introducing Red Hat OpenShift
AMD Fusion12 Developer Summit: Introducing Red Hat OpenShiftAMD Fusion12 Developer Summit: Introducing Red Hat OpenShift
AMD Fusion12 Developer Summit: Introducing Red Hat OpenShiftMark Atwood
 
Openshift + Openstack + Fedora = Awesome
Openshift + Openstack + Fedora = AwesomeOpenshift + Openstack + Fedora = Awesome
Openshift + Openstack + Fedora = AwesomeMark Atwood
 
OpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsOpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsMark Atwood
 
NoSQL Part 3, or A Modest Proposal for a Heretical Key Valuestore
NoSQL Part 3, or A Modest Proposal for a Heretical Key ValuestoreNoSQL Part 3, or A Modest Proposal for a Heretical Key Valuestore
NoSQL Part 3, or A Modest Proposal for a Heretical Key ValuestoreMark Atwood
 
Eucalyptus: Our Story. Presented at LCA2011
Eucalyptus: Our Story. Presented at LCA2011Eucalyptus: Our Story. Presented at LCA2011
Eucalyptus: Our Story. Presented at LCA2011Mark Atwood
 

Mehr von Mark Atwood (8)

How to get one of those Open Source jobs
How to get one of those Open Source jobsHow to get one of those Open Source jobs
How to get one of those Open Source jobs
 
Why is Open Source so Good: Thirty Years of Lessons Learned
Why is Open Source so Good: Thirty Years of Lessons LearnedWhy is Open Source so Good: Thirty Years of Lessons Learned
Why is Open Source so Good: Thirty Years of Lessons Learned
 
Telephony with OpenShift Twilio and MongoDB
Telephony with OpenShift Twilio and MongoDBTelephony with OpenShift Twilio and MongoDB
Telephony with OpenShift Twilio and MongoDB
 
AMD Fusion12 Developer Summit: Introducing Red Hat OpenShift
AMD Fusion12 Developer Summit: Introducing Red Hat OpenShiftAMD Fusion12 Developer Summit: Introducing Red Hat OpenShift
AMD Fusion12 Developer Summit: Introducing Red Hat OpenShift
 
Openshift + Openstack + Fedora = Awesome
Openshift + Openstack + Fedora = AwesomeOpenshift + Openstack + Fedora = Awesome
Openshift + Openstack + Fedora = Awesome
 
OpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsOpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red Hats
 
NoSQL Part 3, or A Modest Proposal for a Heretical Key Valuestore
NoSQL Part 3, or A Modest Proposal for a Heretical Key ValuestoreNoSQL Part 3, or A Modest Proposal for a Heretical Key Valuestore
NoSQL Part 3, or A Modest Proposal for a Heretical Key Valuestore
 
Eucalyptus: Our Story. Presented at LCA2011
Eucalyptus: Our Story. Presented at LCA2011Eucalyptus: Our Story. Presented at LCA2011
Eucalyptus: Our Story. Presented at LCA2011
 

Kürzlich hochgeladen

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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 AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
#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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[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.pdfhans926745
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Kürzlich hochgeladen (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 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
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[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
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Memcached, presented to LCA2010

  • 1. Introduction to Memcached Mark Atwood <matwood@gear6.com>
  • 2. What is it? •open source •high performance •distributed •memory •object •cache : Copyright 2009 Gear6 Inc.
  • 3. How we got here •persistent app service processes •local variables •filesystem caching •database query caching •shared memory segment caching •apache server fragment caching None of these scale OUT : Copyright 2009 Gear6 Inc.
  • 4. Scale out • Multiple machines access the same memcache • Multiple machines running the memcache • Buy more machines, not bigger machines • Each memcache node is a hash table • Memcache client library does consistent hashing » looks at key » computes hash » picks node : Copyright 2009 Gear6 Inc.
  • 5. What about the MySQL query cache? • A hack that makes poorly written PHP actually work • Heavy write load -> Fail • Heavy load -> Fail • Increasing CPU count -> Fail • Database server memory is precious, better spent on innodb buffer pool : Copyright 2009 Gear6 Inc.
  • 6. Where Memcached Fits Web Stack Net Interface Storage Clients PHP, Java, Rails, C, Internet Database Apache, Nginx, Storage Interface: Servers Servers Perl, Python PostgreSQL MySQL, Web App Proxy CDN Load client cache Storage cache Balancer Cache Services memcached : Copyright 2009 Gear6 Inc.
  • 7. Memcached: Technical Background • Written in C • DHT (Distributed Hash Table) Memcached • 2 Stage Protocol Handler » Clients: hash key  server » Server: hash key  value • Slab Allocator, fast Hash • Eviction algorithm: LRU • Supported clients » Java, PHP, Ruby, Perl, Python, C, etc Slab Manager • Key max size: max 250 bytes • Object max size: 1 MiB Item Manager • BSD like License : Copyright 2009 Gear6 Inc.
  • 8. Application Changes Application Requirements: » Modify calls to subsequent application logic or database by use of memcached client » Send requests to memcached server » Check application or db layer next » Update memcached Cons: » Requires coding » Generic Pros: » Some app frameworks already » Performance gains » Back-end complexity reduction » Generic Source: MySQL.com : Copyright 2009 Gear6 Inc.
  • 9. When coding, think of places to use it • In Perl & Python, when you have a big dictionary / hash to keep track of work • Or a highly used big lookup table. • There are modules to “tie” memcache to your language’s dictionary API • If you are in C, and are wishing for good dictionary • To share state between processes : Copyright 2009 Gear6 Inc.
  • 10. Pattern: sessions • Keep session state in the memcache • Turnkey for PHP and for Django » pecl install pecl/memcache » Enable memcache session handler support? [yes] : yes • Win! Avoid sticky HTTP load balancing • Win! Avoid hot session table in database » often the #1 performance hotspot for web apps : Copyright 2009 Gear6 Inc.
  • 11. Pattern: rate limiting • Limit access speed » to login attempts » to page accesses » to API calls » to expensive operations • Key of $prefix.$sourceip.$currtime • Value of access count • Use ADD method to update • Use MGET method to retrieve • Use expiration to delete : Copyright 2009 Gear6 Inc.
  • 12. Pattern: SQL query cache • On every SQL query • SQL statement is the key • Result set is the value • Use expire to delete • Beware of inconsistancy, but it may be ok : Copyright 2009 Gear6 Inc.
  • 13. MySQL User Defined Functions • Access memcached from inside queries • And from inside stored procedures • Can implement the “check cache, then read from table” pattern from inside the SQL query, without having to rewrite the app • Ships with Drizzle DB : Copyright 2009 Gear6 Inc.
  • 14. Other things to keep in memcache • HTML fragments • Image thumbnails • Message headers & bodies • Unread message list • Unread message counter • Contact list • Work queues • API keys • Nonces • Gearman staged work • Remote data fetched over the web • Structured file read cache (Wafflegrid) : Copyright 2009 Gear6 Inc.
  • 15. Thank you! Mark Atwood Director of Community Development <matwood@gear6.com> : Copyright 2009 Gear6 Inc.

Hinweis der Redaktion

  1. Support the Scaled Web stack
  2. Web 2.0 driving user &amp; traffic growth Key Apps : Entertainment, Communication, Social Networking Key Drivers : Mobile, Broadband, International, Consumer Mobile applications &amp;#x2013; 3G+ is 22% by 2010 (Mobile goes hi speed) Consumer Internet Traffic 2006&amp;#x2013;2012 This category encompasses any IP traffic that crosses the Internet and is not confined to a single service provider&amp;#x2019;s network. Peer-to-peer (P2P) traffic, still the largest share of Internet traffic today, will decrease as a percentage of overall Internet traffic. Internet video streaming and downloads are beginning to take a larger share of bandwidth, and will grow to nearly 50 percent of all consumer Internet traffic in 2012. Fortunately the web stack has evolved. OSS Technologies such as Varnish ( high-performance HTTP accelerator&amp;#x2026; reverse proxy), gearman (open source message queuing system that makes it easy to do distributed job processing using multiple languages&amp;#x2026; function dispatcher) and hadoop (distributed computing platform) Otherwise there would be some hard decisions These horizontal architectures require a distributed caching system at SCALE (for dynamic data&amp;#x2026; video can be cached at the edge) The alternatives in the earlier part of this decade was to scale up and put more memory in the application and database servers
  3. connections, operations