Invitation to mongo db @ Rakuten TechTalk


Published on

My talk at Rakuten TechTalk 20140404.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Invitation to mongo db @ Rakuten TechTalk

  1. 1. Invitaion to MongoDB 2014 / 4 / 4 Rakuten techtalk ! Tamagawa Ryuji & Vagrant
  2. 2. About Me Ryuji Tamagawa@facebook tamagawa_ryuji@twitter Software Developer working in Osaka Translator (for O’Reilly) Famous for Rakuten Technology Bronze Award @ 2010
  3. 3. Agenda What is MongoDB ? Try MongoDB using Vagrant About Vagrant and Why is it is useful for hands-on
  4. 4. What is MongoDB ? Hybrid of NoSQL and RDB Stores JSON document as ‘BSON’ Capped collection : Log storage made easy Has Seconday Index ( on any part of JSON Doc), Query Optimizer, GeoLocation index Replication, Sharding ready Drivers in lots of languages … and many more. Rich.
  5. 5. JavaScript based queries Queries written in JavaScript. ex){'_id': product['id']}).sort( {details.m odel_num: -1}).limit(12) If possible, the optimizer automatically uses an index to accelerate Secondary index can be made on deep elements of the documents { _id: ObjectId(“…”), ! sku: "9092",! details: {
 model_num: 4039283402, ! manufacturer: "Acme", ! manufacturer_id: 432, ! color: "Green"! } ! }! details.color can be indexed
  6. 6. ! Schemalessness : pros and cons MongoDB stores JSON : You don’t have to define schemas beforehand Good for prototyping, document-like data Could be dangerous : may lead to degrade, tests & CI are answers ( to some extent ) ?
  7. 7. Browser(AngularJS) The Trend for Web App : 
 MEAN Stack MongoDB (JSON Storage) Express 
 (Web Application Framework for Node.js) AngularJS 
 (JavaScript framework for Web Client) Node.js 
 (JavaScript powered Web Server) And more… Twitter Bootstrap (CSS Framework) DOM Model(JSON) Express & Node.js 2way data bind
  8. 8. ReplicaSet : Availability & Scalability for reads Automatic Failover Setup is very easy Can write to Primary only Can read from any nodes Primary Node Secondary Node Secondary Node heartbeats replication
  9. 9. ReplicaSet : When primary failed One of the Secondaries will take over the Primary role Writing to the ReplicaSet once returns error, then next write will be succeed. The driver take care of dirty-hand jobs of reconnection Primary Node Primary Node Secondary Node heartbeats replication
  10. 10. ReplicaSet : When the node returned Rejoin to the ReplicaSet as a Secondary node Data recovery will be handled transparently to the user (hopefully) Secondary Node Primary Node Secondary Node heartbeats replication
  11. 11. Primary Node Sharding : Scalability for writes Scales write performance Mongos routes requests according to the value of shard key Availability gets lower : Normaly used with ReplicaSet Choose shard key so that the write requests are distributed among the shards Primary Node replication Shard 1 Primary Node Primary Node Shard 2 Primary Node Primary Node Shard N mongos (router)
  12. 12. Playground of MongoDB ReplicaSet mongodb_replicaset_playground_on_vagrant Clone the repository and ‘vagrant up’, then you are ready to try for MongoDB Replicaset
  13. 13. About Vagrant 
 and Why is it is useful for hands-on It often happens … You wrote a perfect scenario for the meetup You confirmed that the scenario ‘works perfect on your machine’ :) At the meetup, you found that many attendee says ‘It doesn’t work on my machine’ :(
  14. 14. Here comes Vagrant
 to the RESQUE ! Hands-on goes inside ‘clean’ virtual machines 
 - no more ‘it worked on my machine’ problem Only Vagrant and VirtualBox are needed before hands-on
 (they’re extremely easy to setup!) Configurations and provisioning scripts can be managed with SCMs like Git
  15. 15. Thanks for listening ! Upcoming Titles ( and talk ? ) : September : Test driven Infrastructure with Chef December : Selenium Web Driver practical guide