Upload
gear6
View
4.040
Download
1
Embed Size (px)
DESCRIPTION
This is a presentation given on April 14, 2009 to a select group of current memcached users. It includes survey results of how the dynamic web has given rise to the distributed caching tier, describes the growing popularity of memcached, provides poll results from memcached users and offers overview of the Gear6 Web Cache solution. Gear6 will be at the 2009 MySQL Conference at booth #218. Or visit us at Gear6.com.
Citation preview
Scaling Website Performance:Caching Session and Profile Data with Memcached
Presented by:
Joaquín Ruiz – EVP Products
14 April 2009
Joaquín Ruiz EVP Products
Perry Krug – Systems Engineer
About Gear6
• First and leading provider of scalable Memcached solutions
• Enabling high-growth web sites to deliver and scale dynamic• Enabling high growth web sites to deliver and scale dynamic applications and content
• Memcached contributor on Github and Google Code• Memcached contributor on Github and Google Code
• Customers are leaders in media, social networking and content aggregationaggregation
• Privately held; Headquartered in Mountain View, California
2 : Copyright 2009 Gear6 Inc.
The Web Has Changed
• It’s Dynamic, It’s Mobile, It’s High Speed» Consumer internet traffic surpassed business traffic in 2008» Dynamic (Social Aggregation Media) sites/services are the driving web growth» Dynamic (Social, Aggregation, Media) sites/services are the driving web growth
So…• A distributed caching tier has become necessary and ubiquitous
» Approximately 70% of websites are Linux-based (typically LAMP/Java) and are not scalable without a distributed caching tier
Because…• Without a distributed caching tier you have no good options
» SCALE VERTICALLY: $$$ It’s very expensive to do this $$$» ADD LARGE AMOUNTS OF WEB, APP AND DB SERVERS: $$$ OPEX $$$» MOVE TO A DIFFENT STACK: “No way!”» MOVE TO A DIFFENT STACK: No way!» GET CRUSHED/SLOW RESPONSE TIMES: “It’s gone from bad to worse”
“Digital Consumer “Digital Consumer –– Undermonetized social networks / video / VoIP driving powerful usage Undermonetized social networks / video / VoIP driving powerful usage growth”growth” –– Morgan Stanley Tech Research, 5 Nov 2008, Web 2.0 Summit, San FranciscoMorgan Stanley Tech Research, 5 Nov 2008, Web 2.0 Summit, San Francisco
3 : Copyright 2009 Gear6 Inc.
growth growth Morgan Stanley Tech Research, 5 Nov 2008, Web 2.0 Summit, San FranciscoMorgan Stanley Tech Research, 5 Nov 2008, Web 2.0 Summit, San Francisco
Web Architecture with No Cache
Web / Application ServersMySQL
DatabasesDatabases
Ad
Addd Loaddd Load
Web / Application Servers
MySQL Databases
E t t hit th d t b d/E t t hit th d t b d/
Databases
4 : Copyright 2009 Gear6 Inc.
Every request must hit the database servers and/or Every request must hit the database servers and/or rere--execute on application serversexecute on application servers
Memcached to the Rescue
• Memcached: a distributed memory object caching system intended for use in speeding up dynamic web applications by alleviating database loaddatabase load
• Memcached is an open source project that developed around the need for dynamic web sites to have a distributed caching tierneed for dynamic web sites to have a distributed caching tier» Technology: Memcached is a generic two stage hashing system (clients and
servers). Clients are written for specific application languages. Server is written in CU HTML M SQL S i / fil hi» Use cases: HTML, MySQL, Session/profile caching
• Memcached is de facto solution85% of top 20 sites use memcached; 50%+ of top 5k sites uses Memcached» 85% of top 20 sites use memcached; 50%+ of top 5k sites uses Memcached
» Memcached has client libraries in all major languages» Memcached has application level plug-ins for apps like WordPress and
Drupal
5 : Copyright 2009 Gear6 Inc.
Why should I use Memcache?
• Enables scale-out of dynamic websites• Faster page loadsp g• Allows for efficient use of your database• Can utilize existing network infrastructure• Very flexible – architect for your workload & resources
6 : Copyright 2009 Gear6 Inc.
Web Architecture with Memcached
Web / Application ServersWithout Memcached
MySQL Databases
Web / Application ServersWeb / Application Servers
With Memcached
Perfect for dynamic website that generate a
hi h l d th iMemcachedMemcached Memcache Server(s)MemcachedMemcached
7 : Copyright 2009 Gear6 Inc.
MemcachedMemcachedhigh load on their
databasee cac ede cac ed
MySQL Databases
Challenges of Memcached
Challenges:» Many web implementations require lots of
memory and lots of servers for memcache:Ad i i t ti li d• Administration, power, cooling and rackspace challenge
» No built-in failover or replication» Instances managed individually
• Lack of consolidated management and• Lack of consolidated management and aggregated statistic gathering
• Can be challenging to troubleshoot client, service, instance and key relationships
Source: “MySQL and memcached” May 2008 seminar
8 : Copyright 2009 Gear6 Inc.
What is a Session?
Al t l l th 250 b t d l t• Almost always larger than 250 bytes, and almost always smaller than 5 kilobytes
Read from datastore for every logged in user for• Read from datastore for every logged in user for every dynamic page load
Written to the datastore for every dynamic page• Written to the datastore for every dynamic page load
• Eventually reaped from the database after N• Eventually reaped from the database after N minutes of inactivity
9 : Copyright 2009 Gear6 Inc.
Credits: “Cache your sessions. Don't piss off your users” by Dormando
Example: Scaling the User Profile
• Too many users creates a load on the database• Replicating the database will help thisp g p» Will quickly experience DB replication lag
10 : Copyright 2009 Gear6 Inc.
Source: “”Scaling and Tuning MySQL.com” Jan 2009
Where do you keep your Sessions?
• Bad: Local sessions (on disk or in memory)» Can’t move users» Can t move users» Can’t avoid hotspots» Not fault tolerant
• Good: Centralized sessions (in a central database or in memor )database or in-memory)» No porting around of session data» No need for sticky sessions» No need for sticky sessions» No hot spots
11 : Copyright 2009 Gear6 Inc.
Credits: “Scalable Web Architectures” by Cal Henderson
Caching Sessions with Memcached
• Common Wisdom: You Don’t » Users will get logged out if anything goes wrong with» Users will get logged out if anything goes wrong with
memcached» Evictions means that people are logged out of your site» If you upgrade memcached, OS, hardware etc., everyone will
be logged offAddi / i h d ki k l ff it» Adding/removing memcached servers kicks people off site
• BUT the benefit of caching sessions is HUGE• BUT the benefit of caching sessions is HUGE» It is VERY FAST - Zero reads or writes to the database… so people do!
12 : Copyright 2009 Gear6 Inc.
Credits: “Cache your sessions. Don't piss off your users” by Dormando
Session Caching Options
Approach 1:
» Memcached / MySQL hybrid ! Run batch/cron jobs to store session data in Memcached / MySQL hybrid ! Run batch/cron jobs to store session data in
both database and memcached
» Good for smaller sites or sites where it doesn’t matter as much if session
data is lost
Approach 2 (Gear6 Approach):Approach 2 (Gear6 Approach):
» Store session in memcached space only
» Provide sufficient memory space to eliminate evictions
• Leverage flash density to reduce space and costs
• Use DRAM to provide low latency
b d l l h d
13 : Copyright 2009 Gear6 Inc.
» Use server-based replication to eliminate memcached misses
Gear6: Session Caching Customer Case
Production Customer Stats:» Alexa rank: top 150 worldwide» 10’s of millions of page views per day» 28 million unique users per month in 2008» Previously used memcached v 1.2.6 to cache sessions» About 120GB of memcache data used
Customer challenges:g» Need to provide very fast access to use profile information in order
to present user with appropriate content (based on user ratings)» Customer: rack space limited and cost sensitive» Need to increase administrative efficiency for memcached tier» Memcached reload can take several hours if failure occurs during
which DB load is very high and service latency increased
14 : Copyright 2009 Gear6 Inc.
Gear6: Session Caching Customer Case
• Without Gear6:Zero High Availability / RedundancyZero High Availability / Redundancy» Slower user experience» 4 U rack space» ~800W power consumption» 800W power consumption» Zero configuration management» Minimal statistics (Cacti)» Cost per Gig = $100 for hardware only» Cost per Gig = $100 for hardware onlyDouble everything for redundancy
32GB32GB 32GB32GB 32GB32GB 32GB32GB
15 : Copyright 2009 Gear6 Inc.
Gear6: Session Caching Customer Case
• With Gear6:Fully redundant / cache data protectiony / p» 2 U rack space» ~400W power consumption» Single point for managementg p g» Enhanced stream analysis and statistics» Cost per Gig = $70 for entire solution
Savings & benefits of Gear6 solution vs. without Gear6:» Over $8k/year in power savings» Immediately deployable with no code changes» Immediately deployable with no code changes» 1/4th the rack space» Customers immediately presented with high-affinity content based
on profile and rating history
16 : Copyright 2009 Gear6 Inc.
p g y» Less expensive to deploy with Gear6 than without!
Gear6 Web Cache Specifications
Gear6 Web Cache Software Gear6 Web Cache Module
• High memory density & advance memory allocation» Best-in-class hybrid RAM-Flash» Best in class hybrid RAM Flash
configurations» Advanced memory management» Most efficient object eviction implementation» High bandwidth support
Gear6 software delivered on best-of-breed, industry standard servers, DRAM and Flash
• High availability» Rich cluster functionality» Failover configurations» Cache replication options
Module specs:•1 U rack profile with four flash drive bays•Minimum of two modules per appliance•Two power supplies per module• Advanced management
» Hot key and client analysis» Service-wide diagnostics» Aggregated physical and logical views
•Two power supplies per module•Four bonded GE ports per module•Two Quad Core processors•Up to 300GB per rack unit
17 : Copyright 2009 Gear6 Inc.
Resources
• www.gear6.com
• Twitter» twitter.com/memcached
• Github» http://github.com/zyounker/brutis/tree/masterp //g / y / / /» http://github.com/rama/statsproxy/tree/master
Google code• Google code» http://code.google.com/p/brutis/wiki/Readme» http://code.google.com/p/statsproxy/
18 : Copyright 2009 Gear6 Inc.
April 14, 2009 Webinar Poll Results
If you do use memcached, do you use it for:0%None of the above
42%
0%
8%
0%
Caching HTML web pages
Session and profile caching
All of the above
None of the above
67%
42%
MySQL or other data caching
Caching HTML web pages
What client are you using for memcached?
44%Other
44%
11%
0%
PHP
Java Based
Perl
19 : Copyright 2009 Gear6 Inc.
Questions?
Thank you for attending“Scaling Website Performance: Caching Session and
P fil D i h M h d”Profile Data with Memcached”presented by Gear6
Joaquin RuizJoaquin RuizGear6Gear6
[email protected]@gear6.com
20 : Copyright 2009 Gear6 Inc.
+1 650 587 7116+1 650 587 7116