This document summarizes a presentation about Memcached and using the cloud. It discusses how Memcached alleviates database load for dynamic web applications by caching objects in memory. Using the cloud allows sites to leverage elastic, on-demand resources and pay only for what they use. The document recommends designing systems to be loosely coupled and resilient to failures when using the cloud. It presents two use cases - a system entirely in the cloud using Memcached and EC2 instances, and a hybrid model with an on-premise Memcached cache. Gear6 is introduced as a commercial distribution of Memcached optimized for use in the cloud.
1. Memcached and the “Cloud”
Presented by: Bill Takacs
Director, Product Management
December 8th 2009
2. Agenda
• Dynamic Web
• Memached
• Why leverage the cloud?
• Where to start?
• Use cases
• Gear6 and the Cloud
2 : Copyright 2009 Gear6 Inc.
3. Truism
“Everything runs from
Everything
Memory in Web 2.0”
y
» Evan Weaver, Twitter, March 2009
3 : Copyright 2009 Gear6 Inc.
4. The Shift to Dynamic Content
Facts:
➜ Web 2 0 driving user traffic and growth
2.0
➜ Mobile, Broadband, Population and Content are web accelerators
➜ Shift to Dynamic Content puts strain on origin sites (CDN not the Answer)
➜ Most sites (over 65%) based on LAMP or JAVA
Web Stack Net
Interface
Storage Clients
PHP, Jav Rails, C,
Data
Apach Nginx,
Internet
Storage Interface:
Storage Interface:
Ser
Ser
Perl, Python
Post
file, b
file, b
Lig
My
Web
W
App
A
block, FC, SCSI
block, FC, SCSI
he,
ghttpd
tgreSQL
ySQL,
,
rvers
abase
rvers
va,
Proxy
P
CDN
Load client cache
Storage cache Balancer
Cache Services
memcached
4 : Copyright 2009 Gear6 Inc.
5. Memcached
“A high performance, distributed memory object caching
system, generic in nature, but intended for use in
t i i t b ti t d df i
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
5 : Copyright 2009 Gear6 Inc.
6. How Does Memcached Work?
• Client - Server
• Client - Server
• Hash Function
• H h Function
Hash F ti
• Memcached
» Two stage • Memcached
» Key / value pair » Two stage
» Key / value p
y pair
6 : Copyright 2009 Gear6 Inc.
7. Memcached Clients
• Client hashes key to server list
• Serializes the object
• Compresses data
• Many client libraries
• Authentication
7 : Copyright 2009 Gear6 Inc.
8. 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
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. What Memcached is NOT:
• A persistent data store
• A database
• Application specific
• A large object cache
• No HA Features
10 : Copyright 2009 Gear6 Inc.
11. Basic Example
function get_foo(foo_id)
foo = memcached_get("foo:" . foo_id)
return foo if defined foo foo = fetch_foo_from_database
(foo_id) memcached_set("foo:" . foo_id, foo) return foo
end
11 : Copyright 2009 Gear6 Inc.
12. Truism II
“Everything in the Cloud runs
Everything
in Memory”y
12 : Copyright 2009 Gear6 Inc.
13. How Do I Run More from Memory?
Memcached
13 : Copyright 2009 Gear6 Inc.
14. Memcached Significance
In General:
• Web 2.0 overwhelmingly depends on it
For th Cl d
F the Cloud:
• Dynamic sites in the Cloud depend on it
• Lower cost
• Lower complexity
• B tt utility
Better tilit
14 : Copyright 2009 Gear6 Inc.
15. Why Leverage the Cloud?
• It’s all about scale – right?
It s
• Virtualized and elastic on-demand
resources
• Pay for what you use
• Self service = no waiting
for resources
• There are different clouds
• Private
• Public
15 : Copyright 2009 Gear6 Inc.
16. Cloud Best Practices
• D i for failure
Design f f il
• Build loosely coupled systems
u d oose y coup ed syste s
• Design for the dynamic nature
of the cloud – Dynamism
• Build in security at every layer
y y y
• Don’t fear constraints
• Leverage storage options
16 : Copyright 2009 Gear6 Inc.
17. Where to Start?
• Evaluate your architecture
• Think it through as the “whole”
Web Tier
Cache Tier
Database Tier
What makes sense to put into the cloud?
17 : Copyright 2009 Gear6 Inc.
18. Great – What about Memcached?
• If your application is entirely built and hosted in the cloud, then
Memcached is an option
• WAN latency will prevent Memcached
use in a mixed environment
(your datacenter + cloud provider)
18 : Copyright 2009 Gear6 Inc.
19. Dynamism and Memcached
Couple of approaches:
C l f h
• Don’t - fixed pool
• Use consistent hashing
p g g p
• http://code.google.com/p/memcached/wiki/Clients
• Libmemcache
• Libketama
19 : Copyright 2009 Gear6 Inc.
20. What Else?
• R li bilit
Reliability
• Recent Rackspace outage
• AWS has had outages
as well
• Cost – need to test your app to
understand the dynamic nature of
how you get charged
20 : Copyright 2009 Gear6 Inc.
21. Use Case 1 - Cloud “Pure”
Internet
AWS
EC2 – Web / Application Servers
-Auto Scaling to meet demand
EC2 – M
Memcache
h
S3 – Large object store RDS – Dynamic data SimpleDB– Static data
(eg video) (profile information) (eg Credentials)
21 : Copyright 2009 Gear6 Inc.
22. Use Case 2 - Hybrid
App / Web Tier Load Balancer
MySQL
(Spike in traffic directs to AWS)
Gear6 Web Cache
Data Centre
Internet
AWS
EC2 – Web / Application Servers
-Auto Scaling to meet demand
EC2 – Memcache
RDS – Dynamic data
(profile information)
22 : Copyright 2009 Gear6 Inc.
23. Summary
• Start by thinking through your architecture
• Different if you’re going “all cloud”
• Plan to deal with the dynamic nature of the cloud
• Don’t forget the the law –
the least scalable component
of your system b
f t becomes the bottleneck
th b ttl k
• Latency between datacenter
and cloud will prevent use of
Memcached in a hybrid model
y
23 : Copyright 2009 Gear6 Inc.
25. Gear6 at a Glance
• Focused on Web Scale Architectures
» Dynamic sites require DYNAMIC DATA SERVICES
» Memcached is the “linchpin”
• Gear6 Web Cache: Leading mission critical Memcached distribution
» Enables sites to reliably and efficiently scale, cut costs and increase transactions
• Company is serving a broadening market:
» More dynamic applications
» Geographically distributed
» Platform diverse: sites and users
• #1 commercial distro for Memcached
25 : Copyright 2009 Gear6 Inc.
26. Gear6 Web Cache Server for the Cloud
• Gear6 Web Cache: Memcached-as-a-Service
» Fi t commercial M
First i l Memcached service f cloud platforms
h d i for l d l tf
» Free and paid image sizes available
• 32 bit free Server
• 64 bit paid
» Available on EC2:
• First Memcached service to use High-Memory Instances on EC2
» First to leverage block storage interface
• Benefit: 100x cache capacity increase per AMI
» Community and commercial support for Memcached
26 : Copyright 2009 Gear6 Inc.
27. Benefits of Gear6 Web Cache Server
Higher Utility; Ease of Use
Ease-of-Use
• No code changes - 100% Memcapable
» Full Memcached protocol compliance
• Up to 50% more use of AMI RAM
» Memory optimization via Gear6 “Slab Manager”
» Fewer instances needed
• 100x cache depth increase
» Unique to G6 offering: Transparent use of block storage
» Leverages Gear6 Media Allocator
• Easy to manage and monitor
» Memcached Web GUI Interface
• Memcached Commercial Support
» Clients and Gear6 Web Cache Server
» 24x7 customer support for Commercial
27 : Copyright 2009 Gear6 Inc.
28. Gear6 Web Cache Server for EC2
Higher Utility; Ease of Use
Ease-of-Use
+ = Memory
Higher
Storage
Storage
S
S
+ = +
Utility: Server Memory
server
Ease-of-Use
» Web interface for monitoring
• Graphical & Text
• 24 hour historical data
» Auto-configurator for EC2
» REST API
• Support URL style queries
• Benefit : Easy integration for
web deployments
28 : Copyright 2009 Gear6 Inc.
29. Gear6 Web Cache Server
Increasing Cloud Utility: “2B or not 2B
2B 2B”
Deploy in Cloud 1 Speed Apps 2A Scale with 2B
with AWS with Memcached Gear6 Web Cache
» On-demand » Offload apps and DB » Increase efficiency of
» Low cost of entry » Decrease latency every image
» Scale by “replication”
replication » Consolidate images
g
» Image management becomes » Decrease costs
issue
App App App App App App
Server
DB DB
DB DB DB DB
29 : Copyright 2009 Gear6 Inc.
30. Education: Amazon EC2 Images
Linux,
Linux USA
AMI Instance
Specs Amazon Pricing
Class Sizes
“Small” (Default) • 1.7 GB RAM $0.085 per hour
• 1 EC2 Compute Unit
• 160 GB bl k storage
block t
• 32 bit platform
andard
“Large” • 7.5 GB RAM $0.34 per hour
• 4 EC2 Compute Units
• 850 GB block storage
g Memory
Sta
• 64 bit platform
Storage
“Extra Large” • 15 GB RAM $0.68 per hour
• 8 EC2 Compute Units CPU
• 1690 GB block storage
• 64 bit platform
“Double XL” • 34.2 GB RAM $1.20 per hour
High-Memory
• 13 EC2 Compute Units
• 850 GB block storage
• 64 bit platform
“Quad XL” • 68.4 GB RAM $2.40 per hour
• 26 EC2 Compute Unit
• 1690 GB block storage
• 64 bit platform
30 : Copyright 2009 Gear6 Inc.
31. Gear6 Web Cache Server Pricing
EC2 (USA)
Server +
Gear6 Amazon Total
AMI Instance Pricing
Class Capacity for Web Cache
Pricing Cost
per hour per hour
Server per hour
“Small” FREE* $0.085 $0.085
1.7 GB RAM
160 GB Storage
Standard
“Large” $0.50 $0.34 $0.84
7.5 GB RAM
850 GB Storage
S
“Extra Large” $0.60 $0.68 $1.28
15 GB RAM
1690 GB Storage
“Double XL” $0.72 $1.20 $1.92
Memory y
34.2 GB RAM
High-
850 GB Storage
“Quad XL” $0.86 $2.40 $3.26
68.4 GB RAM
1690 GB Storage
* Note: “Small” instance limited to 4 GB due to 32 bit platform
31 : Copyright 2009 Gear6 Inc.
32. DIY vs Gear6 Web Cache Server
Linux,
Linux USA
Higher
Storage
Utility: Server
+ = Memory +
Instance Effective “Effective” ¢
Memcached / GB
Capacity Capacity per hour
“Small”
DIY 1.7 GB RAM
160 GB Storage
1.02 GB RAM
0 GB Storage
8.3¢
“Small”
Gear6
Gear6* 1.7 GB RAM
17
160 GB Storage
1.56 GB RAM
1 56
2.1 GB Storage
5.4¢ (RAM only)
5 4¢
2.3¢ (total capacity)
“Quad XL”
DIY 68.4 GB RAM
1690 GB Storage
41.04 GB RAM
0 GB Storage
5.8¢
“Quad XL” Better
Gear6** 68.4 GB RAM
1690 GB Storage
62.93 GB RAM
1380 GB Storage
5.2¢ (RAM only)
0.2¢ (total capacity)
than “free”
* Note: “Small” instance limited to 4 GB due to 32 bit platform
p
** Note: Gear6 priced offerings include 24x7 support
32 : Copyright 2009 Gear6 Inc.
33. Gear6 Web Cache Server AMI Support
Linux,
Linux USA
AMI Class Instance Sizes Support & Services
pp
“Small” FREE
• Gear6 user forum-based support
forum-
tandard
“Large”
St
“Extra Large” Server
• Gear6 user forum-based support
forum-
• 24x7 Email access to Technical Support
pp
including installation & trouble-shooting
trouble-
“Double XL” assistance
emory
High-Me
“Quad XL”
33 : Copyright 2009 Gear6 Inc.
34. Thank You!
For more information:
www.gear6.com
www gear6 com
34 : Copyright 2009 Gear6 Inc.
35. Questions?
Thank you for attending our webinar
Bill Takacs
Gear6
salesinfo@gear6.com
+1 650 587 7118
and please visit our web site at:
www.gear6.com
35 : Copyright 2009 Gear6 Inc.
36. Credits and References
Set Amazon’s Servers on Fire, Not Yours –
AWS Start-Up Event 2009:
http://www.slideshare.net/aws/set-amazons-servers-on-fire
htt // lid h t/ / t fi
Cloud Architectures, Jinesh Varia. Technology Evangelist,
Amazon Web Services (jvaria@amazon.com)
http://jineshvaria.s3.amazonaws.com/public/cloudarchitectures-
htt //ji h i 3 / bli / l d hit t
varia.pdf-jsa90b_Z1Kw&sig2=GT9UWF2SMgodTQ9oQ_NsnQ
36 : Copyright 2009 Gear6 Inc.