atom feed1 message in org.apache.couchdb.userRe: Building substantial "pure" 2 tie...
FromSent OnAttachments
Jason SmithJul 11, 2011 7:06 pm 
Subject:Re: Building substantial "pure" 2 tier CouchApps - feasible?
From:Jason Smith (
Date:Jul 11, 2011 7:06:26 pm

tl;dr summary: It is practical using external processes to check in and keep things sane. This is very future-proof, but with a slightly longer time-to-market.

On Tue, Jul 12, 2011 at 6:18 AM, Andrew Stuart (SuperCoders) <> wrote:

I'd like to build a rather substantial application, it would be nice to build it as a pure 2 tier CouchApp.

Many have tried.

It is completely impractical to build a pure 2-tier Couch app. However, two tiers, plus external helpers ("2.1 tier") is very practical.

We've got some difficult days ahead. But it doesn't really matter with me now. Because I've been to the mountaintop. I don't mind. Like anybody, I would like to build a full-featured Couch app; scalability has its place. But I'm not concerned about that now. I just want to do God's will. And He's allowed me to go up to the mountain. And I've looked over. And I've seen the Promised Land. I may not get there with you. But I want you to know tonight, that we, as a people, will get to the Promised Land. So I'm happy, tonight. I'm not worried about anything. I'm not fearing any <span>.

What I prefer is this: Your programmers develop on and deploy to the Couch. Your users also interact directly with the Couch. However, *external agents* also access the couch and perform administrative tasks as needed.

The benefits of two-tier apps are obvious; I will list a few:

* Simpler * Reduced sysadmin workload * Excellent future-proofing: multi-datacenter, offline operation, run from an iPhone, etc.

Unfortunately, real-world apps are more than a pretty web page. To name a few:

* Send emails or other messages (e.g. push notifications) * Help users recover their password * Interface with related services: boot EC2 instances, update a DNS entry, generate an certificate * Notice that somebody is spamming and do the needful * Ops stuff: run backups, rotate logs, monitor services. Maybe that's an external responsibility; but IMO nowadays that is an application's self-hygeine * Catch unexpected errors, reassure the user, alert the staff

There is no alternative. You need a third component--admin stuff--to build a comprehensive service. But should that component be a blockade between your users and their data? Or should it work behind the scenes? Finally, note that external agents needn't have the same quality as middleware. An exception here or crash there is not devastating to the user experience. (Perhaps emails are delayed, or a backup is missed. That is better than 500 INTERNAL SERVER ERROR.)

I use NodeJS scripts to this end. For a few weeks, one such agent ran from my laptop, over DSL! Hey, it's HTTPS to a Couch in EC2. What does it matter? Similarly, our web site is compiled to static HTML by a couchapp. That app only runs on Chrome/OSX. I've no idea why, nor do I care. The "compiled" site supports all browsers and loads rather quickly (for EC2).