| A couple ways: One you implement validation functions [1] on user databases to control what kind of data can be inserted into couch. These functions can only be changed by database admins, not users, so can act as a security mechanism controlling what goes in. As mentioned by others you can also implement a proxy. This doesn't have to interfere with sync functionality, you just have to make sure you proxy all the endpoints in the replication protocol [2]. Envoy [3] is one such proxy that essentially applies document level permissions to a CouchDB database without interfering with sync. If the goal is just to limit document size, or throttle clients trying to hammer the API, this doesn't even have to be a custom proxy, and reverse proxy with the needed control knobs (such as NGINX) will do. You can of course combine this with validation functions, using validations to ensure the everything that comes in is the right "shape" and using NGINX and it's ilk to apply throttling and sane request limits. At scale there's a decent chance you want a proxy in front of your Couch instance anyway, since Couch is truly multi-master, meaning you probably want to balance your clients across all your nodes anyway. [1] https://docs.couchdb.org/en/stable/ddocs/ddocs.html#validate...
[2] https://docs.couchdb.org/en/stable/replication/protocol.html...
[3] https://github.com/cloudant-labs/envoy |
I'm not sure about current time but previously it was a problem that couchdb file grow until some limit on filesystem and couchdb just crashed.
Start of the envoy readme: it's not battle tested or supported in any way. Also it doesn't do any validation apart from limiting permissions for different users.
It's easier to reimplement couchdb than to create smart proxy that will estimate is this query expensive or not.
I'm not saying about rate-limiting proxy or load-balancing to different backends which could be implemented on nginx or something else.