Cloud Scaling with Memcached

36
Memcached and the “Cloud” Presented by: Bill Takacs Director, Product Management December 8 th 2009

description

These slides cover the pros and cons of implementing Memcached in a cloud environment, the basics and best practices of implementation, and how to get the most out of your investment with Memcached. We also introduce Gear6 Web Cache Server for the Cloud, the first commercial Memcached service for cloud platforms. The on-demand webcast can be accessed here: http://www.gear6.com/memcached-resources/webinar-archive

Transcript of Cloud Scaling with Memcached

Page 1: Cloud Scaling with Memcached

Memcached and the “Cloud”

Presented by: Bill Takacs

Director, Product Management

December 8th 2009

Page 2: Cloud Scaling with Memcached

Agenda

• Dynamic Web

• Memached

• Why leverage the cloud?

• Where to start?• Where to start?

• Use cases

• Gear6 and the Cloud

2 : Copyright 2009 Gear6 Inc.

Page 3: Cloud Scaling with Memcached

Truism

“Everything runs fromEverything runs fromMemory in Web 2.0”y

» Evan Weaver, Twitter, March 2009

3 : Copyright 2009 Gear6 Inc.

Page 4: Cloud Scaling with Memcached

The Shift to Dynamic Content

Facts:➜ Web 2 0 driving user traffic and growth➜ Web 2.0 driving user traffic and growth➜ 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

NetInterface

Web Stack➜ Most sites (over 65%) based on LAMP or JAVA

ClientsInternet

StorageInterface

P

WSer

Apach

LigASer

PHP, JavPerl,

DataM

yPost

StoraStora

file, bfile, b

CDN

client cache

Proxy

Load

Web

rvershe, N

ginx, ghttpd

App

rversva, R

ails, C,

, Python

abaseySQ

L, tgreSQ

L

ge Interface:ge Interface:

block, FC, SC

SIblock, FC

, SCSI

client cacheStorage cache Balancer

Cache Servicesmemcached

4 : Copyright 2009 Gear6 Inc.

memcached

Page 5: Cloud Scaling with Memcached

Memcached

“A high performance, distributed memory object caching t i i t b t i t d d f isystem, 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• Significantly reduced database load

• Perfect for web sites with high database load

• In use by Facebook, Twitter, MyYearBook, others

5 : Copyright 2009 Gear6 Inc.

Page 6: Cloud Scaling with Memcached

How Does Memcached Work?

• Client - Server

• Hash Function• Client - Server

H h F ti• Memcached

» Two stage

• Hash Function

• Memcached» Two stage» Key / value pair

• Memcached» Two stage» Key / value pair y p

6 : Copyright 2009 Gear6 Inc.

Page 7: Cloud Scaling with Memcached

Memcached Clients

• Client hashes key to server list

• Serializes the object

• Compresses data

• Many client libraries

• Authentication

7 : Copyright 2009 Gear6 Inc.

Page 8: Cloud Scaling with Memcached

Memcached Server

• Limits» Key size = (250 bytes)» 1MB Limit » 32bit/64bit (maximum size of process)» 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• Threads? Yes

8 : Copyright 2009 Gear6 Inc.

Page 9: Cloud Scaling with Memcached

Commands

• Storage commands:» Set / Add / Replace /

Append / Prepend / CAS

• Retrieval commands:» Get / Gets

• Delete / increment / ddecrement

Stats• Stats

9 : Copyright 2009 Gear6 Inc.

Page 10: Cloud Scaling with Memcached

What Memcached is NOT:

• A persistent data store

• A database

• Application specific

• A large object cache

• No HA Features

10 : Copyright 2009 Gear6 Inc.

Page 11: Cloud Scaling with Memcached

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 fooendend

11 : Copyright 2009 Gear6 Inc.

Page 12: Cloud Scaling with Memcached

Truism II

“Everything in the Cloud runsEverything in the Cloud runs in Memory”y

12 : Copyright 2009 Gear6 Inc.

Page 13: Cloud Scaling with Memcached

How Do I Run More from Memory?

MemcachedMemcached

13 : Copyright 2009 Gear6 Inc.

Page 14: Cloud Scaling with Memcached

Memcached Significance

In General:• Web 2.0 overwhelmingly depends on it

F th Cl dFor the Cloud:• Dynamic sites in the Cloud depend on it

Lower cost• Lower cost• Lower complexity

B tt tilit• Better utility

14 : Copyright 2009 Gear6 Inc.

Page 15: Cloud Scaling with Memcached

Why Leverage the Cloud?

• It’s all about scale – right?It s all about scale right?

• Virtualized and elastic on-demandresources

• Pay for what you use

• Self service = no waitingSelf service no waitingfor resources

• There are different clouds

• PrivatePrivate

• Public

15 : Copyright 2009 Gear6 Inc.

Page 16: Cloud Scaling with Memcached

Cloud Best Practices

D i f f il• Design for failure

• Build loosely coupled systemsu d oose y coup ed syste s

• Design for the dynamic natureof the cloud Dynamismof the cloud – Dynamism

• Build in security at every layery y y

• Don’t fear constraints

• Leverage storage options

16 : Copyright 2009 Gear6 Inc.

Page 17: Cloud Scaling with Memcached

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.

Page 18: Cloud Scaling with Memcached

Great – What about Memcached?

• If your application is entirely built and hosted in the cloud, thenIf your application is entirely built and hosted in the cloud, then Memcached is an option

• WAN latency will prevent Memcacheduse in a mixed environment(your datacenter + cloud provider)(your datacenter + cloud provider)

18 : Copyright 2009 Gear6 Inc.

Page 19: Cloud Scaling with Memcached

Dynamism and Memcached

C l f hCouple of approaches:

• Don’t - fixed pool

• Use consistent hashing

• http://code.google.com/p/memcached/wiki/Clientsp g g p

• Libmemcache

• Libketama• Libketama

19 : Copyright 2009 Gear6 Inc.

Page 20: Cloud Scaling with Memcached

What Else?

R li bilit• Reliability

• Recent Rackspace outage

• AWS has had outagesas well

• Cost – need to test your app to understand the dynamic nature ofunderstand the dynamic nature of how you get charged

20 : Copyright 2009 Gear6 Inc.

Page 21: Cloud Scaling with Memcached

Use Case 1 - Cloud “Pure”

IInternet

AWSEC2 – Web / Application Servers-Auto Scaling to meet demand

EC2 M hEC2 – Memcache

S3 – Large object store (eg video)

RDS – Dynamic data (profile information)

SimpleDB– Static data (eg Credentials)

21 : Copyright 2009 Gear6 Inc.

Page 22: Cloud Scaling with Memcached

Use Case 2 - Hybrid

Load BalancerLoad Balancer(Spike in traffic directs to AWS)

App / Web TierGear6 Web Cache

MySQL

Internet

Data Centre

EC2 – Web / Application Servers

AWS

Internet

-Auto Scaling to meet demand

EC2 – Memcache

RDS – Dynamic data (profile information)

22 : Copyright 2009 Gear6 Inc.

Page 23: Cloud Scaling with Memcached

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

f t b th b ttl kof your system becomes the bottleneck

• Latency between datacenterand cloud will prevent use ofMemcached in a hybrid model

23 : Copyright 2009 Gear6 Inc.

y

Page 24: Cloud Scaling with Memcached

Gear6

Page 25: Cloud Scaling with Memcached

Gear6 at a Glance

• Focused on Web Scale Architectures» Dynamic sites require DYNAMIC DATA SERVICES» 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.

Page 26: Cloud Scaling with Memcached

Gear6 Web Cache Server for the Cloud

• Gear6 Web Cache: Memcached-as-a-ServiceFi t i l M h d i f l d l tf» First commercial Memcached service for cloud platforms

» Free and paid image sizes available• 32 bit free• 64 bit paid

ServerServer

» 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.

Page 27: Cloud Scaling with Memcached

Benefits of Gear6 Web Cache ServerHigher Utility; Ease of UseHigher Utility; Ease-of-Use

• No code changes - 100% Memcapable» Full Memcached protocol compliance» 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• Easy to manage and monitor» Memcached Web GUI Interface

• Memcached Commercial Support• Memcached Commercial Support» Clients and Gear6 Web Cache Server» 24x7 customer support for Commercial

27 : Copyright 2009 Gear6 Inc.

Page 28: Cloud Scaling with Memcached

Gear6 Web Cache Server for EC2Higher Utility; Ease of UseHigher Utility; Ease-of-Use

+ MemoryMemory=

SS

MemoryMemory

Higher +

StorageStorage

= MemoryMemory +ServerServer

HigherUtility:

Ease-of-Use» Web interface for monitoring

• Graphical & Text

server

• 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.

Page 29: Cloud Scaling with Memcached

Gear6 Web Cache ServerIncreasing Cloud Utility: “2B or not 2B”Increasing Cloud Utility: 2B or not 2B

Deploy in Cloudwith AWS

Speed Appswith Memcached

Scale withGear6 Web Cache

11 2A2A 2B2B

with AWS» On-demand» Low cost of entry» Scale by “replication”

with Memcached» Offload apps and DB» Decrease latency

Gear6 Web Cache» Increase efficiency of

every image» Consolidate images» Scale by replication

» Image management becomes issue

g» Decrease costs

AppApp AppApp AppApp AppApp AppApp AppApp

ServerServer

DBDB DBDBDBDB DBDB DBDB DBDB DBDB DBDB

29 : Copyright 2009 Gear6 Inc.

Page 30: Cloud Scaling with Memcached

Education: Amazon EC2 ImagesLinux USALinux, USA

AMI AMI Instance Instance SpecsSpecs Amazon PricingAmazon PricingClassClass SizesSizes SpecsSpecs Amazon PricingAmazon Pricing

“Small” (Default)“Small” (Default) •• 1.7 GB RAM1.7 GB RAM•• 1 EC2 Compute Unit1 EC2 Compute Unit

160160 GB bl k tGB bl k t

$0.085 per hour$0.085 per hour

anda

rd

•• 160160 GB block storageGB block storage•• 32 bit platform32 bit platform

“Large”“Large” •• 7.5 GB RAM7.5 GB RAM•• 4 EC2 Compute Units4 EC2 Compute Units•• 850 850 GB block storageGB block storage

$0.34 per hour$0.34 per hour

MemoryMemory

Sta gg

•• 64 bit platform64 bit platform

“Extra Large”“Extra Large” •• 15 GB RAM15 GB RAM•• 8 EC2 Compute Units8 EC2 Compute Units•• 1690 1690 GB block storageGB block storage•• 64 bit platform64 bit platform

$0.68 per hour$0.68 per hour

StorageStorage

CPUCPU

•• 64 bit platform64 bit platform

emor

y “Double XL”“Double XL” •• 34.2 GB RAM34.2 GB RAM•• 13 EC2 Compute Units13 EC2 Compute Units•• 850 850 GB block storageGB block storage•• 64 bit platform64 bit platform

$1.20 per hour$1.20 per hour

Hig

h-M “Quad XL”“Quad XL” •• 68.4 GB RAM68.4 GB RAM

•• 26 EC2 Compute Unit26 EC2 Compute Unit•• 1690 1690 GB block storageGB block storage•• 64 bit platform64 bit platform

$2.40 per hour$2.40 per hour

30 : Copyright 2009 Gear6 Inc.

Page 31: Cloud Scaling with Memcached

Gear6 Web Cache Server PricingEC2 (USA)EC2 (USA)

+ServerServer

AMI AMI Instance Instance Gear6 Gear6 PricingPricing

Amazon Amazon PricingPricing

Total Total CostCost

ServerServer

ClassClass CapacityCapacityPricingPricing

for Web Cache Server per hour

PricingPricingper hour

CostCostper hour

“Small”“Small”1.7 GB RAM1.7 GB RAM

FREE*FREE* $0.085$0.085 $0.085$0.085

Stan

dard

160 GB Storage160 GB Storage

“Large”“Large”7.5 GB RAM7.5 GB RAM850 GB Storage850 GB Storage

$0.50$0.50 $0.34$0.34 $0.84$0.84

S “Extra Large”“Extra Large”15 GB RAM15 GB RAM1690 GB Storage1690 GB Storage

$0.60$0.60 $0.68$0.68 $1.28$1.28

y “Double XL”“Double XL” $0.72$0.72 $1.20$1.20 $1.92$1.92

Hig

h-M

emor

y 34.2 GB RAM34.2 GB RAM850 GB Storage850 GB Storage

“Quad XL”“Quad XL”68.4 GB RAM68.4 GB RAM1690 GB Storage1690 GB Storage

$0.86$0.86 $2.40$2.40 $3.26$3.26

31 : Copyright 2009 Gear6 Inc.

1690 GB Storage1690 GB Storage

* Note: “Small” instance limited to 4 GB due to 32 bit platform

Page 32: Cloud Scaling with Memcached

DIY vs Gear6 Web Cache ServerLinux USALinux, USA

Higher+

StorageStorage

= MemoryMemory +ServerServer

HigherUtility:

MemcachedMemcached Instance Instance CapacityCapacity

Effective Effective CapacityCapacity

“Effective” ¢ “Effective” ¢ / GB/ GB

per hour

DIYDIY “Small”“Small”1.7 GB RAM1.7 GB RAM160 GB Storage160 GB Storage

1.02 GB RAM1.02 GB RAM0 GB Storage0 GB Storage

8.3¢8.3¢

Gear6*Gear6* “Small”“Small”1 7 GB RAM1 7 GB RAM 1 56 GB RAM1 56 GB RAM 5 4¢ (RAM only)5 4¢ (RAM only)Gear6Gear6 1.7 GB RAM1.7 GB RAM160 GB Storage160 GB Storage

1.56 GB RAM1.56 GB RAM2.1 GB Storage2.1 GB Storage

5.4¢ (RAM only)5.4¢ (RAM only)2.3¢ (total capacity)2.3¢ (total capacity)

DIYDIY “Quad“Quad XL”XL”68.4 GB RAM68.4 GB RAM16901690 GB StorageGB Storage

41.04 GB RAM41.04 GB RAM0 GB Storage0 GB Storage

5.8¢5.8¢

Gear6**Gear6** “Quad XL”“Quad XL”68.4 GB RAM68.4 GB RAM1690 GB Storage1690 GB Storage

62.93 GB RAM62.93 GB RAM1380 GB Storage1380 GB Storage

5.2¢5.2¢ (RAM only)(RAM only)0.2¢ (total capacity)0.2¢ (total capacity)

* Note: “Small” instance limited to 4 GB due to 32 bit platform

Better Better than “free”than “free”

32 : Copyright 2009 Gear6 Inc.

p** Note: Gear6 priced offerings include 24x7 support

Page 33: Cloud Scaling with Memcached

Gear6 Web Cache Server AMI SupportLinux USALinux, USA

AMI ClassAMI Class Instance SizesInstance Sizes Support & Services Support & Services pppp

“Small” FREE“Small” FREE•• Gear6 user forumGear6 user forum--based supportbased support

tand

ard

“Large”“Large”

St

•• Gear6 user forumGear6 user forum--based supportbased support•• 24x7 Email access to Technical Support 24x7 Email access to Technical Support

“Extra Large”“Extra Large” ServerServer

ppppincluding installation & troubleincluding installation & trouble--shooting shooting assistanceassistance

emor

y

“Double XL”“Double XL”

Hig

h-M

e “Quad XL”“Quad XL”

33 : Copyright 2009 Gear6 Inc.

Page 34: Cloud Scaling with Memcached

Thank You!

For more information:

www gear6 comwww.gear6.com

34 : Copyright 2009 Gear6 Inc.

Page 35: Cloud Scaling with Memcached

Questions?

Thank you for attending our webinar

Bill TakacsBill TakacsGear6Gear6Gear6Gear6

[email protected]@gear6.com+1 650 587 7118+1 650 587 7118

and please visit our web site at:

www.gear6.comwww.gear6.comand please visit our web site at:

35 : Copyright 2009 Gear6 Inc.

Page 36: Cloud Scaling with Memcached

Credits and References

Set Amazon’s Servers on Fire, Not Yours –AWS Start-Up Event 2009:

htt // lid h t/ / t fihttp://www.slideshare.net/aws/set-amazons-servers-on-fire

Cloud Architectures, Jinesh Varia. Technology Evangelist,Amazon Web Services ([email protected])

htt //ji h i 3 / bli / l d hit thttp://jineshvaria.s3.amazonaws.com/public/cloudarchitectures-varia.pdf-jsa90b_Z1Kw&sig2=GT9UWF2SMgodTQ9oQ_NsnQ

36 : Copyright 2009 Gear6 Inc.