Home > couchdb-uuidAlgBalance

couchdb-uuidAlgBalance

Couchdb-uuidAlgBalance is a project mainly written in JavaScript, it's free.

A poorly named experiment to see how you can distribute work among consumers based on CouchDB generated IDs.

Usage

node ./main.js [number of consumers]

Example: node ./main.js 3

The General Idea

Let's say you have a bunch of consumers polling a changes feed. You want to divide the work between the consumers evenly, so you decide to base it on the documents' _id since they are just big hexidecimal numbers.

Flow

  • Take in the results of /_uuids (from a file)
  • Grab the last 4 characters of each id
  • Converts that hex number to decimal
  • Take the remainder of that decimal number divided by the number of nodes
  • Output distribution
Previous:ai-class