Over a million developers have joined DZone.

Introducting a MongoDB Replica Set Demonstration and Experimentation Service

DZone's Guide to

Introducting a MongoDB Replica Set Demonstration and Experimentation Service

· Database Zone ·
Free Resource

MariaDB TX, proven in production and driven by the community, is a complete database solution for any and every enterprise — a modern database for modern applications.

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

MariaDB AX is an open source database for modern analytics: distributed, columnar and easy to use.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}