Memcache Integration with Innodb

16
Memcache Integration with Innodb Presenter: Runish Kumar, Mindfire Solutions Date: 15/09/2014

description

InnoDB memcached plugin is introduced in MySQL5.6 to increase the performance of reading and writing data to InnoDB tables using memcached protocol. In this seminar we will cover basic usage of this plugin.

Transcript of Memcache Integration with Innodb

Page 1: Memcache Integration with Innodb

Memcache Integration with Innodb

Presenter: Runish Kumar, Mindfire SolutionsDate: 15/09/2014

Page 2: Memcache Integration with Innodb

Presenter: Runish Kumar, Mindfire Solutions

About Me

Zend Certified PHP developervSkills Certified Python developer

Skills: PHP, Python, MySQL, Ubuntu, Memcache, Apache

Connect with me: Facebook: https://www.facebook.com/runishkumar LinkedIn: https://www.linkedin.com/in/runishkumar Twitter: https://twitter.com/runishkumar

Contact me: Email: [email protected], [email protected] Skype: mfsi_runishk

Page 3: Memcache Integration with Innodb

Presenter: Runish Kumar, Mindfire Solutions

Agenda

• Introduction to Innodb integration with memcache

• Why to use memcached plugin

• Installation and setup

• How it works

• Demo

• Limitations

• Q&A

Page 4: Memcache Integration with Innodb

Introduction

• InnoDB is a general-purpose storage engine that balances high reliability and high performance.

• Memcached is a general-purpose distributed memory caching system.

• InnoDB Memcached daemon provides a way to interact with Innodb tables using memcached protocol.

• Introduced in MySQL5.6

• No-SQL in MySQL?

Presenter: Runish Kumar, Mindfire Solutions

Page 5: Memcache Integration with Innodb

Why to use it?

• Provides direct access to InnoDB table eliminating SQL processing.

• Can be used for caching data. Communication with InnoDB is handled out of the box by the plugin.

• Provides combination of performace (by caching data in to memory) and persistance (by writing all data to InnoDB).

• Data can still be accessed through conventional SQL query.

• Gives us the ability to fetch any record fast using primary key from memcache. At the same time we can do aggregation operation on same data using SQL query if needed.

Presenter: Runish Kumar, Mindfire Solutions

Page 6: Memcache Integration with Innodb

Installation and Setup

Prerequisite:

• Must have libevent installed

• Can be installed with sudo apt-get install libevent-dev

• plugin/libmemcached.so and plugin/innodb_engine.so must be present under mysql plugin folder

Presenter: Runish Kumar, Mindfire Solutions

Page 7: Memcache Integration with Innodb

Two ways to get plugin files:

• Install MySQL from package manager http://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/

• Compile MySQL from source http://dev.mysql.com/doc/refman/5.6/en/source-installation.html

Build with -DWITH_INNODB_MEMCACHED=ON option.

Optionally you can also add option -DWITH_LIBEVENT if libevent is not installed in your machine.

Presenter: Runish Kumar, Mindfire Solutions

Page 8: Memcache Integration with Innodb

Installation:

mysql> source MYSQL_HOME/share/innodb_memcached_config.sql;

mysql> install plugin daemon_memcached soname "libmemcached.so";

UnInstallation:

mysql> uninstall plugin daemon_memcached;

Presenter: Runish Kumar, Mindfire Solutions

Page 9: Memcache Integration with Innodb

Setup/Configuration options:

• Run memcahe daemon on port of your choice --daemon_memcached_option="-p11222"

• daemon_memcached_r_batch_size, batch commit size for read operations (get)

• daemon_memcached_w_batch_size, batch commit for any write operations (set, replace, append, prepend,incr, decr, and so on)

Presenter: Runish Kumar, Mindfire Solutions

Page 10: Memcache Integration with Innodb

How It Works?

Presenter: Runish Kumar, Mindfire Solutions

Page 11: Memcache Integration with Innodb

Try a demo :)

• Memcache key can not contain spaces or new line character.

• Numeric values gets converted to string when it passes through memcache plugin. Cast it to back to numeric value before using it in arithmatic operation. e.g, SUM(), AVG() etc.

• If the InnoDB column you use as a key can be longer than 250 bytes, hash it to a value that is less than 250 bytes.

• If primary key of table is short, we can use it as lookup key for memcache.

Presenter: Runish Kumar, Mindfire Solutions

Page 12: Memcache Integration with Innodb

Limitations

• You cannot use a partitioned table for data queried or stored through the memcached interface.

• All fileds mapped with memcache has to be varchar.

• Complex queries can not be performed using memcache plugin.

• Aggregation operation can not be performed through memcache plugin.

• Security Concerns.

Presenter: Runish Kumar, Mindfire Solutions

Page 13: Memcache Integration with Innodb

Presenter: Runish Kumar, Mindfire Solutions

Question and Answer

Page 14: Memcache Integration with Innodb

• http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached.html

http://blog.ulf-wendel.de/2013/using-phps-memcache-interface-to-query-mysql-5-7/

http://www.slideshare.net/nixnutz/nosql-in-mysql

Presenter: Runish Kumar, Mindfire Solutions

Page 15: Memcache Integration with Innodb

Presenter: Runish Kumar, Mindfire Solutions

Thank you