SlideShare a Scribd company logo
1 of 42
Couchbase for
Python developers
HotCode 2013
What is Couchbase?
Couchbase
• http://www.couchbase.com
• Open source NoSQL database technology for interactive web and mobile apps
• Easy scalability
• Consistent high performance
• Flexible data model
History.Membase
• Started in June 2010 as Membase
• Simplicity and speed of Memcached
• But also provide storage,persistence and querying capabilities
• Initially created by NorthScale with co-sponsors Zynga and NHN
History.Merge with CouchOne
• In February 2011 Membase merged with CouchOne
• CouchOne company with many developers of CouchDB
• After merge company named Couchbase
• In January 2012 Couchbase 1.8 released
History.Couchbase 2.0
• On December 2012 Couchbase 2.0 released
• New JSON document store
• Indexing and querying data
• Incremental MapReduce
• Cross datacenter replication
In total
• CouchBase is
• Memcached interface for managing data
• CouchDB based interface for indexing and querying data
• Scalability (clustering,replications) out of the box
Why we need another
NoSQL solution?
What we have?
• Key-value cache in RAM
• Redis
• Memcached
• Eventually-consistent key-value store
• Cassandra
• Dynamo
• Riak
What we have?
• Document store
• CouchDB
• MongoDB
• {{ name }}DB
Why we need another?
• Cause developers can
• This is cool to be a NoSQL storage author
• There should be a serious NoSQL storages for business
• But really,I don’t know
• I still prefer Redis + PostgreSQL more than Couchbase :)
CouchBase as cache storage
Couchbase is Memcached
• All Memcached commands* work with Couchbase
• set/add/replace
• append/prepend
• get/delete
• incr/decr
• touch
• stats
• *except of flush
How it works?
• Connect to Memcached socket using binary protocol
• Authenticate with or without password
• Send Memcached command as request
• Receive response from Memcached
Differences
• Additional commands
• lock/unlock
• vBucketID value should present in each key request
What is vBucket?
• http://dustin.github.io/2010/06/29/memcached-vbuckets.html
• http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-introduction-
architecture-vbuckets.html
• vBucket is computed subset of all possible keys
• vBucket system used for distributing data and for supporting replicas
• vBucket mapping allows server know the fastest way for getting/setting data
• Couchbase vBucket implementation differs from standard Memcached
implementation
vBucket mapping
9 vbuckets,3 clusters
if hash(KEY) == vB 8:
read key from server C
vBucket mapping after new node added
9 vbuckets,4 clusters
if hash(KEY) == vB 8:
read key from server D
CouchBase as document storage
Same between CouchDB and Couchbase
• NoSQL document database
• JSON as document format
• Append-only file format
• Same approach for indexing and querying
• CouchDB replication technology is base for Couchbase cross datacenter replication
Differences
• Couchbase cache-based database in terms of read/write performance
• CouchDB disk-based database
• Couchbase has a built-in clustering system that allows data spread over nodes
• CouchDB is a single node solution with peer-to-peer replication
• Each solution has their admin interfaces (Couchbase server admin,Futon)
In total
• Couchbase is not CouchDB
Indexing and querying data
• Say hello to views!
• First you need to create design document (via REST API or admin UI)
• Design document is collection of views
• Next you need to create view and provide map/reduce functions
• View should contain map function and could contain reduce function
• After Couchbase server indexing data by executing map functions and stores result
in sorted order
View map functions
# Returns all document IDs from bucket
function(doc, meta) {
emit(meta.id, null);
}
# Returns only JSON document IDs
function(doc, meta) {
if (meta.type == “json”) {
emit(meta.id, null);
}
}
# Multiple returns in one view
function(doc, meta) {
if (meta.type == “json”) {
if (doc.name) {
emit(doc.name, null);
}
if (doc.nameLong) {
emit(doc.nameLong, null);
}
}
}
Querying indexed data
• Querying available via REST API
• Can filter results by exact key
• Or using range (startkey,endkey)
• All key requests should use JSON format
• Also can group results,reverse results,paginate results
View reduce functions
• When you need data to be summarized or reduced
• Reduce function could be defined in view or
send while querying view via REST API
• Built-in functions
• _count
• _sum
• _stats
Overview of Python clients
couchbase < 0.9
• Very slow official Python client
• Supports Memcached commands and REST API
• Not ready for any usage
• ~800 ops/sec on my machine
couchbase >= 0.9
• Python client based on C libcouchbase library
• Only supports Memcached commands
• No REST API support
• ~8000 ops/sec on my machine
couchbase >= 0.9
from couchbase import Couchbase
couchbase = Couchbase()
client = couchbase.connect(bucket, host, port, username, password)
client.set(‘key’, ‘value’)
assert client.get(‘key’).value == ‘value’
from couchbase import FMT_JSON
client.set(‘doc’, {‘key’: ‘value’}, FMT_JSON)
assert client.get(‘key’).value == {‘key’: ‘value’}
mcdonnell
• Experimental Python client created by myself
• Not open sourced yet :(
• Supports Memcached commands and REST API
• Has Django cache backend and Celery result backend
• ~6000 ops/sec on my machine
mcdonnell
from mcdonnell.bucket import Bucket
client = Bucket(‘couchbase://username:password@host:port/bucket’)
client.set(‘key’, ‘value’)
assert client.get(‘key’) == ‘value’
from mcdonnell.constants import FLAG_JSON
client.set(‘doc’, {‘key’: ‘value’}, flags=FLAG_JSON)
assert client.get(‘key’) == {‘key’: ‘value’}
mcdonnell
import types
from mcdonnell.bucket import Bucket
client = Bucket(‘couchbase://username:password@host:port/bucket’)
results = client.view(‘design’, ‘view’)
assert isinstance(results, types.GeneratorType)
from mcdonnell.ddocs import DesignDoc
ddoc = DesignDoc(‘design_name’)
ddoc.views[‘view_name’] = map_function
ddoc.upload()
How we use CouchBase
in real life in GetGoing?
What we have?
• 3 m2.xlarge EC2 instances
• 45 GB RAM
• 1.43 TB disk
For what reasons?
• Search results cache (with ttl)
• User cache (persistance)
• Hotels data document storage (persistance)
Clustering,replications and
other NoSQL buzzwords
Clustering
• New node could be added/deleted via command line or REST API
• After node added/deleted cluster should be rebalanced
• Can auto-failover broken nodes,but only for 3+ total nodes in cluster
Cross datacenter replication
• Could replicate to other Couchbase cluster
• Could replicate to other storage,like ElasticSearch
Couchbase -> ElasticSearch replication
• ElasticSearch is search engine built on top of Apache Lucene,same to Solr,but
more REST API friendly
• Couchbase has official transport to replicate all cluster data to ElasticSearch
• This enables fulltext search over cluster data
Other
• Couchbase has experimental geo views support
• Couchbase has two editions: community and enterprise
Questions?
I am Igor Davydenko
http://igordavydenko.com
http://github.com/playpauseandstop

More Related Content

What's hot

SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...Sencha
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxKarl-Henry Martinsson
 
MuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of LoopingMuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of Loopingakashdprajapati
 
Caching & validating
Caching & validatingCaching & validating
Caching & validatingSon Nguyen
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS BackendLaurent Cerveau
 
Using memcache to improve php performance
Using memcache to improve php performanceUsing memcache to improve php performance
Using memcache to improve php performanceSudar Muthu
 
Introduction to ServiceStack
Introduction to ServiceStackIntroduction to ServiceStack
Introduction to ServiceStackmobiweave
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSunghyouk Bae
 
Microsoft Azure, door Rob Brommer op de 4DotNet Developers Day
Microsoft Azure, door Rob Brommer op de 4DotNet Developers DayMicrosoft Azure, door Rob Brommer op de 4DotNet Developers Day
Microsoft Azure, door Rob Brommer op de 4DotNet Developers DayHanneke Dotnet
 
Integrating OpenStack with Active Directory
Integrating OpenStack with Active DirectoryIntegrating OpenStack with Active Directory
Integrating OpenStack with Active Directorycjellick
 
Introduction to service stack
Introduction to service stackIntroduction to service stack
Introduction to service stackFabio Cozzolino
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guideAdy Liu
 
Couchbase - Yet Another Introduction
Couchbase - Yet Another IntroductionCouchbase - Yet Another Introduction
Couchbase - Yet Another IntroductionKelum Senanayake
 
Concurrency at the Database Layer
Concurrency at the Database Layer Concurrency at the Database Layer
Concurrency at the Database Layer mcwilson1
 

What's hot (20)

SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
MuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of LoopingMuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of Looping
 
Caching & validating
Caching & validatingCaching & validating
Caching & validating
 
Break out of The Box - Part 2
Break out of The Box - Part 2Break out of The Box - Part 2
Break out of The Box - Part 2
 
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS Backend
 
Using memcache to improve php performance
Using memcache to improve php performanceUsing memcache to improve php performance
Using memcache to improve php performance
 
Introduction to ServiceStack
Introduction to ServiceStackIntroduction to ServiceStack
Introduction to ServiceStack
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSL
 
OpenStack Keystone
OpenStack KeystoneOpenStack Keystone
OpenStack Keystone
 
Microsoft Azure, door Rob Brommer op de 4DotNet Developers Day
Microsoft Azure, door Rob Brommer op de 4DotNet Developers DayMicrosoft Azure, door Rob Brommer op de 4DotNet Developers Day
Microsoft Azure, door Rob Brommer op de 4DotNet Developers Day
 
Integrating OpenStack with Active Directory
Integrating OpenStack with Active DirectoryIntegrating OpenStack with Active Directory
Integrating OpenStack with Active Directory
 
Introduction to service stack
Introduction to service stackIntroduction to service stack
Introduction to service stack
 
Play Framework
Play FrameworkPlay Framework
Play Framework
 
Node.js Introduction
Node.js IntroductionNode.js Introduction
Node.js Introduction
 
Keystone Federation
Keystone Federation Keystone Federation
Keystone Federation
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guide
 
Couchbase - Yet Another Introduction
Couchbase - Yet Another IntroductionCouchbase - Yet Another Introduction
Couchbase - Yet Another Introduction
 
Concurrency at the Database Layer
Concurrency at the Database Layer Concurrency at the Database Layer
Concurrency at the Database Layer
 

Viewers also liked

Viewers also liked (6)

The Power of Planning - Funnel 2012
The Power of Planning - Funnel 2012The Power of Planning - Funnel 2012
The Power of Planning - Funnel 2012
 
Premiere Vision
Premiere VisionPremiere Vision
Premiere Vision
 
Iglesia – castillo de san bartolomé
Iglesia – castillo de san bartoloméIglesia – castillo de san bartolomé
Iglesia – castillo de san bartolomé
 
Cuerpos geometricos 1
Cuerpos geometricos 1Cuerpos geometricos 1
Cuerpos geometricos 1
 
Trip to Upin & Ipin 2013
Trip to Upin & Ipin 2013Trip to Upin & Ipin 2013
Trip to Upin & Ipin 2013
 
Cognition jeopardy review
Cognition jeopardy reviewCognition jeopardy review
Cognition jeopardy review
 

Similar to Igor Davydenko

Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelAlex Thissen
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystemconfluent
 
Cnam azure ze cloud resource manager
Cnam azure ze cloud  resource managerCnam azure ze cloud  resource manager
Cnam azure ze cloud resource managerAymeric Weinbach
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 
SwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup GroupSwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup GroupErnest Jumbe
 
Evolution of a cloud start up: From C# to Node.js
Evolution of a cloud start up: From C# to Node.jsEvolution of a cloud start up: From C# to Node.js
Evolution of a cloud start up: From C# to Node.jsSteve Jamieson
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsRichard Rodger
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetesBen Hall
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)Tim Davis
 
Icinga 2009 at OSMC
Icinga 2009 at OSMCIcinga 2009 at OSMC
Icinga 2009 at OSMCIcinga
 

Similar to Igor Davydenko (20)

Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystem
 
Cnam azure ze cloud resource manager
Cnam azure ze cloud  resource managerCnam azure ze cloud  resource manager
Cnam azure ze cloud resource manager
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
SwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup GroupSwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup Group
 
Evolution of a cloud start up: From C# to Node.js
Evolution of a cloud start up: From C# to Node.jsEvolution of a cloud start up: From C# to Node.js
Evolution of a cloud start up: From C# to Node.js
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.js
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublin
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)
 
Icinga 2009 at OSMC
Icinga 2009 at OSMCIcinga 2009 at OSMC
Icinga 2009 at OSMC
 

More from SCRUMguides

Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...
Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...
Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...SCRUMguides
 
Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге"
 Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге" Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге"
Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге"SCRUMguides
 
Олег Шаповалов "Agile в Академии ДТЭК"
 Олег Шаповалов "Agile в Академии ДТЭК" Олег Шаповалов "Agile в Академии ДТЭК"
Олег Шаповалов "Agile в Академии ДТЭК"SCRUMguides
 
Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"
Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"
Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"SCRUMguides
 
Юрий Литвиненко "Вы пробовали выйти из IT?"
Юрий Литвиненко "Вы пробовали выйти из IT?"Юрий Литвиненко "Вы пробовали выйти из IT?"
Юрий Литвиненко "Вы пробовали выйти из IT?"SCRUMguides
 
Анна Обухова "Powerful Powerless Leader"
Анна Обухова "Powerful Powerless Leader"Анна Обухова "Powerful Powerless Leader"
Анна Обухова "Powerful Powerless Leader"SCRUMguides
 
Иван Дубровин "Agile контракты"
Иван Дубровин "Agile контракты"Иван Дубровин "Agile контракты"
Иван Дубровин "Agile контракты"SCRUMguides
 
Слайды доклада Алексея Мохунова "Вам скучно? Вы увязли в рутине? Откройте ре...
Слайды доклада Алексея Мохунова  "Вам скучно? Вы увязли в рутине? Откройте ре...Слайды доклада Алексея Мохунова  "Вам скучно? Вы увязли в рутине? Откройте ре...
Слайды доклада Алексея Мохунова "Вам скучно? Вы увязли в рутине? Откройте ре...SCRUMguides
 
Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе"
Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе" Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе"
Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе" SCRUMguides
 
Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"
Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"
Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"SCRUMguides
 
Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "
Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "
Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "SCRUMguides
 
Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"
Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"
Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"SCRUMguides
 
Евгений Андрушко "Big & Enterpise data: чему они нас научили"
Евгений Андрушко "Big & Enterpise data: чему они нас научили"Евгений Андрушко "Big & Enterpise data: чему они нас научили"
Евгений Андрушко "Big & Enterpise data: чему они нас научили"SCRUMguides
 
Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"
Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"
Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"SCRUMguides
 
Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"
Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"
Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"SCRUMguides
 
Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"
Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"
Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"SCRUMguides
 
Наталья Бабак "Client: Bring up the connection"
Наталья Бабак "Client: Bring up the connection"Наталья Бабак "Client: Bring up the connection"
Наталья Бабак "Client: Bring up the connection"SCRUMguides
 
AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...
AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...
AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...SCRUMguides
 
AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...
AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...
AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...SCRUMguides
 
AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...
AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...
AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...SCRUMguides
 

More from SCRUMguides (20)

Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...
Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...
Ольга Ильина и Юля Пузырева "Скрам-команда – какая она в глазах Владельца Про...
 
Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге"
 Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге" Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге"
Анастасия Давыдова "ТОП 10 ошибок маркетологов и руководителей в маркетинге"
 
Олег Шаповалов "Agile в Академии ДТЭК"
 Олег Шаповалов "Agile в Академии ДТЭК" Олег Шаповалов "Agile в Академии ДТЭК"
Олег Шаповалов "Agile в Академии ДТЭК"
 
Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"
Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"
Вадим Аристов и Вероника Кобзистая "Государственная реформа по Agile"
 
Юрий Литвиненко "Вы пробовали выйти из IT?"
Юрий Литвиненко "Вы пробовали выйти из IT?"Юрий Литвиненко "Вы пробовали выйти из IT?"
Юрий Литвиненко "Вы пробовали выйти из IT?"
 
Анна Обухова "Powerful Powerless Leader"
Анна Обухова "Powerful Powerless Leader"Анна Обухова "Powerful Powerless Leader"
Анна Обухова "Powerful Powerless Leader"
 
Иван Дубровин "Agile контракты"
Иван Дубровин "Agile контракты"Иван Дубровин "Agile контракты"
Иван Дубровин "Agile контракты"
 
Слайды доклада Алексея Мохунова "Вам скучно? Вы увязли в рутине? Откройте ре...
Слайды доклада Алексея Мохунова  "Вам скучно? Вы увязли в рутине? Откройте ре...Слайды доклада Алексея Мохунова  "Вам скучно? Вы увязли в рутине? Откройте ре...
Слайды доклада Алексея Мохунова "Вам скучно? Вы увязли в рутине? Откройте ре...
 
Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе"
Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе" Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе"
Слайды доклада Юрия Козия "Agile-трансформация в не-ІТ бизнесе"
 
Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"
Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"
Дмитрий Ефименко "Продуктовая команда. ценности, принципы, практики"
 
Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "
Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "
Андрей Павлюков “Внешняя и внутренняя мотивация. Что движет людьми? "
 
Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"
Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"
Андрій Скуратов "Мотивація, Профанація та Арсенал Лідера"
 
Евгений Андрушко "Big & Enterpise data: чему они нас научили"
Евгений Андрушко "Big & Enterpise data: чему они нас научили"Евгений Андрушко "Big & Enterpise data: чему они нас научили"
Евгений Андрушко "Big & Enterpise data: чему они нас научили"
 
Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"
Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"
Роман Сахаров "Зміна Scope спринту посередині розробки: хто винен і що робити?"
 
Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"
Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"
Максим Вишнивецкий "Как мозг мешает гибкости или 1,5 килограмма проблем"
 
Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"
Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"
Андрій Мудрий "Від хаосу до Enterprise завдяки Agile"
 
Наталья Бабак "Client: Bring up the connection"
Наталья Бабак "Client: Bring up the connection"Наталья Бабак "Client: Bring up the connection"
Наталья Бабак "Client: Bring up the connection"
 
AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...
AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...
AgileBaseCamp Lviv 2014: Наталья Тренина "Практикуйте хаотичное добро, или Пр...
 
AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...
AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...
AgileBaseCamp Lviv 2014: Аліна Марусик "Наші і не наші єноти, або синергія в ...
 
AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...
AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...
AgileBaseCamp Lviv 2014: Марьян Царь "Якість продукту в Скрамі. Погляд QA інж...
 

Igor Davydenko

  • 3. Couchbase • http://www.couchbase.com • Open source NoSQL database technology for interactive web and mobile apps • Easy scalability • Consistent high performance • Flexible data model
  • 4. History.Membase • Started in June 2010 as Membase • Simplicity and speed of Memcached • But also provide storage,persistence and querying capabilities • Initially created by NorthScale with co-sponsors Zynga and NHN
  • 5. History.Merge with CouchOne • In February 2011 Membase merged with CouchOne • CouchOne company with many developers of CouchDB • After merge company named Couchbase • In January 2012 Couchbase 1.8 released
  • 6. History.Couchbase 2.0 • On December 2012 Couchbase 2.0 released • New JSON document store • Indexing and querying data • Incremental MapReduce • Cross datacenter replication
  • 7. In total • CouchBase is • Memcached interface for managing data • CouchDB based interface for indexing and querying data • Scalability (clustering,replications) out of the box
  • 8. Why we need another NoSQL solution?
  • 9. What we have? • Key-value cache in RAM • Redis • Memcached • Eventually-consistent key-value store • Cassandra • Dynamo • Riak
  • 10. What we have? • Document store • CouchDB • MongoDB • {{ name }}DB
  • 11. Why we need another? • Cause developers can • This is cool to be a NoSQL storage author • There should be a serious NoSQL storages for business • But really,I don’t know • I still prefer Redis + PostgreSQL more than Couchbase :)
  • 13. Couchbase is Memcached • All Memcached commands* work with Couchbase • set/add/replace • append/prepend • get/delete • incr/decr • touch • stats • *except of flush
  • 14. How it works? • Connect to Memcached socket using binary protocol • Authenticate with or without password • Send Memcached command as request • Receive response from Memcached
  • 15. Differences • Additional commands • lock/unlock • vBucketID value should present in each key request
  • 16. What is vBucket? • http://dustin.github.io/2010/06/29/memcached-vbuckets.html • http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-introduction- architecture-vbuckets.html • vBucket is computed subset of all possible keys • vBucket system used for distributing data and for supporting replicas • vBucket mapping allows server know the fastest way for getting/setting data • Couchbase vBucket implementation differs from standard Memcached implementation
  • 17. vBucket mapping 9 vbuckets,3 clusters if hash(KEY) == vB 8: read key from server C
  • 18. vBucket mapping after new node added 9 vbuckets,4 clusters if hash(KEY) == vB 8: read key from server D
  • 20. Same between CouchDB and Couchbase • NoSQL document database • JSON as document format • Append-only file format • Same approach for indexing and querying • CouchDB replication technology is base for Couchbase cross datacenter replication
  • 21. Differences • Couchbase cache-based database in terms of read/write performance • CouchDB disk-based database • Couchbase has a built-in clustering system that allows data spread over nodes • CouchDB is a single node solution with peer-to-peer replication • Each solution has their admin interfaces (Couchbase server admin,Futon)
  • 22. In total • Couchbase is not CouchDB
  • 23. Indexing and querying data • Say hello to views! • First you need to create design document (via REST API or admin UI) • Design document is collection of views • Next you need to create view and provide map/reduce functions • View should contain map function and could contain reduce function • After Couchbase server indexing data by executing map functions and stores result in sorted order
  • 24. View map functions # Returns all document IDs from bucket function(doc, meta) { emit(meta.id, null); } # Returns only JSON document IDs function(doc, meta) { if (meta.type == “json”) { emit(meta.id, null); } } # Multiple returns in one view function(doc, meta) { if (meta.type == “json”) { if (doc.name) { emit(doc.name, null); } if (doc.nameLong) { emit(doc.nameLong, null); } } }
  • 25. Querying indexed data • Querying available via REST API • Can filter results by exact key • Or using range (startkey,endkey) • All key requests should use JSON format • Also can group results,reverse results,paginate results
  • 26. View reduce functions • When you need data to be summarized or reduced • Reduce function could be defined in view or send while querying view via REST API • Built-in functions • _count • _sum • _stats
  • 28. couchbase < 0.9 • Very slow official Python client • Supports Memcached commands and REST API • Not ready for any usage • ~800 ops/sec on my machine
  • 29. couchbase >= 0.9 • Python client based on C libcouchbase library • Only supports Memcached commands • No REST API support • ~8000 ops/sec on my machine
  • 30. couchbase >= 0.9 from couchbase import Couchbase couchbase = Couchbase() client = couchbase.connect(bucket, host, port, username, password) client.set(‘key’, ‘value’) assert client.get(‘key’).value == ‘value’ from couchbase import FMT_JSON client.set(‘doc’, {‘key’: ‘value’}, FMT_JSON) assert client.get(‘key’).value == {‘key’: ‘value’}
  • 31. mcdonnell • Experimental Python client created by myself • Not open sourced yet :( • Supports Memcached commands and REST API • Has Django cache backend and Celery result backend • ~6000 ops/sec on my machine
  • 32. mcdonnell from mcdonnell.bucket import Bucket client = Bucket(‘couchbase://username:password@host:port/bucket’) client.set(‘key’, ‘value’) assert client.get(‘key’) == ‘value’ from mcdonnell.constants import FLAG_JSON client.set(‘doc’, {‘key’: ‘value’}, flags=FLAG_JSON) assert client.get(‘key’) == {‘key’: ‘value’}
  • 33. mcdonnell import types from mcdonnell.bucket import Bucket client = Bucket(‘couchbase://username:password@host:port/bucket’) results = client.view(‘design’, ‘view’) assert isinstance(results, types.GeneratorType) from mcdonnell.ddocs import DesignDoc ddoc = DesignDoc(‘design_name’) ddoc.views[‘view_name’] = map_function ddoc.upload()
  • 34. How we use CouchBase in real life in GetGoing?
  • 35. What we have? • 3 m2.xlarge EC2 instances • 45 GB RAM • 1.43 TB disk
  • 36. For what reasons? • Search results cache (with ttl) • User cache (persistance) • Hotels data document storage (persistance)
  • 38. Clustering • New node could be added/deleted via command line or REST API • After node added/deleted cluster should be rebalanced • Can auto-failover broken nodes,but only for 3+ total nodes in cluster
  • 39. Cross datacenter replication • Could replicate to other Couchbase cluster • Could replicate to other storage,like ElasticSearch
  • 40. Couchbase -> ElasticSearch replication • ElasticSearch is search engine built on top of Apache Lucene,same to Solr,but more REST API friendly • Couchbase has official transport to replicate all cluster data to ElasticSearch • This enables fulltext search over cluster data
  • 41. Other • Couchbase has experimental geo views support • Couchbase has two editions: community and enterprise
  • 42. Questions? I am Igor Davydenko http://igordavydenko.com http://github.com/playpauseandstop