29
MemCached Because fetching data from disk is too expensive

Basics of Memcached - Introduction

Embed Size (px)

DESCRIPTION

This presentation basically deals with the concepts of memCached. The focus of this presentation is only discussing about theory of memCached.How to implement it and how to configure it. if you want to stick with ACID properties and you want to scale your system definitely Memcached is the right candidate. This presentation was presented by Prashant Prakash, a Sr. Software Engineer in Samsung.

Citation preview

Page 1: Basics of Memcached - Introduction

MemCachedBecause fetching data from disk is too

expensive

Page 2: Basics of Memcached - Introduction

Rise of the Dynamic Web Web Architecture What is MemCached Theory Of Caching How MemCached works Evolution of Dynamic Web Scaling Traditional Vs MemCached

Overview

Page 3: Basics of Memcached - Introduction

The WEB : What’s Changed?

Population

Traffic

Content and Applications

Rise of Dynamic Web

Page 4: Basics of Memcached - Introduction

Web Growth : Population

Page 5: Basics of Memcached - Introduction

Web Growth : Traffic

Page 6: Basics of Memcached - Introduction

Web Growth: Application & Content

Page 7: Basics of Memcached - Introduction

Most Sites (over 65%) based on LAMP or JAVA.

Shift to dynamic content put strain on origin sites.

Web Architecture

Page 8: Basics of Memcached - Introduction

Complexa high performance ,distributed memory object caching ,generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Simplea really big ,platform independent ,dictionary like object that lives in memory and can be intelligently sliced across multiple computers.

What is MemCached

Page 9: Basics of Memcached - Introduction

Theory of Caching

Page 10: Basics of Memcached - Introduction

Where does it fit in Web Architecture?

Page 11: Basics of Memcached - Introduction

How MemCached Works

Page 12: Basics of Memcached - Introduction

It uses consistent Hashing Technique to find the appropriate server where the data is residing or where the data has to be cached.

Consistent Hashing :

◦ server =serverlist[hash(key)%serverlist.length]

How MemCached works contd…

Page 13: Basics of Memcached - Introduction

Consistent Hashing

Page 14: Basics of Memcached - Introduction

Pros◦ If one server goes down , all of its request move

on to the next server.◦ Seamlessly add new servers.

Cons◦ Hashes distribute mostly evenly ,but could cluster.

Split servers into multiple sub-server nodes.

Consistent Hashing Contd…

Page 15: Basics of Memcached - Introduction

It scales horizontally.◦ More servers create more capacity.◦ No single point failure.

How does it help in scaling

Page 16: Basics of Memcached - Introduction

Evolution of a dynamic site #1

Page 17: Basics of Memcached - Introduction

Evolution of a dynamic site #2

Page 18: Basics of Memcached - Introduction

Evolution of a dynamic site #3

Page 19: Basics of Memcached - Introduction

MemCached & MySql

Page 20: Basics of Memcached - Introduction

MemCached & MySql Scale out

Page 21: Basics of Memcached - Introduction

There are other distributed cache like :• EHCache• OSCache• JBossCache

THEN WHY DO WE NEED MEMCACHED?The only reason is that memCached is ourely

distributed with dedicated servers for caching . It does not rum with application server.

Other Distributed Caching

Page 22: Basics of Memcached - Introduction

Traditional Vs MemCached

Page 23: Basics of Memcached - Introduction

Data is Stored in memory ,not disk.

I/O is non-blocking(asynchronous)

epoll() instead of poll for network event loop.

It’s distributed.

Why is MemCached Fast ?

Page 24: Basics of Memcached - Introduction

accessed with sql .

Persistent.

Replicated.

Secure..

What MemCached isn’t

Page 25: Basics of Memcached - Introduction

A single entry cannot be larger than 1mb.

Keys are limited to 250 Characters.

Cache Algorithm is LRU.

Key Size = 250 bytes Value Size = 1 Mbytes

MemCached gotchas

Page 26: Basics of Memcached - Introduction

In General ◦ Cache everything that is slow to query ,fetch or

calculate. Some use cases

◦ Ideal for complex objects that are read several times.

◦ Keeps the current state of application in Cache.◦ Cache directly displayable page elements.

What to Cache ?

Page 27: Basics of Memcached - Introduction

Shard MySQL to handle high write loads , cache objects in memcached to handle high read laods, and then write lot of glue code to make it all work together.

Food for thought

Page 28: Basics of Memcached - Introduction

The main limitations of the current Memcached implementations are the lack of support for : ◦ Write Scalability◦ High Availability

With a little perspective its clear that MySQL+Memcached era is passing. ◦

MySQL and memcached :End of an Era

Page 29: Basics of Memcached - Introduction

Whatever written in previous slide is really an observation about industry trends and isn’t meant to attack any technology

If we are using RDBMS and we want to scale out the application then Memcached is the right Candidate.In Simple , If we need ACID properties we need MemCached for scaling.

MySQL and memcached :End of an Era contd…