Posts tagged mongodb
How to integrate Mongoengine into Pylons
0Integrating Mongoengine into Pylons is really quick and painless if you know where to put stuff.
Add your DB settings to your development.ini file
mongodb.host = host[,replHost2]
mongodb.port = port
mongodb.db = db_name
mongodb.username = uname
mongodb.password = pass
Connect to MongoDB in config/environment.ini
At the top, include Mongoengine
from mongoengine import connect
And at the bottom, just before we return, include the following line:
# Connect with Mongoengine
connect(config['mongodb.db'], host=config['mongodb.host'], port=int(config['mongodb.port']), username=config['mongodb.username'], password=config['mongodb.password'])
Add your models
Now we can create our models just like in the Mongoengine documentation.
Why your startup should be using MongoDB
8
Here's a hint. It isn't because it's better than (insert-your-brand-here)SQL. I'm not even going to address that debate right now. It simply has to do with product iteration.
I love MongoDB as a technology, but I'm not even going to argue this from a tech perspective. The point that I want to address here is pivoting. MongoDB scales, it shards, it map-reduces, yadda yadda yadda. I love it for those things, but for a seed-stage startup, it's single biggest asset is the fact that it is schema-less, and does it beautifully.
SQL is phenomenal for enforcing rigidity onto tightly defined problems. It's fast, mature, stable, and even a mediocre developer can JOIN their way out of a paper bag. Save it for your next government defense contract. Build your startup's tech on the assumption that your business premise will change, and that you need to be ready for it. Your data schema is a direct corollary with how you view your business' direction and tech goals. When you pivot, especially if it's a significant one, your data may no longer make sense in the context of that change. Give yourself room to breath. A schema-less data model is MUCH easier to adapt to rapidly changing requirements than a highly structured, rigidly enforced schema.
This advice applies equally to great solutions such as Cassandra, CouchDB, etc. Whatever your flavor is, make sure to give yourself options. Use the most powerful and flexible technologies available to you. If a startup decided to develop their core technologies in C, under the pretenses that "It will handle more traffic per server," I'd laugh in their faces. You won't get that traffic if another company comes along and can crank out better features, and ten times faster than you. Pre-optimization is at the heart of all software evil, and it applies to data design as well. Bring SQL back into rotation after you've found your market, and a specific project calls for it. When you're first searching for that market, use the most flexible tools you can. Use tools that let you move fast, and allow you to salvage as much work as you can from efforts that dead-ended or required a pivot.
MongoDB Upstart service won’t start on Ubuntu (solved)
4Wow. Just spent wayyyy to much time chasing down an issue getting a MongoDB Upstart daemon up and running using mongodb-stable on Ubuntu 10.4. The short answer is that the DB daemon was uncleanly shut down at some point, and a lock file was lingering. That lock file prevented MongoDB from starting. The solution to this is relatively simple. The database needs to have a repair run on it, which will remove the lock file.
To run the repair:
mongod --repair
You may have to sudo that, depending upon your particular setup. More info about repair can be found here: http://www.mongodb.org/display/DOCS/Durability+and+Repair
If you aren't able to repair because you need a config file specified as well, you're going to have to manually repair each DB on your box.
- Forcibly remove the lock on your database:
sudo rm /var/lib/mongodb/mongodb.lock - Open up the Mongo shell and run
db.repairDatabase();for each db.
The long issue: Why is it impossible for me to find any useful resources on Upstart, a component of the 10.4 LTS Ubuntu distro? I found absolutely nothing indicating where I could find Upstart logs, or something to help me narrow the search. Good grief.
Note: Thanks to Mike Dirolf for offering a safer solution than my first one. This post has been updated as a result of that.
MongoDB now supports sharding
0Excuse my nerd freak-out, but this is really cool.
MongoDB is a great database system that combines a lot of the querying power with the flexibility and scalability of key-value stores. It's the DB I used in my Socialgraph system, and I fell in love with it really fast. It's incredibly easy to use, and requires much less rigidity than traditional SQL solutions.
I won't bore you with my extensive take one it, but suffice to say that I've used it before and absolutely love it. If you feel like SQL is slowing you down or holding you back, I'd really recommend giving MongoDB a trial.
The inclusion of production sharding in the MongoDB 1.6 release is big news because of the scalability that comes with it. If (fingers crossed) your product requires so much bandwidth that one server no longer cuts it, expansion is as simple as provisioning a new server, and letting MongoDB take care of the details. Goodbye app-level hacks and routing layers.
Announcing Socialgraph
0Socialgraph is an open-source project I just launched over the weekend that aims to be a server-to-client relationship visualization platform.
Rather than me trying to explain the whole thing, a picture is worth a thousand words, and an interactive demo is worth a million.
Seriously. Check it out.
