couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Ananich <anton.anan...@inpun.com>
Subject Multitenancy
Date Mon, 15 Sep 2014 13:06:11 GMT
Hi!

=== The Story ===

I use a single CouchDB server with an application in a design doc to
provide cloud solution to a range of customers. Each customer has a
separate database, this way client data is isolated. I use a custom view
server which allow to create design doc with code written in Java.

And here I've got a problem. I found that CouchDB resets the view server
each time it needs to switch from one database to another. And that becomes
a performance hit, but also it causes memory leak because after libraries
are loaded, the memory allocated to compiled code is never freed.

=== What Have We Tried to Do ===

Our idea is to launch a view server instance per a database in order to
isolate each client's code from each other.

So we started to read source code and found that CouchDB reset the state of
view server each time it needs. Here is the link to sourrce code where it
happens:
https://github.com/apache/couchdb/blob/1.6.x/src/couch_mrview/src/couch_mrview_updater.erl#L136

And also we found that there are two implementations of "map_doc":
1)
https://github.com/apache/couchdb/blob/1.6.x/src/couch_mrview/src/couch_mrview_updater.erl#L127
2)
https://github.com/apache/couchdb/blob/1.6.x/src/couchdb/couch_query_servers.erl#L64

That's quite confusing, so we decided to ask developers why is it so.

=== The Questions ===

1) Is there a way to launch several view servers, one per database?
2) If not, can you suggest a way for us to modify sources and allow that?
We are looking for a way that will be compatible with current architecture,
so it will be possible to push these changes to mainstream.

Thanks,
Anthony

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message