"lambda functions are neat. that is all."
- Mar 04 22:56 GMT 2010
The Super Awesome Blog of Malini Das
Welcome!

This site is still under construction, but I'm blogging on it anyway.

Feel free to follow me on Twitter


Tasty Blags:

The Quixotic Engineer

Powered by Django.
CouchDB-Lounge headaches
by nakubu at 2010-02-01 13:44:16

Anyone working with CouchDB for any large-scale project would probably like to be able to shard their database and/or use a cluster of couch instances. Those of you interested in doing this would most likely turn to CouchDB-Lounge. Unfortunately, getting Lounge to work is a huge pain in the ass. It took me a while to figure out why things weren't working, what packages I was missing and what code I had to alter (Lounge is not completely free of hardcoded configs!). There weren't too many useful sites out there, so this post is for all those out there struggling with CouchDB-Lounge and need some help. If I missed something, please comment.


Firstly, I'm assuming a fresh install of some Linux distro (I used ubuntu). Note: Configuring for OS X is different and apparently a bit harder to do for some reason. I was going down that path until I spoke with Randall Leeds (tilgovi, one of the Lounge devs) on the #couchdb IRC channel, and he warned me the install hasn't been properly tested on Macs, and more tweaking might be involved.


So, for dumbproxy to work, you need to download and compile json-c as directed on the Lounge wiki, but also remember to get the python-pyicu package. Once you get that running, read THIS. Fix this bug, otherwise, your nginx process will be running with the wrong config.


For smartproxy, you'll need python-cjson package, and for replicator, you'll need the pycurl package. I think I ran into more problems, but I'll check my logs and get back to this post in a bit.


Now here's the meat of the problem. After running this and setting up my shards.conf file to point to two couch instances on different ports, when I'd submit any request to the main lounge instance (running off port 6984), my requests were virtually ignored. So after running around reading the sparse documentation, the immense log files and reading the code, I found this line in replication_notifier.py:


me = 'http://' + socket.gethostname() + ':5984/' (line 40)


which retrieved my laptop name, and completely ignored my conf files! So it was effectively trying to use http://malini-laptop:5984 as the main couch instance, and my laptop name didn't resolve to 127.0.0.1, so my requests were shot to nowhere. In the end, I fixed this by adding another section in my local.ini conf file that contained the URL for the main couch instance, and I changed that line to pull from the conf file. Beware of this problem if your configuration points to anywhere but (hostname):5984!


Aside from configuration problems, Lounge does what it's supposed to do, which is pretty sweet. I hope this prevented people from wasting their time trying to figure out what was wrong with their configuration:)


Ou, as a side note, it might be useful for those using python-couchdb to modify Server's 'create' method. Lounge uses nginx, and the current python-couchdb (0.6.1) seems to assume you're running Apache or some other web server, since it currently sends no headers with the PUT request. Nginx throws up HTTP errors when it sees that there are no headers (it assumes it's a chunked request, which it does not handle), so I patched it to send:


self.resource.put(validate_dbname(name), headers={'Content-Length':'0'}) [line 17]


This tells nginx that you're simply making a PUT request with no data.


0 comment(s)

Related tags:
couchdb, lounge, cluster, shard
Adventures in a New Land!
by nakubu at 2009-05-07 00:38:15

So I am now in San Francisco.

I'm here on an internship, doing more web development! But instead of Python/Django, it's PHP/Zend. You'd think it would be a pretty easy transition from one MVC web framework to another, but that was not the case! For one thing, Django's cute little ORM spoiled me:(

Zend is a very powerful tool with great libraries, but that fact is not easily recognizable to a beginner. For those who want to get the gist of this framework by running through the QuickStart, good luck to you. Really. I've also been spoiled by Django's amazing Tutorial and Documentation. The QuickStart changed drastically over the last two weeks, due to the new Zend release. This should be good news, except, it's still unfinished. Yes, STILL. The last QuickStart guide had typos, left out information, and didn't use hypertext to its full potential:P Meaning, it was confusing, and you needed to delve into the heavy Zend Documentation to get a simple question answered. And yes, the new QuickStart guide is no better. It is shorter (...yay? I guess. A win for the impatient), but does not hold enough information. It just tells you what SOME lines of code do and what the Zend parser looks for, but it doesn't really go much into depth. It barely even scratches the surface. And there are still chunks of text missing (scroll to the bottom). So yeah. Have fun, beginners! :P

My recommendation to a beginner is, yes, run through the QuickStart, but don't expect many answers to it. All I really learned about Zend from the QuickStart was information regarding what Zend needs to know to parse code properly, and the structure of a normal web application. The real magic lies in the Zend library. I started playing with Zend_Db at work, and it's a pretty good tool. Try using the Zend_Db alone without a Mapper for one of your models. It will be a fun learning exercise that will help shape your Zend and database/querying skills. If you're a beginner to web development and are looking for a friendly, quick way to start a website, my recommendation to you is to skip PHP/Zend and check out Django. It's prettier and the docs are nicer. But maybe that's just my superficiality talking.


1 comment(s)

Related tags:
Django, Zend, PHP, Python, QuickStart, San Francisco
Yarrr Mateys, it be up.
by nakubu at 2009-01-11 17:15:54

Be ready for some posts with substance! Finally!


Yes, I know I don't have comments yet. And yes, I know that sucks. My Javascript/JQuery knowledge right now is close to zero. But I'm working on it!


0 comment(s)

Related tags:
first
Licensed under Creative Commons: Creative Commons License