databaseriak

Using Riak KV for Multitenant Applications


The current Riak 2.0 API precedes buckets with types, thus it is quite hard to use with a Multitenant environment, meaning multiple applications accessing the same database, other databases allow this through Namespaces, e.g. is the Google App Engine Datastore, where each namespace are totally isolated from each other.

What could be the best work-around to have a multi-tenant Riak KV?


Solution

  • I'd suggest using bucket-types as an additional namespace https://www.tiot.jp/riak-docs/riak/kv/2.2.6/using/reference/bucket-types/#buckets-as-namespaces as this would allow you to give each tenant a namespace bucket-type and then they can create buckets and keys inside that bucket type namespace.

    To avoid people fishing on bucket-type to see if they can gain access to a different tenant's data, you can then extend this by creating users and granting exclusive permissions by bucket or bucket type https://www.tiot.jp/riak-docs/riak/kv/2.2.6/using/security/basics/#managing-permissions

    Using these two features together should allow a multi-tenant environment within the same Riak KV instance.