Riyad Kalla
Riyad Kalla

Reputation: 10702

Can nginx be used to front sharded, HTTP-based resources?

Info

CouchDB is a RESTful, HTTP-based NoSQL datastore. Responses are sent back in simple JSON and it is capable of utilizing ETags in the generated responses to help caching servers tell if data has changed or not.

Question

Is it possible to use nginx to front a collection of CouchDB servers where each Couch server is a shard of a larger collection (and not replicas of each other) and have it determine the target shard based on a particular aspect of the query string?

Example Queries:

http://db.mysite.com?id=1
http://db.mysite.com?id=2

Shard Logic:

shard = ${id} % 2; // even/odd

This isn't a straight forward "load balancing" question because I would need the same requests to always end up at the same servers, but I am curious if this type of simple routing logic can be written into an nginx site configuration.

If it can be, what makes this solution so attractive is that you can then turn on nginx caching of the JSON responses from the Couch servers and have the entire setup nicely packaged up and deployed in a very capable and scalable manner.

Upvotes: 3

Views: 1247

Answers (1)

Robert Newson
Robert Newson

Reputation: 4631

You could cobble something together or you could use BigCouch (https://github.com/cloudant/bigcouch).

Upvotes: 1

Related Questions