SlideShare a Scribd company logo
Key-Value Storage Systems …  and beyond … with Python
Who the hell are you? + + = Ian Lewis Company: BeProud Tags: #python #django #redbull #mercurial Twitter: IanMLewis HP: http://www.ianlewis.org/
Pro: Fast Simple Con: Can't easily store complex relational data Can't do complex queries Why?
What?
Memcached Made by this guy  Not Persistent It's a cache so values go away Not useful as a database If you make websites and aren't using it you should be
python-memcached >>>  import  memcache  >>> client = memcache.Client([ "127.0.0.1:11211" ])  >>> client. set ( "test" ,  1 )  True   >>> client. add ( "test" ,  1 )  False   >>> client. add ( "test2" ,  1 )  True   >>> client. set ( "test" ,  2 )  True   >>> client. incr ( "test" )  3   >>>
Tokyo-Cabinet/Tyrant Made by Mikio Hirabayashi for Mixi Persistent Key-Value Store Mmapped file Supports hash-table, b+trees, fixed-length array Replication
python-tokyotyrant/pytyrant >>>  import  pytyrant  >>> t = pytyrant.PyTyrant. open ( '127.0.0.1' ,  1978 )  >>> t[ '__test_key__' ] =  'foo'   >>> t. concat ( '__test_key__' ,  'bar' )  >>>  print  t[ '__test_key__' ]  foobar  >>>  del  t[ '__test_key__' ] PY-
B+ Trees
pytc >>>  import  pytc >>> db = pytc.BDB( 'bdb.db' , pytc.BDBOWRITER | pytc.BDBOCREAT) >>> db[ 'niku' ] =  'umai' >>> db[ 'niku' ] 'umai' >>> db[ 'ra-men' ] =  'kuitai' >>> db[ 'ra-men' ] 'kuitai' >>>  for  key  in  db: >>>  print   'key:' , key,  ' value:' , db[key] 'key: niki value: umai' 'key: ra-men value: kuitai'
= ?
redis Re -mote  Di -ctionary  S -erver Cool new KVS Data structures: Lists, Sets, Sorted Sets Queries: unions, intersection, complement (diff) In Memory (Persisted in background) Replication
So I can't eat it?
>>>  from  redis  import  Redis, ConnectionError, ResponseError >>> r = Redis(db= 9 ) >>> r[ 'a' ] =  24 . 0 >>> r[ 'a' ] Decimal( "24.0" ) >>> r = Redis(db= 9 , float_fn= float ) >>> r[ 'a' ] 24 . 0 >>>  del  r[ 'a' ] >>>  print  r.get( 'a' )  # r['a'] will raise KeyError None redis-py
Made at Facebook for their Inbox search Distributed Key-Value Store Influenced by Apache Dynamo Values are columnar and stored together in column families and super columns Eventually consistent Consistency is user definable (Read servers, Write servers, Quorum, Full) Cassandra
Cassandra
pycassa import  pycassa CLIENT = pycassa.connect_thread_local(framed_transport= True ) USER = pycassa.ColumnFamily(CLIENT,  'Twissandra' ,  'User' , dict_class=OrderedDict) ... TWEET = pycassa.ColumnFamily(CLIENT,  'Twissandra' ,  'Tweet' , dict_class=OrderedDict) TIMELINE = pycassa.ColumnFamily(CLIENT,  'Twissandra' ,  'Timeline' , dict_class=OrderedDict) ... timeline = TIMELINE.get( str (user_id), column_start=start, column_count=limit, column_reversed= True ) tweets = TWEET.multiget(timeline.values())
Questions!

More Related Content

PPTX
Css multi background
PPTX
Getting to 100 in Google Page Speed Insights
PDF
Selenium sandwich-2
DOC
Te Vi Venir
PDF
Selenium Sandwich Part 1: Data driven Selenium
PPT
Couch db and_the_web
PDF
Site Performance Optimization for Joomla #jwc13
DOC
Yerma
Css multi background
Getting to 100 in Google Page Speed Insights
Selenium sandwich-2
Te Vi Venir
Selenium Sandwich Part 1: Data driven Selenium
Couch db and_the_web
Site Performance Optimization for Joomla #jwc13
Yerma

What's hot (6)

PPT
Speeding up Page Load Times by Using the Starling Queue Server
DOCX
Old man emu by john williamson
PPT
HTML, WordPress, and SEO
PPTX
Website Performance
PDF
Basic HTML CSS Slides
PPTX
Kansas City WordCamp - Website Performance
Speeding up Page Load Times by Using the Starling Queue Server
Old man emu by john williamson
HTML, WordPress, and SEO
Website Performance
Basic HTML CSS Slides
Kansas City WordCamp - Website Performance
Ad

Similar to Key Value Storage Systems ... and Beyond ... with Python (20)

PPT
What's new in Rails 2?
PPT
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
PPT
Web Scraper Shibuya.pm tech talk #8
ODP
Perl Teach-In (part 1)
ODP
Why Python by Marilyn Davis, Marakana
PPT
What's New in ZF 1.10
PPSX
jQuery - Doing it right
ODP
Getting started with MongoDB and PHP
PPTX
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
PPTX
Good practices for PrestaShop code security and optimization
PPT
Complex Values
PPT
Exploiting Php With Php
PPTX
Schema design with MongoDB (Dwight Merriman)
PPT
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
PPT
PHP Presentation
PPTX
5 Reasons To Love CodeIgniter
PPT
Redis And python at pycon_2011
PPT
Graph Databases
ODP
Introducing Modern Perl
ODP
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
What's new in Rails 2?
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
Web Scraper Shibuya.pm tech talk #8
Perl Teach-In (part 1)
Why Python by Marilyn Davis, Marakana
What's New in ZF 1.10
jQuery - Doing it right
Getting started with MongoDB and PHP
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Good practices for PrestaShop code security and optimization
Complex Values
Exploiting Php With Php
Schema design with MongoDB (Dwight Merriman)
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
PHP Presentation
5 Reasons To Love CodeIgniter
Redis And python at pycon_2011
Graph Databases
Introducing Modern Perl
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
Ad

More from Ian Lewis (7)

ODP
Appengine ja-night-20110222
ODP
Twisted ロングポーリング チャット サーバ
ODP
Sphinx 1.1 i18n 機能紹介
ODP
BPStudy #40 - Google Appengine 1.4.0
ODP
Djangoアプリの実践的設計手法
PPT
Celery Task Queue
PPT
Django O/R Mapper
Appengine ja-night-20110222
Twisted ロングポーリング チャット サーバ
Sphinx 1.1 i18n 機能紹介
BPStudy #40 - Google Appengine 1.4.0
Djangoアプリの実践的設計手法
Celery Task Queue
Django O/R Mapper

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Mushroom cultivation and it's methods.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Encapsulation theory and applications.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
A Presentation on Touch Screen Technology
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
August Patch Tuesday
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Mushroom cultivation and it's methods.pdf
Enhancing emotion recognition model for a student engagement use case through...
TLE Review Electricity (Electricity).pptx
Encapsulation theory and applications.pdf
1. Introduction to Computer Programming.pptx
A Presentation on Touch Screen Technology
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Hindi spoken digit analysis for native and non-native speakers
gpt5_lecture_notes_comprehensive_20250812015547.pdf
August Patch Tuesday
MIND Revenue Release Quarter 2 2025 Press Release
From MVP to Full-Scale Product A Startup’s Software Journey.pdf

Key Value Storage Systems ... and Beyond ... with Python

  • 1. Key-Value Storage Systems … and beyond … with Python
  • 2. Who the hell are you? + + = Ian Lewis Company: BeProud Tags: #python #django #redbull #mercurial Twitter: IanMLewis HP: http://www.ianlewis.org/
  • 3. Pro: Fast Simple Con: Can't easily store complex relational data Can't do complex queries Why?
  • 5. Memcached Made by this guy Not Persistent It's a cache so values go away Not useful as a database If you make websites and aren't using it you should be
  • 6. python-memcached >>> import memcache >>> client = memcache.Client([ "127.0.0.1:11211" ]) >>> client. set ( "test" , 1 ) True >>> client. add ( "test" , 1 ) False >>> client. add ( "test2" , 1 ) True >>> client. set ( "test" , 2 ) True >>> client. incr ( "test" ) 3 >>>
  • 7. Tokyo-Cabinet/Tyrant Made by Mikio Hirabayashi for Mixi Persistent Key-Value Store Mmapped file Supports hash-table, b+trees, fixed-length array Replication
  • 8. python-tokyotyrant/pytyrant >>> import pytyrant >>> t = pytyrant.PyTyrant. open ( '127.0.0.1' , 1978 ) >>> t[ '__test_key__' ] = 'foo' >>> t. concat ( '__test_key__' , 'bar' ) >>> print t[ '__test_key__' ] foobar >>> del t[ '__test_key__' ] PY-
  • 10. pytc >>> import pytc >>> db = pytc.BDB( 'bdb.db' , pytc.BDBOWRITER | pytc.BDBOCREAT) >>> db[ 'niku' ] = 'umai' >>> db[ 'niku' ] 'umai' >>> db[ 'ra-men' ] = 'kuitai' >>> db[ 'ra-men' ] 'kuitai' >>> for key in db: >>> print 'key:' , key, ' value:' , db[key] 'key: niki value: umai' 'key: ra-men value: kuitai'
  • 11. = ?
  • 12. redis Re -mote Di -ctionary S -erver Cool new KVS Data structures: Lists, Sets, Sorted Sets Queries: unions, intersection, complement (diff) In Memory (Persisted in background) Replication
  • 13. So I can't eat it?
  • 14. >>> from redis import Redis, ConnectionError, ResponseError >>> r = Redis(db= 9 ) >>> r[ 'a' ] = 24 . 0 >>> r[ 'a' ] Decimal( "24.0" ) >>> r = Redis(db= 9 , float_fn= float ) >>> r[ 'a' ] 24 . 0 >>> del r[ 'a' ] >>> print r.get( 'a' ) # r['a'] will raise KeyError None redis-py
  • 15. Made at Facebook for their Inbox search Distributed Key-Value Store Influenced by Apache Dynamo Values are columnar and stored together in column families and super columns Eventually consistent Consistency is user definable (Read servers, Write servers, Quorum, Full) Cassandra
  • 17. pycassa import pycassa CLIENT = pycassa.connect_thread_local(framed_transport= True ) USER = pycassa.ColumnFamily(CLIENT, 'Twissandra' , 'User' , dict_class=OrderedDict) ... TWEET = pycassa.ColumnFamily(CLIENT, 'Twissandra' , 'Tweet' , dict_class=OrderedDict) TIMELINE = pycassa.ColumnFamily(CLIENT, 'Twissandra' , 'Timeline' , dict_class=OrderedDict) ... timeline = TIMELINE.get( str (user_id), column_start=start, column_count=limit, column_reversed= True ) tweets = TWEET.multiget(timeline.values())