Memcached magic Ligaya Turmelle. What is memcached briefly? memcached is a high-performance, distributed memory object caching system, generic in nature.

Slides:



Advertisements
Similar presentations
MEMCACHE FOR BIGINNERS
Advertisements

Chapter 17: WEB COMPONENTS
Copyright GeneGo CONFIDENTIAL »« MetaCore TM (System requirements and installation) Systems Biology for Drug Discovery.
1 Web Servers / Deployment Alastair Dawes Original by Bhupinder Reehal.
Serverless Network File Systems. Network File Systems Allow sharing among independent file systems in a transparent manner Mounting a remote directory.
Implementing ISA Server Caching. Caching Overview ISA Server supports caching as a way to improve the speed of retrieving information from the Internet.
A Dynamic Caching Mechanism for Hadoop using Memcached Gurmeet Singh Puneet Chandra Rashid Tahir University of Illinois at Urbana Champaign Presenter:
Apache : Installation, Configuration, Basic Security Presented by, Sandeep K Thopucherela, ECE Department.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Firewall and Proxy Server Director: Dr. Mort Anvari Name: Anan Chen Date: Summer 2000.
Web Proxy Server Anagh Pathak Jesus Cervantes Henry Tjhen Luis Luna.
Dynamic Web site With PHP and MySQL. MySQL The combination of MySQL database and PHP scripting language is optimum for building dynamic websites. MySQL.
1 Chapter Overview Introduction to Windows XP Professional Printing Setting Up Network Printers Connecting to Network Printers Configuring Network Printers.
VMware vCenter Server Module 4.
Installing and Setting up mongoDB replica set PREPARED BY SUDHEER KONDLA SOLUTIONS ARCHITECT.
Google AppEngine. Google App Engine enables you to build and host web apps on the same systems that power Google applications. App Engine offers fast.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
NovaBACKUP 10 xSP Technical Training By: Nathan Fouarge
Troubleshooting Guide for Network Hard Disk. Model - NH-200.
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
Implementing POP3 and IMAP4 Using Dovecot
Unit 06 : Index and Distributed Caching

Module 13: Configuring Availability of Network Resources and Content.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
5 Copyright © 2008, Oracle. All rights reserved. Configuring the Oracle Network Environment.
Memcached HTTPd mcd DB HTTPd mcd [memcached 설치 및 구동 ] -- memory object caching system *) 설정 없음 1. 설치 - memcached or /usr/ports/databases/memcached.
11 Copyright © 2005, Oracle. All rights reserved. Configuring the Oracle Network Environment.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
CIS 451: Servers, CGI and Log Files Dr. Ralph D. Westfall January, 2009.
Oracle10g RAC Service Architecture Overview of Real Application Cluster Ready Services, Nodeapps, and User Defined Services.
11 Copyright © 2005, Oracle. All rights reserved. Configuring the Oracle Network Environment.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Distributed File Systems
COLD FUSION Deepak Sethi. What is it…. Cold fusion is a complete web application server mainly used for developing e-business applications. It allows.
Module 1: Installing and Configuring Servers. Module Overview Installing Windows Server 2008 Managing Server Roles and Features Overview of the Server.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
EIDE Design Considerations 1 EIDE Design Considerations Brian Wright Portland General Electric.
Revolutionizing enterprise web development Memcache Optimization.
mysql-proxy By Farhad Saberi - Overview and architecture - Making The case for a proxy - Lua - Lua examples - The admin interface - currently.
1 Week #10Business Continuity Backing Up Data Configuring Shadow Copies Providing Server and Service Availability.
Apache Web Server Quick and Dirty for AfNOG 2015 (Originally by Joel Jaeggli for AfNOG 2007) ‏
Apache Web Server Quick and Dirty Evelyn NAMARA for AfNOG 2014 (Originally by Joel Jaeggli for AfNOG 2007) ‏
Implementing ISA Server Caching
ITGS Network Architecture. ITGS Network architecture –The way computers are logically organized on a network, and the role each takes. Client/server network.
PHP Performance w/APC + thaicyberpoint.com thaithinkpad.com thaihi5.com.
Visual Basic for Application - Microsoft Access 2003 Finishing the application.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Linux Operations and Administration
Lab 8 Overview Apache Web Server. SCRIPTS Linux Tricks.
Sem 2v2 Chapter 5 Router Startup and Setup. A router initializes by loading the bootstrap, the operating system, and a configuration file. If the router.
(ITI310) By Eng. BASSEM ALSAID SESSIONS 10: Internet Information Services (IIS)
Module 6: Administering Reporting Services. Overview Server Administration Performance and Reliability Monitoring Database Administration Security Administration.
Installing Koha Presented By Aaron R. Williams KOHA North American Users Group.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Web Cache. What is Cache? Cache is the storing of data temporarily to improve performance. Cache exist in a variety of areas such as your CPU, Hard Disk.
1 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Beginner's Guide to Website Performance with MySQL & memcached Adam.
COP 4343 Unix System Administration
memcached: an in-depth discussion about caching.
File System Implementation
LINUX ADMINISTRATION 1
Chapter 2: System Structures
Introduction to Networks
PHP / MySQL Introduction
Software Architecture in Practice
Scaling and Performance
Chapter 27 WWW and HTTP.
Nate Nelson I*LEVEL, Inc.
Web Servers / Deployment
Presentation transcript:

Memcached magic Ligaya Turmelle

What is memcached briefly? memcached is a high-performance, distributed memory object caching system, generic in nature AKA it is a key-based cache daemon that stores data and objects wherever dedicated or spare RAM is available for very quick access It is a dumb distributed hash table. It doesn’t provide redundancy, failover or authentication. If needed the client has to handle that.

Why was memcached made? It was originally developed by Danga Interactive to enhance the speed of LiveJournal.com It dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss

Where does memcached reside? Memcache is not part of the database but sits outside it on the server(s). Over a pool of servers

Pretty picture

When should I use memcached? When your database is optimized to the hilt and you still need more out of it. Lots of SELECTs are using resources that could be better used elsewhere in the DB. Locking issues keep coming up When table listings in the query cache are torn down so often it becomes useless To get maximum “scale out” of minimum hardware

Use cases anything what is more expensive to fetch from elsewhere, and has sufficient hitrate, can be placed in memcached How often will object or data be used? How expensive is it to generate the data? What is the expected hitrate? Will the application invalidate the data itself, or will TTL be used? How much development work has to be done to embed it?

Why use memcached? To reduce the load on the database by caching data BEFORE it hits the database Can be used for more then just holding database results (objects) and improve the entire application response time Feel the need for speed Memcache is in RAM - much faster then hitting the disk or the database

Why not use memcached? Memcache is held in RAM. This is a finite resource. Adding complexity to a system just for complexities sake is a waste. If the system can respond within the requirements without it - leave it alone

What are the limits of memcached? Keys can be no more then 250 characters Stored data can not exceed 1M (largest typical slab size) There are generally no limits to the number of nodes running memcache There are generally no limits the the amount of RAM used by memcache over all nodes 32 bit machines do have a limit of 4GB though

How do I easily install memcached? You can build and install memcached from the source code directly, or you can use an existing operating system package or installation. on a RedHat, Fedora or CentOS host, use yum: root-shell> yum install memcached on a Debian or Ubuntu host, use apt-get: root-shell> apt-get install memcached on a Gentoo host, use emerge: root-shell> emerge install memcached on OpenSolaris, use the pkg for SUNWmemcached: root-shell> pkg install SUNWmemcached

How do I compile memcached from source? Get the source from the website: ad.bml ad.bml Memcache has a dependancy on libevent so make sure you have that also. Decompress, cd into the dir./configure;make;make install;

How do I start memcached? Memcached can be run as a non-root user if it will not be on a restricted port (<1024) - though the user can not have a memory limit restriction shell> memcached Default configuration - Memory: 64MB, all network interfaces, port:11211, max simultaneous connections: 1024

Memcached options You can change the default configuration with various options. -u : run as user if started as root -m : maximum MB memory to use for items If more then available RAM - will use swap Don’t forget 4G limit on 32 bit machines -d : Run as a daemon -l : Listen on ; default to INDRR_ANY -p : port

Memcached options (con’t) -s : unix socket (disables network support) -c : max simultaneous connections -v : verbose -vv : (2 v’s) very verbose -P : PID file (used with -d) -t : number of threads to use to process incoming requests. Only valid if compiled with thread support enabled. Only useful up to number of CPU’s There is a man page available with the install with a full listing of options.

How can I connect to memcached? Memcached uses a protocol that many languages implement with an API. Languages that implement it: Perl, PHP, Python, Ruby, Java, C#, C, Lua, Postgres, MySQL, Chicken Scheme And yes - because it is a protocol you can even use telnet shell> telnet localhost 11211

Memcached protocol 3 types of commands Storage - ask the server to store some data identified by a key set, add, replace, append, prepend and cas Retrieval - ask the server to retrieve data corresponding to a set of keys get, gets

Memcached protocol (con’t) All others that don’t involve unstructured data Deletion:delete Increment/Decrement: incr, decr Statistics: stats, flush_all: always succeeds, invalidate all existing items immediately (by default) or after the expiration specified. version, verbosity, quit

PHP and Memcached Make sure you have a working Apache/PHP install PHP has a memcached extension available through pecl. Installation: shell> pecl install memcache Make sure the pear is installed (debian: apt-get install php- pear) Make sure that you also have php5-dev installed for phpize.  shell> apt-get install php5-dev

PHP Script Information about the PHP API at <?php // make a memcache object $memcache = new Memcache; // connect to memcache $memcache->connect('localhost', 11211) or die ("Could not connect"); //get the memcache version $version = $memcache->getVersion(); echo "Server's version: ".$version." \n";

PHP Script (con’t) // test data $tmp_object = new stdClass; $tmp_object->str_attr = 'test'; $tmp_object->int_attr = 123; // set the test data in memcache $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); echo "Store data in the cache (data will expire in 10 seconds) \n"; // get the data $get_result = $memcache->get('key'); echo "Data from the cache: \n"; echo ‘ ’, var_dump($get_result), ‘ ’;

PHP Script (con’t) // modify the data $tmp_object->str_attr = ‘boo’; $memcache->replace(‘key’, $tmp_object, false, 10) or die(“Failed to save new data to the server \n”); Echo “Stored data in the cache changed \n”; // get the new data $get_result = $memcache->get(‘key’); Echo “New data from the cache: \n”; Echo ‘ ’, var_dump($get_result), “ \n”; // delete the data $memcache->delete(‘key’) or die(“Data not deleted \n”);

MySQL’s memcached UDF’s Found at ns_for_MySQL.html ns_for_MySQL.html Will have to compile and build the functions./configure; make; make install; May wish to copy the MySQL memcached UDFs into your MySQL plugins directory

MySQL’s memcached UDF’s (con’t) you must initialize all the functions that you wish to have accessable within MySQL using CREATE and specifying the return value and library. (retained after restarts) Ex: mysql> CREATE FUNCTION memc_get RETURNS STRING SONAME "libmemcached_functions_mysql.so"; There is an SQL script in the UDF package to do this if you wish. shell> mysql < sql/install_functions.sql

MySQL’s memcached UDF’s (con’t) The API is consistent with the other API’s Connect: mysql> SELECT memc_servers_set(' :11211, :11211'); The list of servers used by the memcached UDFs is not persistent over restarts of the MySQL server. Set: mysql> SELECT memc_set('myid', 'myvalue'); Retreive: mysql> SELECT memc_get('myid');

Possible ways to secure memcached It has no authentication system - so protection is important Run as a non-priveledged user to minimize potential damage Specify the ip address to listen on using -l , , specific ip address Use a non-standard port Use a firewall

Memcache project Project home: Bug reports: s/list s/list Internal MySQL see -

Memcached project (con’t) SVN Source code: Browse at Use this command to anonymously check out the latest project source code: svn checkout memcached-read-only Non-members may check out a read-only working copy anonymously over HTTP.

Questions?