Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Community Engine, our experience with MongoDB -...

mongodb
March 21, 2012

Community Engine, our experience with MongoDB - Mathieu Kempe, Community Engine

MongoDB Sydney 2012

This talk will cover lessons learned at Community Engine regarding MongoDB, including: why we moved away from an Hybrid solution using SQL and MongoDB; an outline of the technologies and what we learned using MongoDB on Amazon Web Services; the MongoDB C# driver; MongoDB with SOLR for Full Text Search; how we do migration, deployment and more.

mongodb

March 21, 2012
Tweet

More Decks by mongodb

Other Decks in Technology

Transcript

  1. Agenda Brain  dump  on  our  experience  with  MongoDB • Why

     NoSQL • Why  we  chose  MongoDB • Moving  away  from  an  hybrid  solu@on • MongoDB  and  Amazon • SOLR  and  MongoDB • Ease  of  development • Zero  down@me  database  deployment
  2. About  Community  Engine • Social  network  based  on  locality  and

      small  business • Launching  in  April • Built  on: •  ASP.NET  MVC  3 • Amazon  Web  services • MongoDB • SOLR • Mahout • …
  3. NoSQL? • How  to  store  the  big  amounts  of  data

     required   in  social  networking  applica@ons   • Data  complexity,  NoSQL  handle  hierarchical   and  graph  data  structures  beKer • Change  management  is  always  difficult  with   RDBMS • Scaling
  4. Why  we  chose  MongoDB? • Reviewed  different  products  RavenDB,  CouchDB...

    • Selected  MongoDB  because  we  had  the  best   experience – Very  easy  to  install  and  get  started – Great  developer  experience – Replica@on  very  easy  to  setup – Good  documenta@on – Much  of  the  convenience  of  SQL,  Dynamic  Queries,   Indexing
  5. Why Hybrid? • Team  had  a  lot  of  experience  with

     SQL  Server   and  En@ty  Framework • Repor@ng • Transac@on
  6. No more SQL Server • Simplify  our  infrastructure • Easier

     to  Backup • BeKer  performance,  not  slowed  down  by  SQL   Server,  too  many  queries  joined  in  the   applica@on • Development  speed • Lower  cost
  7. Transaction? Transac@ons  we  could  go  around  that  using  the  atomic

      document  updates  and  a  good  schema  design   MongoDB  supports  atomic  opera@ons  on  single   document. When  transac@ons  across  documents  are  needed Two  phase  commits
  8. Hosting with Amazon Web Service • Elas@city  and  scalability •

    Configure  MongoDB  using  Amazon  EC2  instance   bundled  into  an  AMI. • 64  bits  EC2  instance • Raid10  +  EBS  volumes • Mul@-­‐datacenter  3-­‐node  replica  set  in  different   availability  zone • Use  secondaries  for  zero  down@me  backup • We  are  not  yet  using  sharded  replica  sets
  9. Critical writes Verify  that  replica:on  is  working  at  write  :me

    mongodb://host1,host2,host3/?safe=true;w=2; • safe=true  :  Use  safemode • w=2:  wmode,  connect  to  a  replica  set  wai@ng  for   replica@on  to  succeed  on  the  majority  of  nodes
  10. Why we kept SOLR? • Right  tool  for  the  right

     job • Proven  technology • SOLR  best  solu@on  for  Full  Text  Indexing • Faceted  search,  Spelling  sugges@ons…   • Team  already  skilled  with  SOLR • SOLR  scales  well
  11. Mongo  Database  Schema Using  Type  discriminator { "_id"  :  ObjectId("4f504e7acd3e1c190ce04198"),

    "_t"  :  "PhotoSpark", "Photo"  :  "MyMotorcycle.png  "   "DateCreated"  :  ISODate("2012-­‐02-­‐24T09:23:12.246Z") } { "_id"  :  ObjectId("4f504e7ccd3e1c190ce04199"), "_t"  :  "PostSpark", "Body"  :  "Hello  World“   "  DateCreated"  :  ISODate("2012-­‐02-­‐28T10:44:12.858Z") }
  12. Deployment  of  database  with  zero   downtime • We  release

     every  week • We  aim  at  zero  downeme • Our  domain  model  change  ofen  
  13. Deployment  of  database  with  zero   downtime Make  sure  that

     our  code  can  handle  both   "versions"  of  the  data  structure When  saving  we  updates  to  the  new  structure