moxi
a memcached proxy
who

• steve yen
• dustin sallings
• matt ingenthron
rhymes with foxy
open source
multithreaded C
standing on the
   shoulders of giants

• libmemcached
• memcached
• libevent
web stack
              apache

      php   php    php   php




memcached   memcached    memcached
choose your weapons
               apache

       php   RoR   Django   perl




 memcached   memcached      memcached
php then...
              apache

      php   php    php   php




memcached   memcached    memcached
connection mesh
              apache

      php   php    php   php




memcached   memcached    memcached
moxi
              apache

      php   php          php   php



                  moxi




memcached   memcached          memcached
moxi connections
              apache

      php   php          php   php



                  moxi




memcached   memcached          memcached
moxi connections
              apache

      php   php          php   php



                  moxi




memcached   memcached          memcached
moxi connections
                apache

      php     php          php   php



                    moxi

configurable
concurrency


memcached     memcached          memcached
protocol conversion
               apache

       php   php          php        php

                                ascii protocol

                   moxi

                                    ascii protocol



 memcached   memcached              memcached
protocol conversion
                    apache

         php      php          php        php

                                     ascii protocol

                        moxi

                                         ascii protocol
binary protocol


  memcached       memcached              memcached
auth’ed connections
                    apache

         php      php          php   php



                        moxi

   auth’ed
binary protocol


  memcached       memcached          memcached
consistent hashing
              apache

      php   php          php   php



                  moxi




memcached   memcached          memcached
consistent hashing
              apache

      php   php          php   php



                  moxi

                                       a new server!



memcached   memcached          memcached    memcached
management channel
                            apache

                  php     php          php   php



dynamic reconfigurations
     and statistics             moxi

                                                     a new server!



           memcached      memcached          memcached    memcached
GET de-duplication

                  get item:2421
  get item:2421                   get item:2421
GET de-duplication
                apache

 get a b c    get b c d          get c d e



                moxi


             get a b c d e instead of...
                             get a b c
             memcached       get b c d
                             get c d e
front cache
              apache

      php   php          php        php


                               front cache
                  moxi




memcached   memcached              memcached
front cache
              apache

      php   php          php        php


                               front cache
                  moxi




memcached   memcached              memcached
front cache
              apache

      php   php          php        php

                                           Prefix-based. For limited
                                            number of hot items.
                               front cache     Served without
                  moxi                           hitting wire.
                                             Simple expirations.
                                            Meant for replication
                                              friendly content.



memcached   memcached              memcached
front cache
hot items replicated across many front caches.


     moxi            moxi           moxi




      memcached    memcached   memcached
front cache
hot items replicated across many front caches.


     moxi            moxi           moxi




      memcached    memcached   memcached
front cache
hot items replicated across many front caches.
                     lazily.

     moxi            moxi           moxi




      memcached    memcached   memcached
failure handling

moxi           moxi           moxi




 memcached   memcached   memcached
failure handling
   for hiccups: configurable retry counts.
then send misses and ERROR back to clients

    moxi           moxi           moxi




     memcached   memcached   memcached
failure handling
for deep failures (and for planned server changes)
       dynamic reconfiguration messages

           moxi           moxi           moxi

  mgmt
 channel




            memcached   memcached   memcached   memcached
failure handling
for deep failures (and for planned server changes)
       dynamic reconfiguration messages

           moxi           moxi           moxi

  mgmt
 channel




            memcached   memcached   memcached   memcached
draining and filling
lazily migrate items from old server to new server


           moxi           moxi           moxi

  mgmt
 channel




            memcached   memcached   memcached   memcached

                                    draining      filling
draining and filling
     N time later, just use filled server only


          moxi           moxi           moxi

 mgmt
channel




           memcached   memcached   memcached    memcached

                                   drained        filled
timeout
timeout
• if a request takes more than X millisecs,
  moxi should return a miss or error
blackhole configuration

  • GET’s become misses
  • SET’s become error
  • clients never wait, such as trying
    to make a connection to a non-
    existent memcached
fire & forget SET
client...                                    moxi...
session[‘shopping-cart’] = user_cart;
sends... set session:123456 some_big_value
                                             receives... set session:123456 some_big_value
                                             sees a match with configurable prefix
                                             “session:”
                                             responds with STORED to client.

receives STORED.                             forwards to memcached
                                             asynchronously.
continues on its way.
inside moxi

• memcached
• libevent
• libmemcached
inside moxi
memcached
 hash        item manager
 table         slabber


    ascii        binary
  protocol      protocol
  handler       handler




                             drive_machine
                           protocol state machine

                                 libevent
inside moxi
memcached                                                                    proxy
 hash        item manager                  libmemcached                      front
 table         slabber             dyna-config              matcher           cache


    ascii        binary             ascii proxy        ascii proxy       binary proxy
  protocol      protocol             upstream         downstream         downstream
  handler       handler          protocol handler   protocol handler   protocol handler




                             drive_machine
                           protocol state machine

                                 libevent
inside moxi
memcached                                                                    proxy
 hash        item manager                  libmemcached                      front
 table         slabber             dyna-config              matcher           cache


    ascii        binary             ascii proxy        ascii proxy       binary proxy
  protocol      protocol             upstream         downstream         downstream
  handler       handler          protocol handler   protocol handler   protocol handler




                             drive_machine
                           protocol state machine

                                 libevent
moxi embeds memcached
 memcached                                                                    proxy
  hash        item manager                  libmemcached                      front
  table         slabber             dyna-config              matcher           cache


     ascii        binary             ascii proxy        ascii proxy       binary proxy
   protocol      protocol             upstream         downstream         downstream
   handler       handler          protocol handler   protocol handler   protocol handler




                              drive_machine
                            protocol state machine

                                  libevent
moxi’s can talk to themselves

   but, they think they’re talking to memcached


       moxi            moxi          moxi
moxi’s can talk to themselves
    and to memcached
 and, they still think they’re talking to just memcached


          moxi            moxi            moxi




           memcached
moxi’s can talk to themselves
    and to memcached
 and, they still think they’re talking to just memcached


          moxi            moxi            moxi




           memcached   memcached
moxi’s can talk to themselves
    and to memcached
 and, they still think they’re talking to just memcached


          moxi            moxi            moxi




           memcached   memcached    memcached
moxi’s can talk to themselves
  and to memcached(*)
 and, they still think they’re talking to just memcached


          moxi            moxi            moxi




           memcached      tokyo      memcachedb
                          tyrant
starting
                                moxi
          memcached           command
         command-line           line




• memcached -m 512

• moxi -m 512 -z [configkey]
when can I get moxi?
today

• upcoming features
 • draining/filling - August 2009
• everything else is done
 • Available Now
where can I get moxi?
links

• getting moxi
 • http://labs.northscale.com/moxi

• read, join list
 • moxi@googlegroups.com
support, training

• available from NorthScale, Inc.
 • steve.yen@northscale.com
 • 888.399.5509
 • support@northscale.com
questions?
thanks!

photo credits

 •     http://flickr.com/photos/davebluedevil/15877348/

 •     http://www.flickr.com/photos/theamarand/2874288064/

 •     http://www.flickr.com/photos/splityarn/3469596708/

 •     http://www.flickr.com/photos/heisnofool/3241930754/

 •     http://www.flickr.com/photos/onourminds/2885704630/

 •     http://www.flickr.com/photos/lunaspin/990825818/
talking to itself
 optimization
stats aggregation
broadcasts “stats”. sums the responses.


                 moxi




   memcached   memcached   memcached
flush_all
broadcasts “flush_all” to memcached servers


                    moxi




     memcached    memcached   memcached

Moxi - Memcached Proxy

  • 1.
  • 2.
    who • steve yen •dustin sallings • matt ingenthron
  • 3.
  • 4.
  • 5.
  • 6.
    standing on the shoulders of giants • libmemcached • memcached • libevent
  • 7.
    web stack apache php php php php memcached memcached memcached
  • 8.
    choose your weapons apache php RoR Django perl memcached memcached memcached
  • 9.
    php then... apache php php php php memcached memcached memcached
  • 10.
    connection mesh apache php php php php memcached memcached memcached
  • 11.
    moxi apache php php php php moxi memcached memcached memcached
  • 12.
    moxi connections apache php php php php moxi memcached memcached memcached
  • 13.
    moxi connections apache php php php php moxi memcached memcached memcached
  • 14.
    moxi connections apache php php php php moxi configurable concurrency memcached memcached memcached
  • 15.
    protocol conversion apache php php php php ascii protocol moxi ascii protocol memcached memcached memcached
  • 16.
    protocol conversion apache php php php php ascii protocol moxi ascii protocol binary protocol memcached memcached memcached
  • 17.
    auth’ed connections apache php php php php moxi auth’ed binary protocol memcached memcached memcached
  • 18.
    consistent hashing apache php php php php moxi memcached memcached memcached
  • 19.
    consistent hashing apache php php php php moxi a new server! memcached memcached memcached memcached
  • 20.
    management channel apache php php php php dynamic reconfigurations and statistics moxi a new server! memcached memcached memcached memcached
  • 21.
    GET de-duplication get item:2421 get item:2421 get item:2421
  • 22.
    GET de-duplication apache get a b c get b c d get c d e moxi get a b c d e instead of... get a b c memcached get b c d get c d e
  • 23.
    front cache apache php php php php front cache moxi memcached memcached memcached
  • 24.
    front cache apache php php php php front cache moxi memcached memcached memcached
  • 25.
    front cache apache php php php php Prefix-based. For limited number of hot items. front cache Served without moxi hitting wire. Simple expirations. Meant for replication friendly content. memcached memcached memcached
  • 26.
    front cache hot itemsreplicated across many front caches. moxi moxi moxi memcached memcached memcached
  • 27.
    front cache hot itemsreplicated across many front caches. moxi moxi moxi memcached memcached memcached
  • 28.
    front cache hot itemsreplicated across many front caches. lazily. moxi moxi moxi memcached memcached memcached
  • 29.
    failure handling moxi moxi moxi memcached memcached memcached
  • 30.
    failure handling for hiccups: configurable retry counts. then send misses and ERROR back to clients moxi moxi moxi memcached memcached memcached
  • 31.
    failure handling for deepfailures (and for planned server changes) dynamic reconfiguration messages moxi moxi moxi mgmt channel memcached memcached memcached memcached
  • 32.
    failure handling for deepfailures (and for planned server changes) dynamic reconfiguration messages moxi moxi moxi mgmt channel memcached memcached memcached memcached
  • 33.
    draining and filling lazilymigrate items from old server to new server moxi moxi moxi mgmt channel memcached memcached memcached memcached draining filling
  • 34.
    draining and filling N time later, just use filled server only moxi moxi moxi mgmt channel memcached memcached memcached memcached drained filled
  • 35.
  • 36.
    timeout • if arequest takes more than X millisecs, moxi should return a miss or error
  • 37.
    blackhole configuration • GET’s become misses • SET’s become error • clients never wait, such as trying to make a connection to a non- existent memcached
  • 38.
    fire & forgetSET client... moxi... session[‘shopping-cart’] = user_cart; sends... set session:123456 some_big_value receives... set session:123456 some_big_value sees a match with configurable prefix “session:” responds with STORED to client. receives STORED. forwards to memcached asynchronously. continues on its way.
  • 39.
    inside moxi • memcached •libevent • libmemcached
  • 40.
    inside moxi memcached hash item manager table slabber ascii binary protocol protocol handler handler drive_machine protocol state machine libevent
  • 41.
    inside moxi memcached proxy hash item manager libmemcached front table slabber dyna-config matcher cache ascii binary ascii proxy ascii proxy binary proxy protocol protocol upstream downstream downstream handler handler protocol handler protocol handler protocol handler drive_machine protocol state machine libevent
  • 42.
    inside moxi memcached proxy hash item manager libmemcached front table slabber dyna-config matcher cache ascii binary ascii proxy ascii proxy binary proxy protocol protocol upstream downstream downstream handler handler protocol handler protocol handler protocol handler drive_machine protocol state machine libevent
  • 43.
    moxi embeds memcached memcached proxy hash item manager libmemcached front table slabber dyna-config matcher cache ascii binary ascii proxy ascii proxy binary proxy protocol protocol upstream downstream downstream handler handler protocol handler protocol handler protocol handler drive_machine protocol state machine libevent
  • 44.
    moxi’s can talkto themselves but, they think they’re talking to memcached moxi moxi moxi
  • 45.
    moxi’s can talkto themselves and to memcached and, they still think they’re talking to just memcached moxi moxi moxi memcached
  • 46.
    moxi’s can talkto themselves and to memcached and, they still think they’re talking to just memcached moxi moxi moxi memcached memcached
  • 47.
    moxi’s can talkto themselves and to memcached and, they still think they’re talking to just memcached moxi moxi moxi memcached memcached memcached
  • 48.
    moxi’s can talkto themselves and to memcached(*) and, they still think they’re talking to just memcached moxi moxi moxi memcached tokyo memcachedb tyrant
  • 49.
    starting moxi memcached command command-line line • memcached -m 512 • moxi -m 512 -z [configkey]
  • 50.
    when can Iget moxi?
  • 51.
    today • upcoming features • draining/filling - August 2009 • everything else is done • Available Now
  • 52.
    where can Iget moxi?
  • 53.
    links • getting moxi • http://labs.northscale.com/moxi • read, join list • moxi@googlegroups.com
  • 54.
    support, training • availablefrom NorthScale, Inc. • steve.yen@northscale.com • 888.399.5509 • support@northscale.com
  • 55.
  • 56.
    thanks! photo credits • http://flickr.com/photos/davebluedevil/15877348/ • http://www.flickr.com/photos/theamarand/2874288064/ • http://www.flickr.com/photos/splityarn/3469596708/ • http://www.flickr.com/photos/heisnofool/3241930754/ • http://www.flickr.com/photos/onourminds/2885704630/ • http://www.flickr.com/photos/lunaspin/990825818/
  • 58.
    talking to itself optimization
  • 59.
    stats aggregation broadcasts “stats”.sums the responses. moxi memcached memcached memcached
  • 60.
    flush_all broadcasts “flush_all” tomemcached servers moxi memcached memcached memcached