Basics of Memcached - Introduction

Post on 20-May-2015

1.515 views 6 download

Tags:

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.

Transcript of Basics of Memcached - Introduction

MemCachedBecause fetching data from disk is too

expensive

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

The WEB : What’s Changed?

Population

Traffic

Content and Applications

Rise of Dynamic Web

Web Growth : Population

Web Growth : Traffic

Web Growth: Application & Content

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

Shift to dynamic content put strain on origin sites.

Web Architecture

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

Theory of Caching

Where does it fit in Web Architecture?

How MemCached Works

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…

Consistent Hashing

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…

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

How does it help in scaling

Evolution of a dynamic site #1

Evolution of a dynamic site #2

Evolution of a dynamic site #3

MemCached & MySql

MemCached & MySql Scale out

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

Traditional Vs MemCached

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 ?

accessed with sql .

Persistent.

Replicated.

Secure..

What MemCached isn’t

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

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 ?

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

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

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…