Over a million developers have joined DZone.

Introducting a MongoDB Replica Set Demonstration and Experimentation Service

· Database Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database. Try it now! Brought to you in partnership with MongoDB.

Greetings adventurers!

A lot of our users upgrade from single-node databases to replica set clusters without fully understanding how their driver, and therefore their application, will react to failover. In fact, we get so many questions about best practices with MongoDB replica sets that we thought it could be cool to host a replica set that anyone can connect to using their MongoDB driver of choice.

Today we invite you to check out flip-flop, a MongoDB Replica Set demonstration and experimentation service.  The flip-flop service consists of:

  • A live replica set that fails-over (i.e. “flips” and “flops”) every 60 seconds.  This cluster is always running and available to all at the following address:
Connection URI:
  • A set of example client scripts (currently just in Python) that simulate client interactions with the cluster that you can use as a starting point for your own experimentation

The flip-flop service is also great for those of you working on third-party drivers. Gustavo Niemeyer, author of mgo, a MongoDB driver for the Go language, told us flip-flop helped him find and quickly fix a small bug in the driver: “This is brilliant. I actually managed to find an edge case coding a trivial example against it due to the timing of the server re-election.” Pretty cool!

How to get started with flip-flop:

  1. Open http://mongolab.org/flip-flop in one window
  2. Download and run our sample Python script (requires pymongo 2.4+) in a second window
sudo pip install pymongo
curl https://gist.github.com/mongolab-org/5347810/raw/766f8266db377e462f90e5c1389be6211fbd2db6/watch-flip-flop.py > watch-flip-flop.py
python watch-flip-flop.py
  1. Watch this script gracefully recover from failover as the cluster flips and flops every 60 seconds.

We hope you all find this service informative and useful. As you play around with flip-flop, please do let us know what you think!


Your friends at MongoLab

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.


Published at DZone with permission of Dave Walker. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}