Using Couchbase Server to Address Memcached Challenges - Webinar

42
1 Using Couchbase Server to Solve Memcached Challenges Simple. Fast. Elastic. Don Pinto Product Marketing Manager Kendall Bennett CEO, A Main Hobbies

Transcript of Using Couchbase Server to Address Memcached Challenges - Webinar

Page 1: Using Couchbase Server to Address Memcached Challenges - Webinar

1

Using Couchbase Server to Solve Memcached Challenges

Simple. Fast. Elastic.

Don PintoProduct Marketing Manager

Kendall Bennett CEO, A Main Hobbies

Page 2: Using Couchbase Server to Address Memcached Challenges - Webinar

2

The Problem

Web Applications Need to Run Fast!

But this usually means ….

Page 3: Using Couchbase Server to Address Memcached Challenges - Webinar

3

Your Relational Database Needs Help

App App

Relational Database

And so…

Page 4: Using Couchbase Server to Address Memcached Challenges - Webinar

4

You Add a Cache

But that’s still not enough and you still have problems…

Relational Database

App App

Page 5: Using Couchbase Server to Address Memcached Challenges - Webinar

5

Agenda

• Challenges using Memcached• Cold Cache• Heavy RDBMS Contention• Lack of Scalability• Complex Monitoring

• Introducing Couchbase Server• Technical Considerations of Couchbase Server • Solutions to Memcached Challenges • Deployment Options for Couchbase Server• Using Couchbase Server at A Main Hobbies (presented by Kendall Bennett) • Q&A

Page 6: Using Couchbase Server to Address Memcached Challenges - Webinar

6

Memcached Reference Architecture

Page 7: Using Couchbase Server to Address Memcached Challenges - Webinar

7

CHALLENGES WITH MEMCACHED

Page 8: Using Couchbase Server to Address Memcached Challenges - Webinar

8

Cold Cache

Slowdown or collapse of the RDBMS Layer

App App

E F G H

B E F C D H

I J K L

A B C D

Application

IndividualMemcached

Nodes

RDBMS

Page 9: Using Couchbase Server to Address Memcached Challenges - Webinar

9

Lack of Scalability

Duplicate Information. Explicit Cache Warm-up. Difficult to Invalidate.

App App

E F G H

B E F C D H

I J K L

A B C D

Application

IndividualMemcached

Nodes

RDBMS

App

D F.. .. ..

Page 10: Using Couchbase Server to Address Memcached Challenges - Webinar

10

Lack of Scalability – If partitioned

Duplicate Information. Explicit Cache Warm-up. Difficult to Invalidate.

App App

C F G H

D J K L

A B E I

Application

IndividualMemcached

Nodes

RDBMS

App

.. .. ..A J LD E H I LD F G IC

Page 11: Using Couchbase Server to Address Memcached Challenges - Webinar

11

Complex Monitoring

Complicated Management of Individual Memcached NodesLack of Single Consistent View of the Caching Tier

Page 12: Using Couchbase Server to Address Memcached Challenges - Webinar

12

COUCHBASE SERVER

Page 13: Using Couchbase Server to Address Memcached Challenges - Webinar

13

Couchbase Server: Simple. Fast. Elastic. NoSQL.

• Easy scalability• Scale your the database layer without any interruption

or change to your application • Grow your cluster from 5 to 25 to 100 nodes and evenly

distributed workloads across your cluster

• Consistent High Performance• Consistent sub-millisecond response times • High throughput means fewer servers required to serve

growing numbers of users

• Always on• With high availability features applications are always

online• Whether upgrading the database, system software or

hardware - zero downtime

Page 14: Using Couchbase Server to Address Memcached Challenges - Webinar

14

Memcached tier replacement use-case

• Fully memcached protocol compatible. Drop-in replacement• Frequently accessed items kept in memory• Data auto-sharded and replicated across the cluster• Consistent low latency read and write operations • High Throughput• Enjoy the scalability and high-availability advantages of a

Couchbase Server cluster • Single view for monitoring across the cluster

Page 15: Using Couchbase Server to Address Memcached Challenges - Webinar

15

Replacing a Memcached Tier with a Couchbase Cluster

Page 16: Using Couchbase Server to Address Memcached Challenges - Webinar

16

33 2

Single node operations: Couchbase Write2

Managed Cache

Dis

k Q

ueue

Disk

Replication Queue

App Server

Couchbase Server Node

Doc 1Doc 1

Doc 1

To other node

Page 17: Using Couchbase Server to Address Memcached Challenges - Webinar

17

33 2

Single node operations: Couchbase Update2

Managed Cache

Dis

k Q

ueue

Replication Queue

App Server

Couchbase Server Node

Doc 1’

Doc 1

Doc 1’Doc 1

Doc 1’

Disk

To other node

Page 18: Using Couchbase Server to Address Memcached Challenges - Webinar

18

GET

Doc

1

33 2

Single node operations: Couchbase Read2

Dis

k Q

ueue

Replication Queue

App Server

Couchbase Server Node

Doc 1

Doc 1Doc 1

Managed Cache

Disk

To other node

Page 19: Using Couchbase Server to Address Memcached Challenges - Webinar

19

33 2

Single node operations: Couchbase Cache Eviction2

Dis

k Q

ueue

Replication Queue

App Server

Couchbase Server Node

Doc 1

Doc 6Doc 5Doc 4Doc 3Doc 2

Doc 1

Doc 6 Doc 5 Doc 4 Doc 3 Doc 2

Managed Cache

Disk

To other node

Page 20: Using Couchbase Server to Address Memcached Challenges - Webinar

20

33 2

Single node operations: Couchbase Cache Miss2

Dis

k Q

ueue

Replication Queue

App Server

Couchbase Server Node

Doc 1

Doc 3Doc 5 Doc 2Doc 4

Doc 6 Doc 5 Doc 4 Doc 3 Doc 2

Doc 4

GET

Doc

1

Doc 1

Doc 1

Managed Cache

Disk

To other node

Page 21: Using Couchbase Server to Address Memcached Challenges - Webinar

21

Cluster wide operations: Add Nodes

Read/Write/Update Read/Write/Update

Doc 7

Doc 9

Doc 3

Active Docs

Replica Docs

Doc 6

COUCHBASE CLIENT LIBRARY

CLUSTER MAP

APP SERVER 1

COUCHBASE CLIENT LIBRARY

CLUSTER MAP

APP SERVER 2

Doc 4

Doc 2

Doc 5

SERVER 1

Doc 6

Doc 4

SERVER 2

Doc 7

Doc 1

SERVER 3

Doc 3

Doc 9

Doc 7

Doc 8 Doc 6

Doc 3

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

DOC

Doc 9

Doc 5

DOC

DOC

DOC

Doc 1

Doc 8 Doc 2

Replica Docs Replica Docs Replica Docs

Active Docs Active Docs Active Docs

SERVER 4 SERVER 5

Active Docs Active Docs

Replica Docs Replica Docs

COUCHBASE SERVER CLUSTER

Page 22: Using Couchbase Server to Address Memcached Challenges - Webinar

22

Cluster wide operations: Failover

Doc 7

Doc 9

Doc 3

Active Docs

Replica Docs

Doc 6

COUCHBASE CLIENT LIBRARY

CLUSTER MAP

APP SERVER 1

COUCHBASE CLIENT LIBRARY

CLUSTER MAP

APP SERVER 2

Doc 4

Doc 2

Doc 5

SERVER 1

Doc 6

Doc 4

SERVER 2

Doc 7

Doc 1

SERVER 3

Doc 3

Doc 9

Doc 7 Doc 8

Doc 6

Doc 3

DOC

DOC

DOCDOC

DOC

DOC

DOC DOC

DOC

DOC

DOC DOC

DOC

DOC

DOC

Doc 9

Doc 5DOC

DOC

DOC

Doc 1

Doc 8

Doc 2

Replica Docs Replica Docs Replica Docs

Active Docs Active Docs Active Docs

SERVER 4 SERVER 5

Active Docs Active Docs

Replica Docs Replica Docs

COUCHBASE SERVER CLUSTER

Page 23: Using Couchbase Server to Address Memcached Challenges - Webinar

23

Monitoring

• Real-time traffic graphs• Per bucket, per node and aggregate

statistics• Application and inter-node traffic• RAM <-> Disk• REST API

Page 24: Using Couchbase Server to Address Memcached Challenges - Webinar

24

Deployment Options

Page 25: Using Couchbase Server to Address Memcached Challenges - Webinar

25

Technical Considerations

• Ejection instead of eviction• Increased disk and network I/O• Memory pressure and bulk-loading• Sizing changes• Database warm-up

Page 26: Using Couchbase Server to Address Memcached Challenges - Webinar

26

COUCHBASE SERVER ATA MAIN HOBBIES

How we use it today and plans for the future

Kendall Bennett CEO, A Main Hobbies

Page 27: Using Couchbase Server to Address Memcached Challenges - Webinar

27

About Kendall Bennett

• Founder and CEO of A Main Hobbies• Leading online internet retailer of radio controlled

cars, trucks, helicopters and airplanes• Computer programmer with over 20 years of

industry experience• Prior company, SciTech Software, Inc. was a

computer software library developer

Page 28: Using Couchbase Server to Address Memcached Challenges - Webinar

28

Prior Solution

• Database server runs on Linux using MySQL• Web server runs on ASP.NET on Windows using a

combination of PHP code compiled with Phalanger and ASP.NET MVC written in C#

• Caching was done using the Window File System– Cached SQL result sets and HTML fragments using the disk

to speed up page load times - Poor Performance!

• Started looking for a high-performance caching solution

Page 29: Using Couchbase Server to Address Memcached Challenges - Webinar

29

Using Couchbase Server as a cache

• We deployed it live and immediately noticed speed improvements on the web site

• With a better caching solution we spent more time improving what we cached for even more performance

Page 30: Using Couchbase Server to Address Memcached Challenges - Webinar

30

Using Sentinels to Invalidate the Cache

• We needed the ability to invalidate large chunks of the cache quickly based on user events (such as editing a product category, etc).

• Keeping track of all the cached entries in a list was the initial solution, but adds a lot of overhead when reading and writing cache entries to update the lists

• A better solution is to use sentinel objects to invalidate cache entries

• Writing to the cache is extremely fast, as it does nothing but write the actual data

• Reading from the cache checks a list of sentinels to see if they have changed since the last read

• Writing the most recently read sentinel list is done inside the read before it returns a failure

Page 31: Using Couchbase Server to Address Memcached Challenges - Webinar

31

ICacheStore Interface

• public interface ICacheStore• {• /// <summary>• /// Writes out a serialized object to the cache• /// </summary>• /// <param name="o">Object to write to the cache</param>• /// <param name="group">Cache group that this item belongs to</param>• /// <param name="key">Key name for this cache item</param>• /// <param name="expiresAt">Optional date/time stamp that the cached item will expire at</param>• void Write(• object o,• string group,• string key,• DateTime? expiresAt);

• /// <summary>• /// Reads a serialized object from the cache• /// </summary>• /// <param name="o">Place to return the object read from the cache</param>• /// <param name="group">Cache group that this item belongs to</param>• /// <param name="key">Key name for this cache item</param>• /// <param name="dependencies">List of dependent sentinels this item is dependent on</param>• /// <returns>True if the item was read from the cache, false if not</returns>• bool Read(• out object o,• string group,• string key,• List<string> dependencies = null);

• /// <summary>• /// Invalidates all the cache entries for this specific cache sentinel value• /// </summary>• /// <param name="sentinel">Name of the sentinel to invalidate (group name or dependent sentinel)</param>• void InvalidateCache(• string sentinel);

• /// <summary>• /// Returns the current value for a cache sentinel. This value will increment on each invalidation• /// so you can tell if it was invalidated if the number changes• /// </summary>• /// <param name="sentinel">Name of the sentinel to read the value for</param>• string GetCacheSentinel(• string sentinel);• }

Page 32: Using Couchbase Server to Address Memcached Challenges - Webinar

32

ASP.NET Session State Provider with Couchbase

• Previously we stored session data in MySQL with a customer session state provider

• To improve performance we moved the session state store to Couchbase using a modified version of the Couchbase ASP.NET library

• Session date is stored in persistent Couchbase buckets

• Performance is excellent and takes load off of our MySQL server

• Security is enhanced as it is not possible for hackers to query the data from the session store for all sessions

Page 33: Using Couchbase Server to Address Memcached Challenges - Webinar

33

ASP.NET Output Cache Provider with Couchbase

• We wanted a full page cache for our site for spiders such as Google when they crawl it, updated only once per day

• ASP.NET has a great Output Cache system already, so we wrote an Output Cache provider for it using Couchbase

• Watch out for session Cookies! The ASP.NET Output Cache will not work if the page tries to set a Cookie!

• Make sure you disable session when you know a spider is looking (we use Javascript to set a cookie so we know a real browser is looking)

Page 34: Using Couchbase Server to Address Memcached Challenges - Webinar

34

Future Directions

• Our goal is to replace MySQL for basic site data such as product pages, information pages, etc and store those in a Couchbase persistent NoSQL store

• MySQL will be kept for the core transactional component of placing orders and managing inventory levels

• That way we can scale the web site more easily as Couchbase can scale out better than MySQL and keep the load down on the MySQL server

• We need the ability to index data in the NoSQL store, so we are waiting on Couchbase 2.0 to be released before we move forward

Page 35: Using Couchbase Server to Address Memcached Challenges - Webinar

35

More Information

• More information can be found on my blog

• http://www.AMainHobbies.com/FromTheCEO

Page 37: Using Couchbase Server to Address Memcached Challenges - Webinar

37

Coming September 21, 2012

SAN FRANCISCO

Featured speakers include:

Use promo code WEBINAR and get 10% off.http://www.couchbase.com/couchconf-san-francisco

Page 38: Using Couchbase Server to Address Memcached Challenges - Webinar

38

Q & A

Page 39: Using Couchbase Server to Address Memcached Challenges - Webinar

39

APPENDIX

Page 40: Using Couchbase Server to Address Memcached Challenges - Webinar

40

Key results of Cisco benchmark

Couchbase Server demonstrates

• Consistent sub-millisecond latency for mixed workload

• High throughput

• Linear scalability

Page 41: Using Couchbase Server to Address Memcached Challenges - Webinar

41

Consistent low latency with varying doc sizes

Consistently low latencies in microseconds for

varying documents sizes with a mixed workload

Page 42: Using Couchbase Server to Address Memcached Challenges - Webinar

42

High throughput that scales linearly

Linear throughput scalability

High throughput with 1.4 GB/sec data transfer rate

using 4 servers