SlideShare una empresa de Scribd logo
1 de 118
Descargar para leer sin conexión
Memcachedb: The Complete Guide

                        Steve Chu
                    stvchu@gmail.com

                         ICRD-Web@Sina


                       March 12, 2008




Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   1 / 73
Part I

                          Getting Started

1   What is Memcachedb?

2   Why Memcachedb?

3   Memcachedb Features

4   Supported Commands

5   Benchmark



        Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   2 / 73
What is Memcachedb?


What is Memcachedb?


1   What is Memcachedb?

2   Why Memcachedb?

3   Memcachedb Features

4   Supported Commands

5   Benchmark




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   3 / 73
What is Memcachedb?


What is Memcachedb?


    ”Memcachedb is a distributed key-value storage system designed
    for persistent.”
A complete memcached, but
    *NOT* a cache solution
    Memcached is good enough for cache.
    *NO* expiration
    For memcache protocol compatible, still reserved, but we do nothing.
    Totally for persistent
    Transaction, replication, we do our best to achieve persistent.




       Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   4 / 73
Why Memcachedb?


Why Memcachedb?


1   What is Memcachedb?

2   Why Memcachedb?

3   Memcachedb Features

4   Supported Commands

5   Benchmark




        Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   5 / 73
Why Memcachedb?


Why Memcachedb?(1/2)


We have MySQL, we have PostgreSQL, we have a lot of RDBMSs, but
why we need Memcachedb?
    RDBMS is slow
    All they have a complicated SQL engine on top of storage. Our data
    requires to be stored and retrieved damnable fast.
    Not concurrent well
    When thousands of clients, millions of requests happens...
    But the data we wanna store is very small size!
    Cost is high if we use RDBMS.




       Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   6 / 73
Why Memcachedb?


Why Memcachedb?(2/2)


Many critical infrastructure services need fast, reliable data storage and
retrieval, but do not need the flexibility of dynamic SQL queries.
    Index, Counter, Flags
    Identity Management(Account, Profile, User config info, Score)
    Messaging
    Personal domain name
    meta data of distributed system
    Other non-relatonal data
    ...




          Steve Chu         Memcachedb: The Complete Guide    March 12, 2008   7 / 73
Memcachedb Features


Memcachedb Features


1   What is Memcachedb?

2   Why Memcachedb?

3   Memcachedb Features

4   Supported Commands

5   Benchmark




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   8 / 73
Memcachedb Features


Memcachedb Features


   High performance read/write for a key-value based object
   Rapid set/get for a key-value based object, not relational. Benchmark
   will tell you the true later.
   High reliable persistent storage with transaction
   Transaction is used to make your data more reliable.
   High availability data storage with replication
   Replication rocks! Achieve your HA, spread your read, make your
   transaction durable!
   Memcache protocol compatibility
   Lots of Memcached Client APIs can be used for Memcachedb, almost
   in any language, Perl, C, Python, Java, ...



      Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   9 / 73
Supported Commands


Supported Commands


1   What is Memcachedb?

2   Why Memcachedb?

3   Memcachedb Features

4   Supported Commands

5   Benchmark




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   10 / 73
Supported Commands


Standard Memcache Commands


       ‘get’ Retrieval of one or multiple items
       ‘set’ ”Store this data”
       ‘add’ ”Store this data, but only if the server *doesn’t* already
             hold data for this key”
  ‘replace’ ”Store this data, but only if the server *does* already hold
            data for this key”
   ‘delete’ deletes one item based a key
‘incr/decr’ Increment or decrement a numeric value. It’s atomic!
    ‘stats’ shows the status of current deamon. ’stats’, ’stats malloc’,
            ’stats maps’



       Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   11 / 73
Supported Commands


Private Commands

‘db checkpoint’ does a checkpoint manuanlly.
‘db archive’ removes log files that are no longer needed.
‘stats bdb’ shows the status of BerkeleyDB.
‘rep ismaster’ shows whether the site is a master.
‘rep whoismaster’ shows which site is a master.
‘rep set priority’ sets the priority of a site for electing in replication.
‘rep set ack policy’ sets ACK policy of the replication.
‘rep set ack timeout’ sets ACK timeout value of the replication .
‘rep set bulk’ Enable bulk transfer or not in replication.
‘rep set request’ sets the minimum and maximum number of missing
            log records that a client waits before requesting
            retransmission.
‘stats rep’ shows the status of Replication.
        Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   12 / 73
Benchmark


Benchmark


1   What is Memcachedb?

2   Why Memcachedb?

3   Memcachedb Features

4   Supported Commands

5   Benchmark




        Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   13 / 73
Benchmark


Environment


   Box: Dell 2950III
   OS: Linux CentOS 5
   Version: memcachedb-1.0.0-beta
   Client API: libmemcached




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   14 / 73
Benchmark


Non-thread Version

key: 16 value: 100B, 8 concurrents, every process does 2,000,000 set/get

memcachedb -d -r -u root -H /data1/mdbtest/ -N -v

    Write
     No.            1     2      3        4         5        6     7     8       avg.
     Cost(s)       807   835    840      853       859      857   865   868      848
                         2000000 * 8 / 848 = 18868 w/s
    Read
     No.            1     2      3        4         5        6     7     8       avg.
     Cost(s)       354   354    359      358       357      364   363   365      360
                          2000000 * 8 / 360 = 44444 r/s



       Steve Chu               Memcachedb: The Complete Guide           March 12, 2008   15 / 73
Benchmark


Thread Version

key: 16 value: 100B, 8 concurrents, every process does 2,000,000 set/get

memcachedb -d -r -u root -H /data1/mdbtest/ -N -t 4 -v

    Write
     No.            1     2      3        4         5        6     7     8       avg.
     Cost(s)       663   669    680      680       684      683   687   686      679
                         2000000 * 8 / 679 = 23564 w/s
    Read
     No.            1     2      3        4         5        6     7     8       avg.
     Cost(s)       245   249    250      248       248      249   251   250      249
                          2000000 * 8 / 249 = 64257 r/s



       Steve Chu               Memcachedb: The Complete Guide           March 12, 2008   16 / 73
Part II

                            MDB In Action

6   Installation

7   Running Options Explained

8   Managing Daemon

9   Commands Using telnet




         Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   17 / 73
Installation


Installation



6   Installation


7   Running Options Explained


8   Managing Daemon


9   Commands Using telnet




         Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   18 / 73
Installation


Dependencies


   libevent An event notification library that provides a mechanism to
            execute a callback function when a specific event occurs on a
            file descriptor or after a timeout has been reached. Now it
            supports /dev/poll, kqueue(2), event ports, select(2), poll(2)
            and epoll(4).
            http://www.monkey.org/~provos/libevent/
BerkeleyDB The industry-leading open source, embeddable database
            engine that provides developers with fast, reliable, local
            persistence with zero administration.
            http://www.oracle.com/technology/products/
            berkeley-db/db/index.html



       Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   19 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz
~ % cd libevent-1.3e




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz
~ % cd libevent-1.3e
~/libevent-1.3e % ./configure
...




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz
~ % cd libevent-1.3e
~/libevent-1.3e % ./configure
...
~/libevent-1.3e % make
...




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz
~ % cd libevent-1.3e
~/libevent-1.3e % ./configure
...
~/libevent-1.3e % make
...
~/libevent-1.3e % su
Password:




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz
~ % cd libevent-1.3e
~/libevent-1.3e % ./configure
...
~/libevent-1.3e % make
...
~/libevent-1.3e % su
Password:
/home/sc/libevent-1.3e # make install
...




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing libevent


~ % tar zvxf libevent-1.3e.tar.gz
~ % cd libevent-1.3e
~/libevent-1.3e % ./configure
...
~/libevent-1.3e % make
...
~/libevent-1.3e % su
Password:
/home/sc/libevent-1.3e # make install
...
/home/sc/libevent-1.3e # exit



       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   20 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21
~ % cd build unix




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21
~ % cd build unix
~/db-4.6.21/build unix % ../dist/configure
...




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21
~ % cd build unix
~/db-4.6.21/build unix % ../dist/configure
...
~/db-4.6.21/build unix % make
...




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21
~ % cd build unix
~/db-4.6.21/build unix % ../dist/configure
...
~/db-4.6.21/build unix % make
...
~/db-4.6.21/build unix % su
Password:




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21
~ % cd build unix
~/db-4.6.21/build unix % ../dist/configure
...
~/db-4.6.21/build unix % make
...
~/db-4.6.21/build unix % su
Password:
/home/sc/db-4.6.21/build unix # make install
...




      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing BerkeleyDB


~ % tar zvxf db-4.6.21.tar.gz
~ % cd db-4.6.21
~ % cd build unix
~/db-4.6.21/build unix % ../dist/configure
...
~/db-4.6.21/build unix % make
...
~/db-4.6.21/build unix % su
Password:
/home/sc/db-4.6.21/build unix # make install
...
/home/sc/db-4.6.21/build unix # exit


      Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   21 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz
~ % cd memcachedb-1.0.3-beta




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz
~ % cd memcachedb-1.0.3-beta
~/memcachedb-1.0.3-beta % ./configure #--enable-threads if
you wanna thread version
...




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz
~ % cd memcachedb-1.0.3-beta
~/memcachedb-1.0.3-beta % ./configure #--enable-threads if
you wanna thread version
...
~/memcachedb-1.0.3-beta % make
...




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz
~ % cd memcachedb-1.0.3-beta
~/memcachedb-1.0.3-beta % ./configure #--enable-threads if
you wanna thread version
...
~/memcachedb-1.0.3-beta % make
...
~/memcachedb-1.0.3-beta % su
Password:




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz
~ % cd memcachedb-1.0.3-beta
~/memcachedb-1.0.3-beta % ./configure #--enable-threads if
you wanna thread version
...
~/memcachedb-1.0.3-beta % make
...
~/memcachedb-1.0.3-beta % su
Password:
/home/sc/memcachedb-1.0.3-beta # make install
...




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Installation


Installing Memcachedb


~ % tar zvxf memcachedb-1.0.3-beta.tar.gz
~ % cd memcachedb-1.0.3-beta
~/memcachedb-1.0.3-beta % ./configure #--enable-threads if
you wanna thread version
...
~/memcachedb-1.0.3-beta % make
...
~/memcachedb-1.0.3-beta % su
Password:
/home/sc/memcachedb-1.0.3-beta # make install
...
/home/sc/memcachedb-1.0.3-beta # exit


      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   22 / 73
Running Options Explained


Running Options Explained



6   Installation


7   Running Options Explained


8   Managing Daemon


9   Commands Using telnet




         Steve Chu             Memcachedb: The Complete Guide   March 12, 2008   23 / 73
Running Options Explained


Deamon Options


 ‘-p <num>’ TCP port number to listen on (default: 21201)
‘-l <ip addr>’ interface to listen on, default is INDRR ANY
        ‘-d’ run as a daemon
        ‘-r’ maximize core file limit
‘-u <username>’ assume identity of <username> (only when run as root)
 ‘-c <num>’ max simultaneous connections, default is 1024
 ‘-b <num>’ max item buffer size in bytes, default is 1KB
        ‘-v’ verbose (print errors/warnings while in event loop)
       ‘-vv’ very verbose (also print client commands/reponses)
‘-P <file>’ save PID in <file>, only used with -d option



       Steve Chu             Memcachedb: The Complete Guide   March 12, 2008   24 / 73
Running Options Explained


BekerleyDB Options


 ‘-m <num>’ in-memmory cache size of BerkeleyDB in megabytes, default
            is 64MB
‘-f <file>’ filename of database, default is
            /data1/memcachedb/default.db
 ‘-H <dir>’ env home of database, default is /data1/memcachedb
 ‘-L <num>’ log buffer size in kbytes, default is 32KB
 ‘-C <num>’ do checkpoint every XX seconds, 0 for disable, default is 60s
 ‘-D <num>’ do deadlock detecting every XXX millisecond, 0 for disable,
            default is 100ms
        ‘-N’ enable DB TXN NOSYNC to gain big performance
             improved, default is off


       Steve Chu             Memcachedb: The Complete Guide   March 12, 2008   25 / 73
Managing Daemon


Managing Daemon



6   Installation


7   Running Options Explained


8   Managing Daemon


9   Commands Using telnet




         Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   26 / 73
Managing Daemon


Before start..


Please take care this two options, a lot of mistakes have been made due to
this:
 ‘-b <num>’ max item buffer size in bytes, default is 1KB. ’-b option’
            determines MAX size of item can be stored. Just choose a
            suitable size. Following this formula:
            item buffer size(-b) = key size + data size + 37(Max)
        ‘-N’ enable DB TXN NOSYNC to gain big performance
             improved, default is off. By using ’-N’ option, ’ACID’ in
             transaction will lose ’D’. The data in transaction log buffer
             may be gone when the machine loses power(So we need
             replication).



       Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   27 / 73
Managing Daemon


How to start a deamon?




Non-replication:

memcachedb -p21201 -d -r -u root -f 21201.db -H /data1/demo
-N -P /data1/logs/21201.pid




       Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   28 / 73
Managing Daemon


How to stop a deamon?




Just kill it:
kill ‘cat /data1/logs/21201.pid‘

When the deamon recives a signal of SIGTERM/SIGQUIT/SIGINT, it will
do a checkpoint instantly and close the db and env resource normally. So
don’t be afraid, just kill it!




         Steve Chu        Memcachedb: The Complete Guide   March 12, 2008   29 / 73
Commands Using telnet


Commands Using telnet



6   Installation


7   Running Options Explained


8   Managing Daemon


9   Commands Using telnet




         Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   30 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4
1234




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4
1234
STORED




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4
1234
STORED
get test




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4
1234
STORED
get test
VALUE test 0 4
1234
END




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4
1234
STORED
get test
VALUE test 0 4
1234
END
delete test



      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


set/get/delete a Item


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
set test 0 0 4
1234
STORED
get test
VALUE test 0 4
1234
END
delete test
DELETED


      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   31 / 73
Commands Using telnet


stats

~ % telnet 127.0.0.1 21201




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   32 / 73
Commands Using telnet


stats

~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   32 / 73
Commands Using telnet


stats

~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
stats




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   32 / 73
Commands Using telnet


stats

~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
stats
STAT pid 18547
STAT uptime 41385
STAT rusage user 0.084005
STAT rusage system 0.804050
STAT curr connections 1
...
STAT bytes read 5347
STAT bytes written 122797
STAT threads 1
END
        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   32 / 73
Commands Using telnet


stats bdb


~ % telnet 127.0.0.1 21201




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   33 / 73
Commands Using telnet


stats bdb


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   33 / 73
Commands Using telnet


stats bdb


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
stats bdb




      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   33 / 73
Commands Using telnet


stats bdb


~ % telnet 127.0.0.1 21201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
stats bdb
STAT cache size 67108864
STAT txn lg bsize 32768
STAT txn nosync 1
STAT dldetect val 100000
STAT chkpoint val 60
END



      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   33 / 73
Part III

                              Internals


10   The Big Picture




         Steve Chu     Memcachedb: The Complete Guide   March 12, 2008   34 / 73
The Big Picture


The Big Picture




10   The Big Picture




         Steve Chu     Memcachedb: The Complete Guide   March 12, 2008   35 / 73
The Big Picture


Nonthread Version




     Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   36 / 73
The Big Picture


Thread Version




      Steve Chu   Memcachedb: The Complete Guide   March 12, 2008   37 / 73
The Big Picture


The Backend: BerkeleyDB

http://www.oracle.com/technology/products/berkeley-db/db/
index.html




      Steve Chu      Memcachedb: The Complete Guide   March 12, 2008   38 / 73
Part IV

                                Replication

11   Overview


12   Replication Patterns


13   Replication Howto




         Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   39 / 73
Overview


Overview




11   Overview


12   Replication Patterns


13   Replication Howto




         Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   40 / 73
Overview


Replication Model

Consistency is an important issue that every engineer must resolve when
designing a distributed system. The BerkeleyDB replication framework
resolves this by following a single master, multiple replica model.




       Steve Chu         Memcachedb: The Complete Guide   March 12, 2008   41 / 73
Overview


Replication Benefits

   Improve application reliability
   By spreading your data across multiple machines, you can ensure that
   your application’s data continues to be available even in the event of
   a hardware failure on any given machine in the replication group.
   Improve read performance
   By using replication you can spread data reads across multiple
   machines on your network.
   Improve transactional commit performance and data durability
   guarantee
   Replication allows you to avoid this disk I/O and still maintain a
   degree of durability by committing to the network. So we can
   use ’-N’ option for better performance but never lose durability(The
   D of ACID).


      Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   42 / 73
Replication Patterns


Replication Patterns




11   Overview


12   Replication Patterns


13   Replication Howto




         Steve Chu              Memcachedb: The Complete Guide   March 12, 2008   43 / 73
Replication Patterns


ACK Policy(1/2)

Messaging is the key facility that implements replication. How to process a
message influences your data reliability and performance. Now we go deep
into these policies:
‘DB REPMGR ACKS ALL’ The master should wait until all replication clients
            have acknowledged each permanent replication message.
‘DB REPMGR ACKS ALL PEERS’ The master should wait until all electable
            peers have acknowledged each permanent replication
            message (where ”electable peer” means a client capable of
            being subsequently elected master of the replication group).
‘DB REPMGR ACKS NONE’ The master should not wait for any client
            replication message acknowledgments.
‘DB REPMGR ACKS ONE’ The master should wait until at least one client
            site has acknowledged each permanent replication message.

       Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   44 / 73
Replication Patterns


ACK Policy(2/2)

‘DB REPMGR ACKS ONE PEER’ The master should wait until at least one
            electable peer has acknowledged each permanent replication
            message (where ”electable peer” means a client capable of
            being subsequently elected master of the replication group).
‘DB REPMGR ACKS QUORUM’ The master should wait until it has received
            acknowledgements from the minimum number of electable
            peers sufficient to ensure that the effect of the permanent
            record remains durable if an election is held (where
            ”electable peer” means a client capable of being
            subsequently elected master of the replication group). This
            is the default acknowledgement policy.
Note: The current implementation requires all sites in a replication group
configure the same acknowledgement policy.

       Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   45 / 73
Replication Patterns


Performance vs Data Reliability



  ‘ACK ALL’ More data reliability, but poor performance due to the
            blocked thread waiting for ack(the thread can not continue
            to write).
 ‘ACK NONE’ Better performance, but may cause reliable problem because
            of the unstable network between a master and replica(the
            data of repllica may be out-of-date).
So we must do a tradeoff:
Let Replica who in the same LAN with Master do the reliable thing, and let
the site far from the Master recieves replication message with ACK NONE.




       Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   46 / 73
Replication Patterns


How ACK NONE Replicas catch up with Master



   Restart your replica daemon, and force a replica sync with master.
   Not that flexible..
   Set a minor number of missing log records that a client waits before
   requesting retransmission.
   A replication client checks the log sequence number of each incoming
   log record, and can detect gaps in the sequence. If some log records
   are lost due to network problems, then when later log records arrive
   the client detects the missing records. The client waits for some
   number of out-of-sequence log records before issuing the request for
   retransmission.




      Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   47 / 73
Replication Patterns


Replication over LAN




      Steve Chu        Memcachedb: The Complete Guide   March 12, 2008   48 / 73
Replication Patterns


Replication over WAN




     Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   49 / 73
Replication Howto


Replication Howto




11   Overview


12   Replication Patterns


13   Replication Howto




         Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   50 / 73
Replication Howto


Design your deployment
Your deployment based the replication pattern you choose, and try to
think about these:
    Network QoS
    How large your dataset
    Proportion of read/write
    Throughput of read/write
    The replication group size
    ...
Find out:
    How many sites? Over LAN or WAN?
    Which ACK policy to take?
    Which is electable or not?
    ...
          Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   51 / 73
Replication Howto


Prepare your dataset

If your initial dataset is empty, then go to next step.. otherwise follow this:

     Initialize your data into a Master site.
     Do a hotbackup of your master environment and compress all data
     into a package.
     Drag the package to where replica locates, decompress, and go to
     next step.




        Steve Chu           Memcachedb: The Complete Guide    March 12, 2008   52 / 73
Replication Howto


Start and Configure the Daemon(1/4)

Replication Options:
         ‘-R’ identifies the host and port used by this site (required).
         ‘-O’ identifies another site participating in this replication group
     ‘-M/-S’ start as a master or slave
Start as a master:
memcachedb -p21201 -d -r -u root -f 21201.db -H /data1/demo
-N -P /data1/logs/21201.pid -R 127.0.0.1:31201 -M

Start as a slave:
memcachedb -p21202 -d -r -u root -f 21202.db -H /data1/demo
-N -P /data1/logs/21202.pid -R 127.0.0.1:31202 -O
127.0.0.1:31201 -S


        Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   53 / 73
Replication Howto


Start and Configure the Daemon(2/4)
Besides running replication options, there are private commands available
to configure the current site:
‘stats rep’ shows the status of Replication.
‘rep set priority’ sets the priority of a site for electing in replication.
‘rep set request’ sets the minimum and maximum number of missing
             log records that a client waits before requesting
             retransmission.
‘rep set bulk’ Enable bulk transfer or not in replication.
‘rep set ack timeout’ sets ACK timeout value of the replication .
‘rep set ack policy’ sets ACK policy of the replication.
                          DB REPMGR ACKS ALL                   1
                          DB REPMGR ACKS ALL PEERS 2
                          DB REPMGR ACKS NONE                  3
                          DB REPMGR ACKS ONE                   4
                          DB REPMGR ACKS ONE PEER 5
                          DB REPMGR ACKS QUORUM                6
        Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   54 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0
rep set ack policy 5




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0
rep set ack policy 5
5




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0
rep set ack policy 5
5
rep set ack timeout 50000




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0
rep set ack policy 5
5
rep set ack timeout 50000
50000




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0
rep set ack policy 5
5
rep set ack timeout 50000
50000
rep set request 2 4




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(3/4)


~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
rep set priority 0
0
rep set ack policy 5
5
rep set ack timeout 50000
50000
rep set request 2 4
2/4


      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   55 / 73
Replication Howto


Start and Configure the Daemon(4/4)

~ % telnet 127.0.0.1 21202




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   56 / 73
Replication Howto


Start and Configure the Daemon(4/4)

~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   56 / 73
Replication Howto


Start and Configure the Daemon(4/4)

~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
stats rep




      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   56 / 73
Replication Howto


Start and Configure the Daemon(4/4)

~ % telnet 127.0.0.1 21202
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ’^]’.
stats rep
STAT rep whoismaster 127.0.0.1:31201
STAT rep localhp 127.0.0.1:31202
STAT rep ismaster REP FALSE
STAT rep priority 0
STAT rep ack policy 5
STAT rep ack timeout 50000
STAT rep bulk 1
STAT rep request 2/4
STAT rep next lsn 25/6752622
END
      Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   56 / 73
Part V

                     Managing and Monitoring


14   Managing DB Files



15   Monitoring




         Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   57 / 73
Managing DB Files


Managing DB Files




14   Managing DB Files



15   Monitoring




         Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   58 / 73
Managing DB Files


Home Environment


    In order to transaction protect your database operations, you
    must use an environment.
    An environment, represents an encapsulation of one or more
    databases and any associated log and region files.
There are three types of files in a environment:
‘Database files’ the exact files that store your data.
‘Log files’ all your transcations you commit first come into logs.
‘Region files’ files that back the share memory region using mmap().




       Steve Chu            Memcachedb: The Complete Guide   March 12, 2008   59 / 73
Managing DB Files


Checkpoint(1/2)


    When databases are modified (that is, a transaction is committed),
    the modifications are recorded in DB’s logs
    But the increased logs make recovery take too long time.
    Log files also have more unnecessary data than database file.
    Log files make catastrophic recovery possible.
So here comes Checkpoint:




       Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   60 / 73
Managing DB Files


Checkpoint(2/2)



The checkpoint:
    Flushes dirty pages from the in-memory cache.
    Writes a checkpoint record.
    Flushes the log.
    Writes a list of open databases.
How to do checkpoint in Memcachedb:
    Run checkpoint periodically with ’-C’ option
    The private command: ’db checkpoint’




       Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   61 / 73
Managing DB Files


Backup Procedures




Hot Backup

/usr/local/BerkeleyDB.4.6/bin/db hotbackup [-c] -h home -b
backup dir

DB files has a high compression ratio, and use gzip and tar to archive.




       Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   62 / 73
Managing DB Files


Recovery Procedures

   Normal Recovery
   Put database files and log files since the last checkpoint(or a
   hotbackup copy) into a empty home environemt, Start the deamon on
   this environment, the deamon will do recovery automatically. Also it
   can be done by using standalone utility ’db recover’:

/usr/local/BerkeleyDB.4.6/bin/db recover -f -h home

   Catastrophic Recovery
   Put all your database files and all log files(since environment created)
   into a empty home environment, Use standalone utility ’db recover’
   with option ’-c’:

/usr/local/BerkeleyDB.4.6/bin/db recover -cf -h home


      Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   63 / 73
Managing DB Files


Removing Log Files


Log Files in which transactions have been checkpointed into database file
can be removed directly or archived to offline storage devices. You can
remove this log files by
    using private command: ’db archive’
    using standalone utility ’db archive’ with option ’-d’:

/usr/local/BerkeleyDB.4.6/bin/db archive -d -h home

Warning: log file removal is likely to make catastrophic recovery
impossible. If the data is very important(I mean if the data is lost, you are
over.), you’d better archive them to offline storage devices instead of
removal.



        Steve Chu           Memcachedb: The Complete Guide    March 12, 2008   64 / 73
Monitoring


Monitoring




14   Managing DB Files



15   Monitoring




         Steve Chu       Memcachedb: The Complete Guide   March 12, 2008   65 / 73
Monitoring


Overview




There are four ways now available for monitoring Memcachedb:
    the raw ’stats’ commands: ’stats’, ’stats bdb’, ’stats rep’
    the standalone utility ’db stat’
    the coming along monitoring tool ’tools/mdbtop.py’
    writing your own monitoring tool using ’tools/memcache.py’




       Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   66 / 73
Monitoring


’stats’ command



There are a few of ’stats’ commands in Memcachedb:
    ‘stats’ shows the status of current deamon.
‘stats bdb’ shows the status of BerkeleyDB.
‘stats rep’ shows the status of Replication.
Just telnet in, and use them. Some of Memcached Client APIs support
’stats’ command, but some not. If you find no one can do it, have a try of
patched ’memcache.py’ in ’tools/’ of distribution.




       Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   67 / 73
Monitoring


db stat

BerkeleyDB distribution has a standalone utility ’db stat’ that can help us
to get statistics for Berkeley DB environments.
         ‘-c’ Display locking subsystem statistics
         ‘-l’ Display logging subsystem statistics
         ‘-m’ Display cache statistics
         ‘-r’ Display replication statistics
         ‘-t’ Display transaction subsystem statistics
              ...
See ’docs/utility/db stat.html’ in BerkeleyDB distribution for more info.
Warning: ’-d’ option which displays database statistics for the specified file
will be very expensive(that requires traversing the database), do not use it
on a high traffic Memcachedb daemon.


        Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   68 / 73
Monitoring


mdbtop.py

’mdbtop.py’ is a monitoring tool coming along with distribution. It is built
on the patched ’memcache.py’ Python API.

 ./mdbtop.py <mdbtop.cfg> [rep]

’mdbtop.cfg’ is the configure file that mdbtop.py uses:
mdbtop.cfg

[ Server ]
server1 = 127.0.0.1:21201
server2 = 127.0.0.1:21202
[ View ]
interval = 1

[rep] option is for only replication syncing monitoring.
        Steve Chu           Memcachedb: The Complete Guide   March 12, 2008   69 / 73
Monitoring


memcache.py
The patched ’memcache.py’ now has all private commands supported and
you can write your own monitoring tools depending on these APIs:
memcache.py

import memcache
mc = memcache . C l i e n t ( [ ’ 1 2 7 . 0 . 0 . 1 : 2 1 2 0 2 ’ ] , debug =0)
mc . d b a r c h i v e ( )
mc . d b c h e c k p o i n t ( )
mc . r e p i s m a s t e r ( )
mc . r e p w h o i s m a s t e r ( )
mc . r e p s e t p r i o r i t y ( 1 0 0 )
mc . r e p s e t a c k p o l i c y ( 5 )
mc . r e p s e t a c k t i m e o u t ( 2 0 0 0 0 )
mc . r e p s e t r e q u e s t ( 4 , 1 6 )
mc . d i s c o n n e c t a l l ( )

        Steve Chu            Memcachedb: The Complete Guide      March 12, 2008   70 / 73
Part VI

                  The End




Steve Chu   Memcachedb: The Complete Guide   March 12, 2008   71 / 73
Project info



Homepage: http://memcachedb.org
Mailing list: http://groups.google.com/group/memcachedb
    To subscribe to maillist, send email to
    memcachedb-subscribe@googlegroups.com
    To post to maillist, send email to memcachedb@googlegroups.com
    To unsubscribe from maillist, send email to
    memcachedb-unsubscribe@googlegroups.com
Please report your bugs and issues to the Maillist.




        Steve Chu          Memcachedb: The Complete Guide   March 12, 2008   72 / 73
Q/A




                      Any question?




      Steve Chu   Memcachedb: The Complete Guide   March 12, 2008   73 / 73

Más contenido relacionado

La actualidad más candente

Distributed Lock Manager
Distributed Lock ManagerDistributed Lock Manager
Distributed Lock ManagerHao Chen
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group ReplicationKenny Gryp
 
Training netbackup6x2
Training netbackup6x2Training netbackup6x2
Training netbackup6x2M Shariff
 
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsQuery Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsJaime Crespo
 
What makes JBoss AS7 tick?
What makes JBoss AS7 tick?What makes JBoss AS7 tick?
What makes JBoss AS7 tick?marius_bogoevici
 
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionUnanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionMarcus Denker
 
Behind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling StorytimeBehind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling StorytimeSergeyChernyshev
 
Jug Lugano - Scale over the limits
Jug Lugano - Scale over the limitsJug Lugano - Scale over the limits
Jug Lugano - Scale over the limitsDavide Carnevali
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLReducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLKenny Gryp
 
MySQL High Availability Sprint: Launch the Pacemaker
MySQL High Availability Sprint: Launch the PacemakerMySQL High Availability Sprint: Launch the Pacemaker
MySQL High Availability Sprint: Launch the Pacemakerhastexo
 
Redis trouble shooting_eng
Redis trouble shooting_engRedis trouble shooting_eng
Redis trouble shooting_engDaeMyung Kang
 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In ActionBruce Snyder
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagJean-François Gagné
 
HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.
HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.
HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.Takatoshi Matsuo
 

La actualidad más candente (20)

Distributed Lock Manager
Distributed Lock ManagerDistributed Lock Manager
Distributed Lock Manager
 
Tools for Metaspace
Tools for MetaspaceTools for Metaspace
Tools for Metaspace
 
Redis ndc2013
Redis ndc2013Redis ndc2013
Redis ndc2013
 
NoSQL with MySQL
NoSQL with MySQLNoSQL with MySQL
NoSQL with MySQL
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
 
Training netbackup6x2
Training netbackup6x2Training netbackup6x2
Training netbackup6x2
 
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsQuery Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
 
What makes JBoss AS7 tick?
What makes JBoss AS7 tick?What makes JBoss AS7 tick?
What makes JBoss AS7 tick?
 
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionUnanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
 
Behind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling StorytimeBehind the Scenes at LiveJournal: Scaling Storytime
Behind the Scenes at LiveJournal: Scaling Storytime
 
Jug Lugano - Scale over the limits
Jug Lugano - Scale over the limitsJug Lugano - Scale over the limits
Jug Lugano - Scale over the limits
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLReducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQL
 
MySQL High Availability Sprint: Launch the Pacemaker
MySQL High Availability Sprint: Launch the PacemakerMySQL High Availability Sprint: Launch the Pacemaker
MySQL High Availability Sprint: Launch the Pacemaker
 
Redis acc
Redis accRedis acc
Redis acc
 
Redis trouble shooting_eng
Redis trouble shooting_engRedis trouble shooting_eng
Redis trouble shooting_eng
 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In Action
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lag
 
HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.
HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.
HA Clustering of PostgreSQL(replication)@2012.9.29 PG Study.
 
DTrace and Drupal
DTrace and DrupalDTrace and Drupal
DTrace and Drupal
 

Similar a Memcachedb: The Complete Guide

Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMakerKris Buytaert
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介kwatch
 
Compile ahead of time. It's fine?
Compile ahead of time. It's fine?Compile ahead of time. It's fine?
Compile ahead of time. It's fine?Dmitry Chuyko
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
 
Caching and tuning fun for high scalability @ LOAD2012
Caching and tuning fun for high scalability @ LOAD2012Caching and tuning fun for high scalability @ LOAD2012
Caching and tuning fun for high scalability @ LOAD2012Wim Godden
 
Running Stateful Apps on Kubernetes
Running Stateful Apps on KubernetesRunning Stateful Apps on Kubernetes
Running Stateful Apps on KubernetesYugabyte
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionBen Mildren
 
Ceph Day Beijing - Ceph all-flash array design based on NUMA architecture
Ceph Day Beijing - Ceph all-flash array design based on NUMA architectureCeph Day Beijing - Ceph all-flash array design based on NUMA architecture
Ceph Day Beijing - Ceph all-flash array design based on NUMA architectureCeph Community
 
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA ArchitectureCeph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA ArchitectureDanielle Womboldt
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentJean-François Gagné
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017Dave Stokes
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in descriptionPrzemyslaw Koltermann
 

Similar a Memcachedb: The Complete Guide (20)

Memcachedb Guide 1.0
Memcachedb Guide 1.0Memcachedb Guide 1.0
Memcachedb Guide 1.0
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMaker
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介
 
No sql presentation
No sql presentationNo sql presentation
No sql presentation
 
Compile ahead of time. It's fine?
Compile ahead of time. It's fine?Compile ahead of time. It's fine?
Compile ahead of time. It's fine?
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
Caching and tuning fun for high scalability @ LOAD2012
Caching and tuning fun for high scalability @ LOAD2012Caching and tuning fun for high scalability @ LOAD2012
Caching and tuning fun for high scalability @ LOAD2012
 
Running Stateful Apps on Kubernetes
Running Stateful Apps on KubernetesRunning Stateful Apps on Kubernetes
Running Stateful Apps on Kubernetes
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
 
Ceph Day Beijing - Ceph all-flash array design based on NUMA architecture
Ceph Day Beijing - Ceph all-flash array design based on NUMA architectureCeph Day Beijing - Ceph all-flash array design based on NUMA architecture
Ceph Day Beijing - Ceph all-flash array design based on NUMA architecture
 
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA ArchitectureCeph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017
 
cosbench-openstack.pdf
cosbench-openstack.pdfcosbench-openstack.pdf
cosbench-openstack.pdf
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 

Más de elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

Más de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Último

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Memcachedb: The Complete Guide

  • 1. Memcachedb: The Complete Guide Steve Chu stvchu@gmail.com ICRD-Web@Sina March 12, 2008 Steve Chu Memcachedb: The Complete Guide March 12, 2008 1 / 73
  • 2. Part I Getting Started 1 What is Memcachedb? 2 Why Memcachedb? 3 Memcachedb Features 4 Supported Commands 5 Benchmark Steve Chu Memcachedb: The Complete Guide March 12, 2008 2 / 73
  • 3. What is Memcachedb? What is Memcachedb? 1 What is Memcachedb? 2 Why Memcachedb? 3 Memcachedb Features 4 Supported Commands 5 Benchmark Steve Chu Memcachedb: The Complete Guide March 12, 2008 3 / 73
  • 4. What is Memcachedb? What is Memcachedb? ”Memcachedb is a distributed key-value storage system designed for persistent.” A complete memcached, but *NOT* a cache solution Memcached is good enough for cache. *NO* expiration For memcache protocol compatible, still reserved, but we do nothing. Totally for persistent Transaction, replication, we do our best to achieve persistent. Steve Chu Memcachedb: The Complete Guide March 12, 2008 4 / 73
  • 5. Why Memcachedb? Why Memcachedb? 1 What is Memcachedb? 2 Why Memcachedb? 3 Memcachedb Features 4 Supported Commands 5 Benchmark Steve Chu Memcachedb: The Complete Guide March 12, 2008 5 / 73
  • 6. Why Memcachedb? Why Memcachedb?(1/2) We have MySQL, we have PostgreSQL, we have a lot of RDBMSs, but why we need Memcachedb? RDBMS is slow All they have a complicated SQL engine on top of storage. Our data requires to be stored and retrieved damnable fast. Not concurrent well When thousands of clients, millions of requests happens... But the data we wanna store is very small size! Cost is high if we use RDBMS. Steve Chu Memcachedb: The Complete Guide March 12, 2008 6 / 73
  • 7. Why Memcachedb? Why Memcachedb?(2/2) Many critical infrastructure services need fast, reliable data storage and retrieval, but do not need the flexibility of dynamic SQL queries. Index, Counter, Flags Identity Management(Account, Profile, User config info, Score) Messaging Personal domain name meta data of distributed system Other non-relatonal data ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 7 / 73
  • 8. Memcachedb Features Memcachedb Features 1 What is Memcachedb? 2 Why Memcachedb? 3 Memcachedb Features 4 Supported Commands 5 Benchmark Steve Chu Memcachedb: The Complete Guide March 12, 2008 8 / 73
  • 9. Memcachedb Features Memcachedb Features High performance read/write for a key-value based object Rapid set/get for a key-value based object, not relational. Benchmark will tell you the true later. High reliable persistent storage with transaction Transaction is used to make your data more reliable. High availability data storage with replication Replication rocks! Achieve your HA, spread your read, make your transaction durable! Memcache protocol compatibility Lots of Memcached Client APIs can be used for Memcachedb, almost in any language, Perl, C, Python, Java, ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 9 / 73
  • 10. Supported Commands Supported Commands 1 What is Memcachedb? 2 Why Memcachedb? 3 Memcachedb Features 4 Supported Commands 5 Benchmark Steve Chu Memcachedb: The Complete Guide March 12, 2008 10 / 73
  • 11. Supported Commands Standard Memcache Commands ‘get’ Retrieval of one or multiple items ‘set’ ”Store this data” ‘add’ ”Store this data, but only if the server *doesn’t* already hold data for this key” ‘replace’ ”Store this data, but only if the server *does* already hold data for this key” ‘delete’ deletes one item based a key ‘incr/decr’ Increment or decrement a numeric value. It’s atomic! ‘stats’ shows the status of current deamon. ’stats’, ’stats malloc’, ’stats maps’ Steve Chu Memcachedb: The Complete Guide March 12, 2008 11 / 73
  • 12. Supported Commands Private Commands ‘db checkpoint’ does a checkpoint manuanlly. ‘db archive’ removes log files that are no longer needed. ‘stats bdb’ shows the status of BerkeleyDB. ‘rep ismaster’ shows whether the site is a master. ‘rep whoismaster’ shows which site is a master. ‘rep set priority’ sets the priority of a site for electing in replication. ‘rep set ack policy’ sets ACK policy of the replication. ‘rep set ack timeout’ sets ACK timeout value of the replication . ‘rep set bulk’ Enable bulk transfer or not in replication. ‘rep set request’ sets the minimum and maximum number of missing log records that a client waits before requesting retransmission. ‘stats rep’ shows the status of Replication. Steve Chu Memcachedb: The Complete Guide March 12, 2008 12 / 73
  • 13. Benchmark Benchmark 1 What is Memcachedb? 2 Why Memcachedb? 3 Memcachedb Features 4 Supported Commands 5 Benchmark Steve Chu Memcachedb: The Complete Guide March 12, 2008 13 / 73
  • 14. Benchmark Environment Box: Dell 2950III OS: Linux CentOS 5 Version: memcachedb-1.0.0-beta Client API: libmemcached Steve Chu Memcachedb: The Complete Guide March 12, 2008 14 / 73
  • 15. Benchmark Non-thread Version key: 16 value: 100B, 8 concurrents, every process does 2,000,000 set/get memcachedb -d -r -u root -H /data1/mdbtest/ -N -v Write No. 1 2 3 4 5 6 7 8 avg. Cost(s) 807 835 840 853 859 857 865 868 848 2000000 * 8 / 848 = 18868 w/s Read No. 1 2 3 4 5 6 7 8 avg. Cost(s) 354 354 359 358 357 364 363 365 360 2000000 * 8 / 360 = 44444 r/s Steve Chu Memcachedb: The Complete Guide March 12, 2008 15 / 73
  • 16. Benchmark Thread Version key: 16 value: 100B, 8 concurrents, every process does 2,000,000 set/get memcachedb -d -r -u root -H /data1/mdbtest/ -N -t 4 -v Write No. 1 2 3 4 5 6 7 8 avg. Cost(s) 663 669 680 680 684 683 687 686 679 2000000 * 8 / 679 = 23564 w/s Read No. 1 2 3 4 5 6 7 8 avg. Cost(s) 245 249 250 248 248 249 251 250 249 2000000 * 8 / 249 = 64257 r/s Steve Chu Memcachedb: The Complete Guide March 12, 2008 16 / 73
  • 17. Part II MDB In Action 6 Installation 7 Running Options Explained 8 Managing Daemon 9 Commands Using telnet Steve Chu Memcachedb: The Complete Guide March 12, 2008 17 / 73
  • 18. Installation Installation 6 Installation 7 Running Options Explained 8 Managing Daemon 9 Commands Using telnet Steve Chu Memcachedb: The Complete Guide March 12, 2008 18 / 73
  • 19. Installation Dependencies libevent An event notification library that provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Now it supports /dev/poll, kqueue(2), event ports, select(2), poll(2) and epoll(4). http://www.monkey.org/~provos/libevent/ BerkeleyDB The industry-leading open source, embeddable database engine that provides developers with fast, reliable, local persistence with zero administration. http://www.oracle.com/technology/products/ berkeley-db/db/index.html Steve Chu Memcachedb: The Complete Guide March 12, 2008 19 / 73
  • 20. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 21. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz ~ % cd libevent-1.3e Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 22. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz ~ % cd libevent-1.3e ~/libevent-1.3e % ./configure ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 23. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz ~ % cd libevent-1.3e ~/libevent-1.3e % ./configure ... ~/libevent-1.3e % make ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 24. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz ~ % cd libevent-1.3e ~/libevent-1.3e % ./configure ... ~/libevent-1.3e % make ... ~/libevent-1.3e % su Password: Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 25. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz ~ % cd libevent-1.3e ~/libevent-1.3e % ./configure ... ~/libevent-1.3e % make ... ~/libevent-1.3e % su Password: /home/sc/libevent-1.3e # make install ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 26. Installation Installing libevent ~ % tar zvxf libevent-1.3e.tar.gz ~ % cd libevent-1.3e ~/libevent-1.3e % ./configure ... ~/libevent-1.3e % make ... ~/libevent-1.3e % su Password: /home/sc/libevent-1.3e # make install ... /home/sc/libevent-1.3e # exit Steve Chu Memcachedb: The Complete Guide March 12, 2008 20 / 73
  • 27. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 28. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 29. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 ~ % cd build unix Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 30. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 ~ % cd build unix ~/db-4.6.21/build unix % ../dist/configure ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 31. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 ~ % cd build unix ~/db-4.6.21/build unix % ../dist/configure ... ~/db-4.6.21/build unix % make ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 32. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 ~ % cd build unix ~/db-4.6.21/build unix % ../dist/configure ... ~/db-4.6.21/build unix % make ... ~/db-4.6.21/build unix % su Password: Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 33. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 ~ % cd build unix ~/db-4.6.21/build unix % ../dist/configure ... ~/db-4.6.21/build unix % make ... ~/db-4.6.21/build unix % su Password: /home/sc/db-4.6.21/build unix # make install ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 34. Installation Installing BerkeleyDB ~ % tar zvxf db-4.6.21.tar.gz ~ % cd db-4.6.21 ~ % cd build unix ~/db-4.6.21/build unix % ../dist/configure ... ~/db-4.6.21/build unix % make ... ~/db-4.6.21/build unix % su Password: /home/sc/db-4.6.21/build unix # make install ... /home/sc/db-4.6.21/build unix # exit Steve Chu Memcachedb: The Complete Guide March 12, 2008 21 / 73
  • 35. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 36. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz ~ % cd memcachedb-1.0.3-beta Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 37. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz ~ % cd memcachedb-1.0.3-beta ~/memcachedb-1.0.3-beta % ./configure #--enable-threads if you wanna thread version ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 38. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz ~ % cd memcachedb-1.0.3-beta ~/memcachedb-1.0.3-beta % ./configure #--enable-threads if you wanna thread version ... ~/memcachedb-1.0.3-beta % make ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 39. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz ~ % cd memcachedb-1.0.3-beta ~/memcachedb-1.0.3-beta % ./configure #--enable-threads if you wanna thread version ... ~/memcachedb-1.0.3-beta % make ... ~/memcachedb-1.0.3-beta % su Password: Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 40. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz ~ % cd memcachedb-1.0.3-beta ~/memcachedb-1.0.3-beta % ./configure #--enable-threads if you wanna thread version ... ~/memcachedb-1.0.3-beta % make ... ~/memcachedb-1.0.3-beta % su Password: /home/sc/memcachedb-1.0.3-beta # make install ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 41. Installation Installing Memcachedb ~ % tar zvxf memcachedb-1.0.3-beta.tar.gz ~ % cd memcachedb-1.0.3-beta ~/memcachedb-1.0.3-beta % ./configure #--enable-threads if you wanna thread version ... ~/memcachedb-1.0.3-beta % make ... ~/memcachedb-1.0.3-beta % su Password: /home/sc/memcachedb-1.0.3-beta # make install ... /home/sc/memcachedb-1.0.3-beta # exit Steve Chu Memcachedb: The Complete Guide March 12, 2008 22 / 73
  • 42. Running Options Explained Running Options Explained 6 Installation 7 Running Options Explained 8 Managing Daemon 9 Commands Using telnet Steve Chu Memcachedb: The Complete Guide March 12, 2008 23 / 73
  • 43. Running Options Explained Deamon Options ‘-p <num>’ TCP port number to listen on (default: 21201) ‘-l <ip addr>’ interface to listen on, default is INDRR ANY ‘-d’ run as a daemon ‘-r’ maximize core file limit ‘-u <username>’ assume identity of <username> (only when run as root) ‘-c <num>’ max simultaneous connections, default is 1024 ‘-b <num>’ max item buffer size in bytes, default is 1KB ‘-v’ verbose (print errors/warnings while in event loop) ‘-vv’ very verbose (also print client commands/reponses) ‘-P <file>’ save PID in <file>, only used with -d option Steve Chu Memcachedb: The Complete Guide March 12, 2008 24 / 73
  • 44. Running Options Explained BekerleyDB Options ‘-m <num>’ in-memmory cache size of BerkeleyDB in megabytes, default is 64MB ‘-f <file>’ filename of database, default is /data1/memcachedb/default.db ‘-H <dir>’ env home of database, default is /data1/memcachedb ‘-L <num>’ log buffer size in kbytes, default is 32KB ‘-C <num>’ do checkpoint every XX seconds, 0 for disable, default is 60s ‘-D <num>’ do deadlock detecting every XXX millisecond, 0 for disable, default is 100ms ‘-N’ enable DB TXN NOSYNC to gain big performance improved, default is off Steve Chu Memcachedb: The Complete Guide March 12, 2008 25 / 73
  • 45. Managing Daemon Managing Daemon 6 Installation 7 Running Options Explained 8 Managing Daemon 9 Commands Using telnet Steve Chu Memcachedb: The Complete Guide March 12, 2008 26 / 73
  • 46. Managing Daemon Before start.. Please take care this two options, a lot of mistakes have been made due to this: ‘-b <num>’ max item buffer size in bytes, default is 1KB. ’-b option’ determines MAX size of item can be stored. Just choose a suitable size. Following this formula: item buffer size(-b) = key size + data size + 37(Max) ‘-N’ enable DB TXN NOSYNC to gain big performance improved, default is off. By using ’-N’ option, ’ACID’ in transaction will lose ’D’. The data in transaction log buffer may be gone when the machine loses power(So we need replication). Steve Chu Memcachedb: The Complete Guide March 12, 2008 27 / 73
  • 47. Managing Daemon How to start a deamon? Non-replication: memcachedb -p21201 -d -r -u root -f 21201.db -H /data1/demo -N -P /data1/logs/21201.pid Steve Chu Memcachedb: The Complete Guide March 12, 2008 28 / 73
  • 48. Managing Daemon How to stop a deamon? Just kill it: kill ‘cat /data1/logs/21201.pid‘ When the deamon recives a signal of SIGTERM/SIGQUIT/SIGINT, it will do a checkpoint instantly and close the db and env resource normally. So don’t be afraid, just kill it! Steve Chu Memcachedb: The Complete Guide March 12, 2008 29 / 73
  • 49. Commands Using telnet Commands Using telnet 6 Installation 7 Running Options Explained 8 Managing Daemon 9 Commands Using telnet Steve Chu Memcachedb: The Complete Guide March 12, 2008 30 / 73
  • 50. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 51. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 52. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 53. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 1234 Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 54. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 1234 STORED Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 55. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 1234 STORED get test Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 56. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 1234 STORED get test VALUE test 0 4 1234 END Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 57. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 1234 STORED get test VALUE test 0 4 1234 END delete test Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 58. Commands Using telnet set/get/delete a Item ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. set test 0 0 4 1234 STORED get test VALUE test 0 4 1234 END delete test DELETED Steve Chu Memcachedb: The Complete Guide March 12, 2008 31 / 73
  • 59. Commands Using telnet stats ~ % telnet 127.0.0.1 21201 Steve Chu Memcachedb: The Complete Guide March 12, 2008 32 / 73
  • 60. Commands Using telnet stats ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. Steve Chu Memcachedb: The Complete Guide March 12, 2008 32 / 73
  • 61. Commands Using telnet stats ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. stats Steve Chu Memcachedb: The Complete Guide March 12, 2008 32 / 73
  • 62. Commands Using telnet stats ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. stats STAT pid 18547 STAT uptime 41385 STAT rusage user 0.084005 STAT rusage system 0.804050 STAT curr connections 1 ... STAT bytes read 5347 STAT bytes written 122797 STAT threads 1 END Steve Chu Memcachedb: The Complete Guide March 12, 2008 32 / 73
  • 63. Commands Using telnet stats bdb ~ % telnet 127.0.0.1 21201 Steve Chu Memcachedb: The Complete Guide March 12, 2008 33 / 73
  • 64. Commands Using telnet stats bdb ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. Steve Chu Memcachedb: The Complete Guide March 12, 2008 33 / 73
  • 65. Commands Using telnet stats bdb ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. stats bdb Steve Chu Memcachedb: The Complete Guide March 12, 2008 33 / 73
  • 66. Commands Using telnet stats bdb ~ % telnet 127.0.0.1 21201 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. stats bdb STAT cache size 67108864 STAT txn lg bsize 32768 STAT txn nosync 1 STAT dldetect val 100000 STAT chkpoint val 60 END Steve Chu Memcachedb: The Complete Guide March 12, 2008 33 / 73
  • 67. Part III Internals 10 The Big Picture Steve Chu Memcachedb: The Complete Guide March 12, 2008 34 / 73
  • 68. The Big Picture The Big Picture 10 The Big Picture Steve Chu Memcachedb: The Complete Guide March 12, 2008 35 / 73
  • 69. The Big Picture Nonthread Version Steve Chu Memcachedb: The Complete Guide March 12, 2008 36 / 73
  • 70. The Big Picture Thread Version Steve Chu Memcachedb: The Complete Guide March 12, 2008 37 / 73
  • 71. The Big Picture The Backend: BerkeleyDB http://www.oracle.com/technology/products/berkeley-db/db/ index.html Steve Chu Memcachedb: The Complete Guide March 12, 2008 38 / 73
  • 72. Part IV Replication 11 Overview 12 Replication Patterns 13 Replication Howto Steve Chu Memcachedb: The Complete Guide March 12, 2008 39 / 73
  • 73. Overview Overview 11 Overview 12 Replication Patterns 13 Replication Howto Steve Chu Memcachedb: The Complete Guide March 12, 2008 40 / 73
  • 74. Overview Replication Model Consistency is an important issue that every engineer must resolve when designing a distributed system. The BerkeleyDB replication framework resolves this by following a single master, multiple replica model. Steve Chu Memcachedb: The Complete Guide March 12, 2008 41 / 73
  • 75. Overview Replication Benefits Improve application reliability By spreading your data across multiple machines, you can ensure that your application’s data continues to be available even in the event of a hardware failure on any given machine in the replication group. Improve read performance By using replication you can spread data reads across multiple machines on your network. Improve transactional commit performance and data durability guarantee Replication allows you to avoid this disk I/O and still maintain a degree of durability by committing to the network. So we can use ’-N’ option for better performance but never lose durability(The D of ACID). Steve Chu Memcachedb: The Complete Guide March 12, 2008 42 / 73
  • 76. Replication Patterns Replication Patterns 11 Overview 12 Replication Patterns 13 Replication Howto Steve Chu Memcachedb: The Complete Guide March 12, 2008 43 / 73
  • 77. Replication Patterns ACK Policy(1/2) Messaging is the key facility that implements replication. How to process a message influences your data reliability and performance. Now we go deep into these policies: ‘DB REPMGR ACKS ALL’ The master should wait until all replication clients have acknowledged each permanent replication message. ‘DB REPMGR ACKS ALL PEERS’ The master should wait until all electable peers have acknowledged each permanent replication message (where ”electable peer” means a client capable of being subsequently elected master of the replication group). ‘DB REPMGR ACKS NONE’ The master should not wait for any client replication message acknowledgments. ‘DB REPMGR ACKS ONE’ The master should wait until at least one client site has acknowledged each permanent replication message. Steve Chu Memcachedb: The Complete Guide March 12, 2008 44 / 73
  • 78. Replication Patterns ACK Policy(2/2) ‘DB REPMGR ACKS ONE PEER’ The master should wait until at least one electable peer has acknowledged each permanent replication message (where ”electable peer” means a client capable of being subsequently elected master of the replication group). ‘DB REPMGR ACKS QUORUM’ The master should wait until it has received acknowledgements from the minimum number of electable peers sufficient to ensure that the effect of the permanent record remains durable if an election is held (where ”electable peer” means a client capable of being subsequently elected master of the replication group). This is the default acknowledgement policy. Note: The current implementation requires all sites in a replication group configure the same acknowledgement policy. Steve Chu Memcachedb: The Complete Guide March 12, 2008 45 / 73
  • 79. Replication Patterns Performance vs Data Reliability ‘ACK ALL’ More data reliability, but poor performance due to the blocked thread waiting for ack(the thread can not continue to write). ‘ACK NONE’ Better performance, but may cause reliable problem because of the unstable network between a master and replica(the data of repllica may be out-of-date). So we must do a tradeoff: Let Replica who in the same LAN with Master do the reliable thing, and let the site far from the Master recieves replication message with ACK NONE. Steve Chu Memcachedb: The Complete Guide March 12, 2008 46 / 73
  • 80. Replication Patterns How ACK NONE Replicas catch up with Master Restart your replica daemon, and force a replica sync with master. Not that flexible.. Set a minor number of missing log records that a client waits before requesting retransmission. A replication client checks the log sequence number of each incoming log record, and can detect gaps in the sequence. If some log records are lost due to network problems, then when later log records arrive the client detects the missing records. The client waits for some number of out-of-sequence log records before issuing the request for retransmission. Steve Chu Memcachedb: The Complete Guide March 12, 2008 47 / 73
  • 81. Replication Patterns Replication over LAN Steve Chu Memcachedb: The Complete Guide March 12, 2008 48 / 73
  • 82. Replication Patterns Replication over WAN Steve Chu Memcachedb: The Complete Guide March 12, 2008 49 / 73
  • 83. Replication Howto Replication Howto 11 Overview 12 Replication Patterns 13 Replication Howto Steve Chu Memcachedb: The Complete Guide March 12, 2008 50 / 73
  • 84. Replication Howto Design your deployment Your deployment based the replication pattern you choose, and try to think about these: Network QoS How large your dataset Proportion of read/write Throughput of read/write The replication group size ... Find out: How many sites? Over LAN or WAN? Which ACK policy to take? Which is electable or not? ... Steve Chu Memcachedb: The Complete Guide March 12, 2008 51 / 73
  • 85. Replication Howto Prepare your dataset If your initial dataset is empty, then go to next step.. otherwise follow this: Initialize your data into a Master site. Do a hotbackup of your master environment and compress all data into a package. Drag the package to where replica locates, decompress, and go to next step. Steve Chu Memcachedb: The Complete Guide March 12, 2008 52 / 73
  • 86. Replication Howto Start and Configure the Daemon(1/4) Replication Options: ‘-R’ identifies the host and port used by this site (required). ‘-O’ identifies another site participating in this replication group ‘-M/-S’ start as a master or slave Start as a master: memcachedb -p21201 -d -r -u root -f 21201.db -H /data1/demo -N -P /data1/logs/21201.pid -R 127.0.0.1:31201 -M Start as a slave: memcachedb -p21202 -d -r -u root -f 21202.db -H /data1/demo -N -P /data1/logs/21202.pid -R 127.0.0.1:31202 -O 127.0.0.1:31201 -S Steve Chu Memcachedb: The Complete Guide March 12, 2008 53 / 73
  • 87. Replication Howto Start and Configure the Daemon(2/4) Besides running replication options, there are private commands available to configure the current site: ‘stats rep’ shows the status of Replication. ‘rep set priority’ sets the priority of a site for electing in replication. ‘rep set request’ sets the minimum and maximum number of missing log records that a client waits before requesting retransmission. ‘rep set bulk’ Enable bulk transfer or not in replication. ‘rep set ack timeout’ sets ACK timeout value of the replication . ‘rep set ack policy’ sets ACK policy of the replication. DB REPMGR ACKS ALL 1 DB REPMGR ACKS ALL PEERS 2 DB REPMGR ACKS NONE 3 DB REPMGR ACKS ONE 4 DB REPMGR ACKS ONE PEER 5 DB REPMGR ACKS QUORUM 6 Steve Chu Memcachedb: The Complete Guide March 12, 2008 54 / 73
  • 88. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 89. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 90. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 91. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 92. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 rep set ack policy 5 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 93. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 rep set ack policy 5 5 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 94. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 rep set ack policy 5 5 rep set ack timeout 50000 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 95. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 rep set ack policy 5 5 rep set ack timeout 50000 50000 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 96. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 rep set ack policy 5 5 rep set ack timeout 50000 50000 rep set request 2 4 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 97. Replication Howto Start and Configure the Daemon(3/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. rep set priority 0 0 rep set ack policy 5 5 rep set ack timeout 50000 50000 rep set request 2 4 2/4 Steve Chu Memcachedb: The Complete Guide March 12, 2008 55 / 73
  • 98. Replication Howto Start and Configure the Daemon(4/4) ~ % telnet 127.0.0.1 21202 Steve Chu Memcachedb: The Complete Guide March 12, 2008 56 / 73
  • 99. Replication Howto Start and Configure the Daemon(4/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. Steve Chu Memcachedb: The Complete Guide March 12, 2008 56 / 73
  • 100. Replication Howto Start and Configure the Daemon(4/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. stats rep Steve Chu Memcachedb: The Complete Guide March 12, 2008 56 / 73
  • 101. Replication Howto Start and Configure the Daemon(4/4) ~ % telnet 127.0.0.1 21202 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ’^]’. stats rep STAT rep whoismaster 127.0.0.1:31201 STAT rep localhp 127.0.0.1:31202 STAT rep ismaster REP FALSE STAT rep priority 0 STAT rep ack policy 5 STAT rep ack timeout 50000 STAT rep bulk 1 STAT rep request 2/4 STAT rep next lsn 25/6752622 END Steve Chu Memcachedb: The Complete Guide March 12, 2008 56 / 73
  • 102. Part V Managing and Monitoring 14 Managing DB Files 15 Monitoring Steve Chu Memcachedb: The Complete Guide March 12, 2008 57 / 73
  • 103. Managing DB Files Managing DB Files 14 Managing DB Files 15 Monitoring Steve Chu Memcachedb: The Complete Guide March 12, 2008 58 / 73
  • 104. Managing DB Files Home Environment In order to transaction protect your database operations, you must use an environment. An environment, represents an encapsulation of one or more databases and any associated log and region files. There are three types of files in a environment: ‘Database files’ the exact files that store your data. ‘Log files’ all your transcations you commit first come into logs. ‘Region files’ files that back the share memory region using mmap(). Steve Chu Memcachedb: The Complete Guide March 12, 2008 59 / 73
  • 105. Managing DB Files Checkpoint(1/2) When databases are modified (that is, a transaction is committed), the modifications are recorded in DB’s logs But the increased logs make recovery take too long time. Log files also have more unnecessary data than database file. Log files make catastrophic recovery possible. So here comes Checkpoint: Steve Chu Memcachedb: The Complete Guide March 12, 2008 60 / 73
  • 106. Managing DB Files Checkpoint(2/2) The checkpoint: Flushes dirty pages from the in-memory cache. Writes a checkpoint record. Flushes the log. Writes a list of open databases. How to do checkpoint in Memcachedb: Run checkpoint periodically with ’-C’ option The private command: ’db checkpoint’ Steve Chu Memcachedb: The Complete Guide March 12, 2008 61 / 73
  • 107. Managing DB Files Backup Procedures Hot Backup /usr/local/BerkeleyDB.4.6/bin/db hotbackup [-c] -h home -b backup dir DB files has a high compression ratio, and use gzip and tar to archive. Steve Chu Memcachedb: The Complete Guide March 12, 2008 62 / 73
  • 108. Managing DB Files Recovery Procedures Normal Recovery Put database files and log files since the last checkpoint(or a hotbackup copy) into a empty home environemt, Start the deamon on this environment, the deamon will do recovery automatically. Also it can be done by using standalone utility ’db recover’: /usr/local/BerkeleyDB.4.6/bin/db recover -f -h home Catastrophic Recovery Put all your database files and all log files(since environment created) into a empty home environment, Use standalone utility ’db recover’ with option ’-c’: /usr/local/BerkeleyDB.4.6/bin/db recover -cf -h home Steve Chu Memcachedb: The Complete Guide March 12, 2008 63 / 73
  • 109. Managing DB Files Removing Log Files Log Files in which transactions have been checkpointed into database file can be removed directly or archived to offline storage devices. You can remove this log files by using private command: ’db archive’ using standalone utility ’db archive’ with option ’-d’: /usr/local/BerkeleyDB.4.6/bin/db archive -d -h home Warning: log file removal is likely to make catastrophic recovery impossible. If the data is very important(I mean if the data is lost, you are over.), you’d better archive them to offline storage devices instead of removal. Steve Chu Memcachedb: The Complete Guide March 12, 2008 64 / 73
  • 110. Monitoring Monitoring 14 Managing DB Files 15 Monitoring Steve Chu Memcachedb: The Complete Guide March 12, 2008 65 / 73
  • 111. Monitoring Overview There are four ways now available for monitoring Memcachedb: the raw ’stats’ commands: ’stats’, ’stats bdb’, ’stats rep’ the standalone utility ’db stat’ the coming along monitoring tool ’tools/mdbtop.py’ writing your own monitoring tool using ’tools/memcache.py’ Steve Chu Memcachedb: The Complete Guide March 12, 2008 66 / 73
  • 112. Monitoring ’stats’ command There are a few of ’stats’ commands in Memcachedb: ‘stats’ shows the status of current deamon. ‘stats bdb’ shows the status of BerkeleyDB. ‘stats rep’ shows the status of Replication. Just telnet in, and use them. Some of Memcached Client APIs support ’stats’ command, but some not. If you find no one can do it, have a try of patched ’memcache.py’ in ’tools/’ of distribution. Steve Chu Memcachedb: The Complete Guide March 12, 2008 67 / 73
  • 113. Monitoring db stat BerkeleyDB distribution has a standalone utility ’db stat’ that can help us to get statistics for Berkeley DB environments. ‘-c’ Display locking subsystem statistics ‘-l’ Display logging subsystem statistics ‘-m’ Display cache statistics ‘-r’ Display replication statistics ‘-t’ Display transaction subsystem statistics ... See ’docs/utility/db stat.html’ in BerkeleyDB distribution for more info. Warning: ’-d’ option which displays database statistics for the specified file will be very expensive(that requires traversing the database), do not use it on a high traffic Memcachedb daemon. Steve Chu Memcachedb: The Complete Guide March 12, 2008 68 / 73
  • 114. Monitoring mdbtop.py ’mdbtop.py’ is a monitoring tool coming along with distribution. It is built on the patched ’memcache.py’ Python API. ./mdbtop.py <mdbtop.cfg> [rep] ’mdbtop.cfg’ is the configure file that mdbtop.py uses: mdbtop.cfg [ Server ] server1 = 127.0.0.1:21201 server2 = 127.0.0.1:21202 [ View ] interval = 1 [rep] option is for only replication syncing monitoring. Steve Chu Memcachedb: The Complete Guide March 12, 2008 69 / 73
  • 115. Monitoring memcache.py The patched ’memcache.py’ now has all private commands supported and you can write your own monitoring tools depending on these APIs: memcache.py import memcache mc = memcache . C l i e n t ( [ ’ 1 2 7 . 0 . 0 . 1 : 2 1 2 0 2 ’ ] , debug =0) mc . d b a r c h i v e ( ) mc . d b c h e c k p o i n t ( ) mc . r e p i s m a s t e r ( ) mc . r e p w h o i s m a s t e r ( ) mc . r e p s e t p r i o r i t y ( 1 0 0 ) mc . r e p s e t a c k p o l i c y ( 5 ) mc . r e p s e t a c k t i m e o u t ( 2 0 0 0 0 ) mc . r e p s e t r e q u e s t ( 4 , 1 6 ) mc . d i s c o n n e c t a l l ( ) Steve Chu Memcachedb: The Complete Guide March 12, 2008 70 / 73
  • 116. Part VI The End Steve Chu Memcachedb: The Complete Guide March 12, 2008 71 / 73
  • 117. Project info Homepage: http://memcachedb.org Mailing list: http://groups.google.com/group/memcachedb To subscribe to maillist, send email to memcachedb-subscribe@googlegroups.com To post to maillist, send email to memcachedb@googlegroups.com To unsubscribe from maillist, send email to memcachedb-unsubscribe@googlegroups.com Please report your bugs and issues to the Maillist. Steve Chu Memcachedb: The Complete Guide March 12, 2008 72 / 73
  • 118. Q/A Any question? Steve Chu Memcachedb: The Complete Guide March 12, 2008 73 / 73