Ayende @ Rahien

Hi!
My name is Ayende Rahien
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

@

Posts: 5,947 | Comments: 44,540

filter by tags archive

RavenDB Multi Tenancy


Originally posted at 11/27/2010

One of the features that people asked for RavenDB is the notion of multi tenancy. The idea is that I can (easily) create a new database (there is the RavenDB Server, and the server contains Databases, which contain indexes and documents) for each tenant. As you can imagine from the feature name, while it is actually an implementation of several databases on the same server, the usage goal is to have this for different tenants. As such, the RavenDB implementation is aimed to handle that exact scenario.

As such, it is expected that some users will have hundreds / thousands of databases on a single instance (think shared hosting or hosted raven). In order to support this, we need to have a good handle on our resources.

RavenDB handles this scenario by loading databases on demand, and unloading them again when they aren’t used for a long enough period. Using this approach, the only databases that consume resources are the ones actually being used.

In order to use the multi tenancy features, all you need to do is call:

documentStore.DatabaseCommands.EnsureDatabaseExists("Northwind");

var northwindSession = documentStore.OpenSession("Northwind");

You can now work in a separate database from all other databases, with no potential for data to leak from one tenant to another. Creating a database on the fly s a very cheap operation, as well, so you can create as many of them as you want.


Comments

Scooletz

If creating dbs is so cheap, do you aim at creating task databases for some processes and delete them afterward?

Ayende Rahien

Scooletz,

Can you give me a good idea about what you want exactly?

Please note that there is no facility to delete a database. You can make it inaccessible, but not delete it.

Shawn

I looked but couldn't find any mention elsewhere -- I realize that this competes to an extent with Table Storage, but do you have any plans for this to be hostable as an Azure Worker Role? You might be able to use a CloudDrive for your persistent storage, but I'm not sure about performance.

Scooletz

@Ayende,

what I meant was using so-called temporary Raven db as a source for running Map/Reduces after filling it with data. With temporary, in-memory indexes feature in mind, it seems to allow you to easy work with that kind of task, doesn't? Am I missing sth?

Chris Wright

How does this work with the REST API? Any idea how many people are using that rather than the C# client?

Ayende Rahien

Shawn,

RavenDB works on Azure, yes.

Ayende Rahien

Scooletz,

Yes, that one would be very easy to do, then.

You can create a database in memory, which would fit what you want

Ayende Rahien

Chris,

I'll talk about this in my next post

Tony

Is it possible to create indexes in only one database? At the moment i use the following code to create indexes:

IndexCreation.CreateIndexes(typeof(My_Index).Assembly, container.Resolve <idocumentstore());

is this method of creating indexes obsolete/bad practice?

Ayende Rahien

Tony,

I just fixed this bug, will be up in the new build

Tony

@Ayende

Thanks for that, does this fix also cover DeleteByIndex too?

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. RavenDB Sharding (2):
    21 May 2015 - Adding a new shard to an existing cluster, the easy way
  2. The RavenDB Comic Strip (2):
    20 May 2015 - Part II – a team in trouble!
  3. Challenge (45):
    28 Apr 2015 - What is the meaning of this change?
  4. Interview question (2):
    30 Mar 2015 - fix the index
  5. Excerpts from the RavenDB Performance team report (20):
    20 Feb 2015 - Optimizing Compare – The circle of life (a post-mortem)
View all series

RECENT COMMENTS

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats