views:

613

answers:

3

I'm working on a small web application using the Python Flask framework. For a few happy weeks SQLAlchemy was a perfect fit for my needs. In the meantime I found out more about MongoDB, played with it locally and started thinking of using it instead of MySql along with SQLAlchemy.

Is this a good idea in terms of:

  1. Suitability. The project probably wont become 2nd Facebook, so I dont really need any scalability at all...
  2. Deployment. Is it more complicated to deploy a MongoDB enabled app, than a MySQL app?
  3. Anything else I need to know about Mongo and NoSql??
+6  A: 

To put it this way, it's better to do a small project and not know whether MongoDB is suitable or not, than doing a large project and not knowing whether MongoDB works for your application.

I would suggest you go the MongoDB route. You won't need to worry about SQL, rows, tables etc. Seeing it's a small web app, you should be able to easily switch to MySQL later if need be.

T.K.
What about deploying the project? Do the hosting companies provide MongoDB servers, like they do with MySQL?
ak
Very good advice in general.
Rex M
@ak plenty of hosting companies do support MongoDB but mostly only in VPS configurations - e.g. it's not common to see a web hotel plan with MongoDB yet.
Rex M
Lots of hosting options (MongoHQ, Dreamhost, EngineYard), see http://www.mongodb.org/display/DOCS/Hosting+Center
kristina
+1  A: 

I've got a few rails apps running on mongodb - I use mongohq.com for my database hosting and it's ridiculously easy to get it up and running (at least it is if you are using rails and heroku).

Anyway, I was asked by a friend if our small website needed mongodb and I said that it wouldn't do it any harm. MongoHQ is also cloud-based, which means it's got potential to be fast - I guess it all depends on how they manage their system though. I use a rails wrapper that lets you do relational associations through mongodb and perhaps python has the same thing - if your app does take off, you have the setup to handle it

stephenmurdoch
So in case of MongoHQ the database server will actually run on Amazon EC2 platform, right? And the application will run on some other machine, wherever I host it? Is it a common practice to have the database sever and the app sever running in different places? I believe that in this case the MongoDB response time wont be as good as the one of MySQL, which runs on the machine in the same network, or even on the app machine... Or am I missing the point?
ak
good question - my apps are hosted on AmazonS3 so it's advantageous to use the S3-hosted-database but if you're app is on a standalone server, then I'd probably try to find another way of getting mongodb setup - maybe see if you can install it on your server or something - but you always have mongohq as a fall-back if you want to play around or ever decide to start hosting your apps on S3 :)
stephenmurdoch
+8  A: 

Hobby web application == Best way to learn MongoDB.

I'll work the questions in order.

  1. Yes, MongoDB is suitable for projects that don't need to scale. In fact, MongoDB is a very good way to get small projects off the ground quickly. You do very little "DB configuration" work, especially when using PHP and Rails (though C# NoRM looks pretty simple too).
  2. Basically every web host will give you "free MySQL" databases as part of the package. Providers that offer MongoDB are harder to find, so it depends on your setup. If you have a Virtual Private Server, then setting up MongoDB should be easy. If you're on $20/month shared hosting, then you'll probably have to look at someone else to host the DB. The MongoDB site has a list of hosting providers as well as instructions for configuration on many popular cloud computing providers. You will pay a small premium for using MongoDB.
  3. Be prepared to "think different". If you've used SQL for a long time, you're probably used to thinking of all data as "relational" and accessible as "sets" (which is SQL's strength). You have to think of MongoDB as a hash table, good for single or small lookups. Be prepared to write some "client-side" for loops in your code. You'll need those to process data in arrays within an object.
Gates VP
Is it common to host the app and the database on different servers?Wont the response time grow up significantly?
ak
It depends. Most large-scale applications have separate DB and web servers, but they're usually close together. If your queries are running back and forth across the Internet, then it may be slow. But you'll have to test it. I was doing population from "home office", over a VPN to our distant data center and I was getting 3ms response times on a small MongoDB. Your "hobby app" is probably going to reach "awesome" before 3ms becomes a major problem. YMMV, but it's definitely possible.
Gates VP