Book Image

Ruby and MongoDB Web Development Beginner's Guide

By : Gautam Rege
Book Image

Ruby and MongoDB Web Development Beginner's Guide

By: Gautam Rege

Overview of this book

<p>MongoDB is a high-performance, open source, schema-free document-oriented database. Ruby is an object- oriented scripting language. Ruby and MongoDB are an ideal partnership for building scalable web applications.<br /><br /><em>Ruby and MongoDB Web Development Beginner's Guide</em> is a fast-paced, hands-on guide to get started with web application development using Ruby and MongoDB. The book follows a practical approach, using clear and step-by-step instructions and examples in Ruby to demonstrate application development using MongoDB. <br /><br />The book starts by introducing the concepts of MongoDB. The book teaches everything right from the installation to creating objects, MongoDB internals, queries and Ruby Data Mappers. <br /><br />You will learn how to use various Ruby data mappers like Mongoid and MongoMapper to map Ruby objects to MongoDB documents.<br /><br />You will learn MongoDB features and deal with geo-spatial indexing with MongoDB and Scaling MongoDB. <br /><br />With its coverage of concepts and practical examples, <em>Ruby and MongoDB Web Development Beginner's Guide</em> is the right choice for Ruby developers to get started with developing websites with MongoDB as the database.</p>
Table of Contents (18 chapters)
Ruby and MongoDB Web Development Beginner's Guide
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Ensuring write consistency or "read your writes"


It's very important to ensure that the database is eventually consistent. As we shall soon see, MongoDB delays all writes to the disk because the disk's I/O is slow. Write consistency means that every time something is written to the database, the delayed write should not cause inconsistency when we read back the data. MongoDB ensures this consistency for every write operation and the updated value is always returned back in the read operation. This is important for a couple of reasons:

  • Ensuring you always get the latest updated data

  • Easy and consistent crash recovery

How does MongoDB use its memory-mapped storage engine?

MongoDB tries to be as efficient and fast as it can get. So, to cater to this, it uses memory-mapped files for storage. This is as fast as it can get with the disk I/O and system cache. As every operating system works with virtual memory, MongoDB leverages this and can effectively be as large as the virtual memory allows it...