Introduction to NoSQL with Couchbase

  • 820 views
Uploaded on

Generic introduction to NoSQL, Couchbase presentation and Demonstration

Generic introduction to NoSQL, Couchbase presentation and Demonstration

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
820
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
8
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Monday, June 17, 13
  • 2. Introducing  Couchbase  Server  2.0Tugdual  GrallTechnical  EvangelistMonday, June 17, 13
  • 3. About  me...• Tugdual  “Tug”  Grall­ Couchbase• Technical  Evangelist­ eXo• CTO­ Oracle• Developer/Product  Manager­ Mainly  Java/SOA­ Developer  in  consulDng  firms• Web­  @tgrall­      hHp://blog.grallandco.com­      tgrall­ NantesJUG  co-­‐founder­ Pet  Project  :­ hHp://www.resultri.comMonday, June 17, 13
  • 4. RDBMS  are  not  Enough?Monday, June 17, 13
  • 5. Growth  is  the  New  Reality• Instagram  gained  nearly  1  million  users  overnight  when  then  expanded  to  AndroidMonday, June 17, 13
  • 6. Draw  Something  Viral  Growth191715131197533/12826242220181614121082/6Draw  Something  by  OMGPOPDaily  Ac)ve  Users  (millions)21246810121416Monday, June 17, 13
  • 7. RDBMS  is  good  for  many  thing,  but  hard  to  scaleRDBMS  Scales  UpGet  a  bigger,  more  complex  serverUsersApplicaNon  Scales  OutJust  add  more  commodity  web  serversUsersSystem  CostApplicaDon  Performance  RelaNonal  DatabaseWeb/App  Server  TierSystem  CostApplicaDon  Performance  Won’t  scale  beyond  this  pointHow  do  you  take  this  growth?Monday, June 17, 13
  • 8. Web/App  Server  TierMemcached  TierMySQL  TierScaling  out  RDBMS• Run  Many  SQL  Servers• Data  could  be  shared­ Done  by  the  applicaDon  code• Caching  for  faster  response  NmeMonday, June 17, 13
  • 9. Scaling  out  flaWens  the  cost  and  performance  curvesNoSQL  Database  Scales  OutCost  and  performance  mirrors  app  NerUsersNoSQL  Distributed  Data  StoreWeb/App  Server  TierApplicaNon  Scales  OutJust  add  more  commodity  web  serversUsersSystem  CostApplicaDon  Performance  ApplicaDon  Performance  System  CostNoSQL  Technology  Scales  OutMonday, June 17, 13
  • 10. Building  new  database  to  answer  the  following  requirementsNo  schema  required  before  inserDng  dataNo  schema  change  required  to  change  data  formatAuto-­‐sharding  without  applicaDon  parDcipaDonDistributed  queriesIntegrated  main  memory  cachingData  synchronizaDon  (  mulD-­‐datacenter)DynamoOctober  2007CassandraAugust  2008BigtableNovember  2006VoldemortFebruary  2009Very  few  organizaNons  want  to  (fewer  can)  build  and  maintain  database  so[ware  technology.But  every  organizaNon  building  interacNve  web  applicaNons  needs  this  technology.A  New  Technology?Monday, June 17, 13
  • 11. Lack  of  flexibility/rigid  schemasInability  to  scale  out  data Performance  challenges Cost All  of  these Other49%35%29%16%12%11%What  Is  Biggest  Data  Management  Problem  Driving  Use  of  NoSQL  in  Coming  Year?Source:  Couchbase  Survey,  December  2011,  n  =  1351.Monday, June 17, 13
  • 12. NoSQL  CatalogKey-­‐ValueMemcachedMembaseRedisData  Structure Document Column GraphMongoDBCouchbase CassandraCache(memory  only)Database(memory/disk)Neo4jHBase InfiniteGraphCoherenceMonday, June 17, 13
  • 13. Couchbase  ServerNoSQL  Document  DatabaseMonday, June 17, 13
  • 14. Couchbase  Open  Source  Project• Leading  NoSQL  database  project  focused  on  distributed  database  technology  and  surrounding  ecosystem• Supports  both  key-­‐value  and  document-­‐oriented  use  cases• All  components  are  available  under  the  Apache  2.0  Public  License• Obtained  as  packaged  soiware  in  both  enterprise  and  community  ediDons. CouchbaseOpen Source ProjectMonday, June 17, 13
  • 15. Easy  Scalability Consistent  High  PerformanceAlways  On  24x365Grow  cluster  without  applicaDon  changes,  without  downDme  with  a  single  clickConsistent  sub-­‐millisecond  read  and  write  response  Dmes  with  consistent  high  throughputNo  downDme  for  soiware  upgrades,  hardware  maintenance,  etc.Flexible  Data  ModelJSON  document  model  with  no  fixed  schema.Couchbase  ServerMonday, June 17, 13
  • 16. Flexible  Data  Model• No  need  to  worry  about  the  database  when  changing  your  applicaDon• Records  can  have  different  structures,  there  is  no  fixed  schema• Allows  painless  data  model  changes  for  rapid  applicaDon  development  {        “ID”:  1,        “FIRST”:  “DipN”,        “LAST”:  “Borkar”,        “ZIP”:  “94040”,        “CITY”:  “MV”,        “STATE”:  “CA”}JSONJSONJSON JSONMonday, June 17, 13
  • 17. AddiDonal  Couchbase  Server  FeaturesBuilt-­‐in  clustering  –  All  nodes  equalData  replicaDon  with  auto-­‐failoverZero-­‐downDme  maintenance  Built-­‐in  managed  cachedAppend-­‐only  storage  layerOnline  compacDonMonitoring  and  admin  API  &  UISDK  for  a  variety  of  languagesMonday, June 17, 13
  • 18. Market  AdopDon  –  CustomersInternet  Companies EnterprisesMonday, June 17, 13
  • 19. HeartbeatProcess  monitorGlobal  singleton  supervisorConfiguraDon  manageron  each  nodeRebalance  orchestratorNode  health  monitorone  per  clustervBucket  state  and  replicaDon  managerhFpREST  management  API/Web  UIHTTP8091Erlang  port  mapper4369Distributed  Erlang21100  -­‐  21199Erlang/OTPstorage  interfaceCouchbase  EP  Engine11210Memcapable    2.0Moxi11211Memcapable    1.0MemcachedNew  Persistence  Layer8092Query  APIQuery  EngineData  Manager Cluster  ManagerCouchbase  Server  ArchitectureMonday, June 17, 13
  • 20. HeartbeatProcess  monitorGlobal  singleton  supervisorConfiguraDon  manageron  each  nodeRebalance  orchestratorNode  health  monitorone  per  clustervBucket  state  and  replicaDon  managerhFpREST  management  API/Web  UIHTTP8091Erlang  port  mapper4369Distributed  Erlang21100  -­‐  21199Erlang/OTPstorage  interfaceCouchbase  EP  Engine11210Memcapable    2.0Moxi11211Memcapable    1.0MemcachedNew  Persistence  Layer8092Query  APIQuery  EngineCouchbase  Server  ArchitectureMonday, June 17, 13
  • 21. Couchbase  OperaDonsMonday, June 17, 13
  • 22. 33 2Single  node  -­‐  Couchbase  Write  OperaDonManaged  CacheDisk  QueueDiskReplicaDon  QueueApp  ServerCouchbase  Server  NodeDoc  1Doc  1Doc  1To  other  nodeMonday, June 17, 13
  • 23. COUCHBASE  SERVER    CLUSTERBasic  OperaDon• Docs  distributed  evenly  across  servers  • Each  server  stores  both  acPve  and  replica  docsOnly  one  server  acDve  at  a  Dme• Client  library  provides  app  with  simple  interface  to  database• Cluster  map  provides  map  to  which  server  doc  is  onApp  never  needs  to  know• App  reads,  writes,  updates  docs• MulPple  app  servers  can  access  same  document  at  same  PmeUser  Configured  Replica  Count  =  1READ/WRITE/UPDATEACTIVESERVER  1ACTIVEDoc  4Doc  7DocDocDocSERVER  2Doc  8ACTIVEDoc  1Doc  2DocDocDocREPLICADoc  4Doc  1Doc  8DocDocDocREPLICADoc  6Doc  3Doc  2DocDocDocREPLICADoc  7Doc  9Doc  5DocDocDocSERVER  3Doc  6Doc  5Doc  2DocDocDocDoc  9APP  SERVER  1COUCHBASE  Client  LibraryCLUSTER  MAPCOUCHBASE  Client  LibraryCLUSTER  MAPAPP  SERVER  2Monday, June 17, 13
  • 24. Client  SDKwww.couchbase.com/developClojurePythonRubylibcouchbaseGoMonday, June 17, 13
  • 25. NPM{    "name": "my-node-application",    "version": "1.0.0",    "private": true,    "dependencies":    {        "express": "3.x",        "couchbase": "0.0.12",        "ejs": ">= 0.0.1"    }}Monday, June 17, 13
  • 26. Connect  to  the  clustervar driver = require(couchbase); dbConfiguration = {   "hosts": ["localhost:8091"],   "bucket": "ideas"}; driver.connect(dbConfiguration, function(err, cb) {   if (err) {      throw (err)   } // your application code here }Monday, June 17, 13
  • 27. Insert  Datavar meetup = {"type" : "meetup", "language" : "javascript"};cb.set("web5",meetup, function(err, meta) {}); var tmp = {"message" : "hello world!"};cb.set("tmp", tmp, {"expiry" : 5},function(err, meta) {});Monday, June 17, 13
  • 28. Insert  /  Delete  Datavar meetup = {"type" : "meetup", "language" : "javascript"};cb.set("barcelonajs",meetup, function(err, meta) {}); var tmp = {"message" : "hello world!"};cb.set("tmp", tmp, {"expiry" : 5},function(err, meta) {}); cb.set("todelete", tmp, function(err, meta) {});cb.remove("todelete", function(err, meta) {});Monday, June 17, 13
  • 29. Retrieve  the  Datacb.get("product:45", function(errs, doc, metas) {console.log("=== get the document ===");console.log( doc );});var keys = new Array();keys.push("product:1");keys.push("product:45");keys.push("product:65");keys.push("product:80");cb.get(keys, null, function(errs, docs, metas) {console.log("n=== get List of documents ===");console.log( docs );});Monday, June 17, 13
  • 30. Retrieve  the  DataWhat  if  I  want  all  products  or  meetups?key : barcelonajs{"type": "meetup","language": "javascript"}key : product:10{"type": "product","name": "Product with id 10"}Monday, June 17, 13
  • 31. Calling  a  view  from  your  appvar queryParams = {      stale: false,      key : "meetup"}; cb.view("my_views", "by_type", queryParams, function(err, view) {      var keys = new Array();      for (var i = 0; i < view.length; i++) {         keys.push(view[i].id);      }      cb.get(keys, null, function(errs, docs, metas) {         console.log(docs);      });   });Monday, June 17, 13
  • 32. Demo  TimeMonday, June 17, 13
  • 33. www.couchbase.com/downloadCouchbase  Server  Monday, June 17, 13
  • 34. Q  &  AMonday, June 17, 13
  • 35. Thank  you!tug@couchbase.com@tgrallGet  Couchbase  Server  at  hHp://www.couchbase.com/downloadMonday, June 17, 13
  • 36. Monday, June 17, 13