You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Michael Beam <mi...@mac.com> on 2010/08/02 20:03:35 UTC

Appropriate use of batch=ok?

Hi All,

CouchDB is used throughout an application that I work on, and I was thinking of using it for a new implementation of an old feature. The feature involves other applications reporting progress of "jobs" to a progress DB via documents that look like:

{
  "_id":"a8baaee7963b4ee5893f0120514c4294",
  "_rev":"35-8735bcf3c66945932acb4d573166f741",
  "progress":0.87
}

Since there may be potentially hundreds of processes updating their progress docs relatively frequently (say, one update every 10 seconds, maybe longer, maybe much longer) I figured this would be an ideal use case for batch=ok in the PUT request that applications use to update their job's progress to the database. However, I discovered that the rev is not returned (which makes sense), which  means that for an app to update it's progress doc, it needs to get the rev through a separate HEAD request.

In terms of overall load on the server, is anything gained by doing lots of updates via HEAD/PUT-batch=ok versus a standard PUT?  Or, am I missing some other relevant aspect of Couch in my analysis of the problem?

Thanks in advance,

Mike



Re: Appropriate use of batch=ok?

Posted by J Chris Anderson <jc...@apache.org>.
On Aug 2, 2010, at 11:03 AM, Michael Beam wrote:

> Hi All,
> 
> CouchDB is used throughout an application that I work on, and I was thinking of using it for a new implementation of an old feature. The feature involves other applications reporting progress of "jobs" to a progress DB via documents that look like:
> 
> {
>  "_id":"a8baaee7963b4ee5893f0120514c4294",
>  "_rev":"35-8735bcf3c66945932acb4d573166f741",
>  "progress":0.87
> }
> 
> Since there may be potentially hundreds of processes updating their progress docs relatively frequently (say, one update every 10 seconds, maybe longer, maybe much longer) I figured this would be an ideal use case for batch=ok in the PUT request that applications use to update their job's progress to the database. However, I discovered that the rev is not returned (which makes sense), which  means that for an app to update it's progress doc, it needs to get the rev through a separate HEAD request.
> 
> In terms of overall load on the server, is anything gained by doing lots of updates via HEAD/PUT-batch=ok versus a standard PUT?  Or, am I missing some other relevant aspect of Couch in my analysis of the problem?
> 

batch=ok should really be renamed async=true

basically it allows a serial client to get really fast inserts, without changing the load profile for CouchDB.

In your case (where you need the rev) it is probably better to do a regular PUT (or to batch requests on the client and use bulk_docs)

Chris

> Thanks in advance,
> 
> Mike
> 
>