How I Scrapped MySQL for MongoDB in Three Hours

Mike Borozdin, August 15th, 2011

MongoLabLast weekend at the AT&T Mobile Hackathon I had a pleasure of checking out the MongoLab’s MongoDB service.  In short: it was a delight to work with.  I fell in love with that technology.  It worked exactly the way I thought–MongoDB architects got it right. After spending a good part of the day fighting my hibernate configuration in JUnit I was pleasantly surprised when I saw that Mongo keeps their documentation and design accessible with plan old object and simple REST calls to its MongoLab API.

MongoLab makes creating a MongoDB super easy.  You can sign up for a dev account and within minutes get an instance that will hold up to 240MB of data.  It’s perfect for a prototype. In 15 minutes I was up and running and had my unit test executing flawlessly. It took a couple of more hours to refactor the application to move my serialization from MySQL + Hibernate to MongoDB.  In a total of three hours the port was complete.

The web interface on MongoDB made it easy to see if my app was serializing data correctly.  I created one collection for Unit Test and another collection for my production data. Collections can be limited in the number of records so they wouldn’t flood my account with test data.

MongoLab Admin View

Working with Mongo right after working with Hibernate and MySQL made me realize something.  In 2000-2007 we built up some complicated protocols and frameworks. The last couple of year the simplicity seems to have taken off.  A lot of people wrote off Java because of the complexities, but I can tell you that Spring+Annotations and MongoDB brings the joy back to Java web development again.

Both comments and pings are currently closed.

11 Responses to “How I Scrapped MySQL for MongoDB in Three Hours”

August 15th, 2011
at 11:32 pm
Comment by: EllisGL

I want to love MongoDB, but there are several issues I have with it.

1.) Security. You can password protect against writes, but you can read with out having authed against it.

2.) No built in joins, you have to do this external. You can do with CouchDB.

3.) No Master/Master replication. Only Master/Slave.

August 16th, 2011
at 12:50 pm
Comment by: Mike B.

are you sure you can read without a password? It seems like there is a password on connection in my tests. I assumed that prevents reads and writes.

Have you tested the version deployed by MongoLab?

August 16th, 2011
at 10:38 pm
Comment by: Will Shulman

You need to authenticate to read or write.

August 19th, 2011
at 10:52 am
Comment by: InfiniteGraph Wants You to Connect the Dots and Win Big Prizes

[...] databases are all the rage these days. We recently discussed moving from MySQL to MongoDB within hours. The rise of NoSQL is often associated with the need to not just store large amounts [...]

August 20th, 2011
at 6:57 pm
Comment by: Links for August 16th through August 20th — Vinny Carpenter's blog

[...] How I Scrapped MySQL for MongoDB in Three Hours – I can tell you that Spring+Annotations and MongoDB brings the joy back to Java web development again [...]

August 21st, 2011
at 8:01 am
Comment by: 45 New APIs: MongoDB, Podcast Retrieval, Skyscanner

[...] week we had 45 new APIs added to our API directory including a hosted MongoDB database, live chat platform, fact sharing service, podcast retrieval service, distributed graph database, [...]

August 26th, 2011
at 7:49 am
Comment by: Java Technologies Hibernate 4 Projects |

[...] How I Scrapped MySQL for MongoDB in Three Hours (programmableweb.com) [...]

June 14th, 2012
at 7:27 am
Comment by: Converting to MongoDB » Agile Mobile Developer

[...] Converting to MongoDB  Java, MongoDB, NOSQL, Spring  Add comments Jun 102012   http://blog.programmableweb.com/2011/08/15/how-i-scrapped-mysql-for-mongodb-in-three-hours/ [...]

July 26th, 2012
at 2:26 pm
Comment by: Andrew

If you were using Ruby, you could have quickly moved your mySQL data to MongoDB by using Mongify (http://mongify.com/)

It’s a super simple way to transform your data from a RDBS to MongoDB without losing anything.

Mongify will read your mysql database, build a translation file for you and all you have to do is map how you want your data transformed.

It supports:

* Updating internal IDs (to BSON ObjectID)
* Updating referencing IDs
* Type Casting values
* Embedding Tables into other documents
* Before filters (to change data manually)
* and much much more…

Read more about it at: http://mongify.com/getting_started.html

There is also a short 5 min video on the homepage that shows you how easy it is.

November 19th, 2012
at 6:52 am
Comment by: Lela

Right here is the right blog for everyone who would like to understand this topic.
You understand so much its almost hard to argue with you (not
that I personally would want to…HaHa). You certainly put a
fresh spin on a topic that’s been written about for decades. Great stuff, just excellent!

December 6th, 2012
at 6:19 am
Comment by: ellayararwhy

You’re probably not counting the several ours it took you to sit in on sessions learning Mongo, but I can tell you from firsthand experience with Mongo that a 3 hour port tells me that your application is extremely simple.

Your application probably has only a dozen tables, no functions, no stored procedures, no complicated relationships, queries or joins. A real production backend will have all those things and require many man months to do a basic Mongo migration, all of the debug required and the necessary performance tuning and learning along the way, interspersed with finding forums like these that explain how to get yourself out of the trouble you got yourself into. We eventually paid to have two 10Gen techies come in for a day to help us out in establishing new guidelines and best practices for managing Mongo with our very large legacy application. In other words, we had to redesign parts of our Mongo adapters per their recommendations, adding more time and effort to the already extended project.

I’m not complaining, but I’m outlining for everybody what realistically to expect

Follow the PW team on Twitter

ProgrammableWeb
APIs, mashups and code. Because the world's your programmable oyster.

John Musser
Founder, ProgrammableWeb

Adam DuVander
Executive Editor, ProgrammableWeb. Author, Map Scripting 101. Lover, APIs.