Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,125 | Comments: 45,492

filter by tags archive

RavenDB Multi Tenancy

time to read 2 min | 312 words

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:


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.



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

Ayende Rahien


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.


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.



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


RavenDB works on Azure, yes.

Ayende Rahien


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


I'll talk about this in my next post


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


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



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

Comment preview

Comments have been closed on this topic.


  1. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - 13 hours from now
  2. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 4 days from now
  3. The design of RavenDB 4.0: Voron has a one track mind - 5 days from now
  4. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 6 days from now
  5. The design of RavenDB 4.0: Separation of indexes and documents - 7 days from now

And 11 more posts are pending...

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    05 May 2016 - Physically segregating collections
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats