About Me Ryuji Tamagawa@facebook tamagawa_ryuji@twitter Software Developer working in Osaka Translator (for O’Reilly) Famous for Rakuten Technology Bronze Award @ 2010
Agenda What is MongoDB ? Try MongoDB using Vagrant About Vagrant and Why is it is useful for hands-on
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.
! 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 ) ?
ReplicaSet : Availability & Scalability for reads replication Automatic Failover Primary Node Setup is very easy heartbeats Secondary Secondary Can write to Primary only Node Node Can read from any nodes
ReplicaSet : When primary failed One of the Secondaries will take over the Primary role Primary Node Writing to the ReplicaSet heartbeats once returns error, then Primary Secondary next write will be succeed. Node Node The driver take care of dirty-hand jobs of reconnection replication
ReplicaSet : When the node returned Secondary Rejoin to the ReplicaSet as Node a Secondary node heartbeats Data recovery will be Primary Secondary handled transparently to Node Node the user (hopefully) replication
Sharding : Scalability for writes Scales write performance replication Primar Primar Shard 1 y y Node Node Mongos routes requests according to the value of shard key Primar Primar Shard 2 y y mongos Node Node Availability gets lower : Normaly (router) used with ReplicaSet Choose shard key so that the write requests are distributed Primar Primar Shard N y y among the shards Node Node
Playground of MongoDB ReplicaSet https://bitbucket.org/tamagawa_ryuji/ mongodb_replicaset_playground_on_vagrant Clone the repository and ‘vagrant up’, then you are ready to try for MongoDB Replicaset
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’ :(
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
Thanks for listening ! Upcoming Titles ( and talk ? ) : September : Test driven Infrastructure with Chef December : Selenium Web Driver practical guide