Skip to content
Aaronontheweb edited this page Sep 3, 2012 · 6 revisions

Hircine is a stand-alone RavenDB index builder used in continuous integration systems and automated deployments. Think of it like FluentMigrations, but for RavenDB indexes instead of SQL schemas.

Index building for RavenDB is a process that doesn't scale well traditionally because it's a blocking operation that happens on application startup typically.

If you have more than one RavenDB server or a large number of indexes you need to build, imagine just how long this could cause your ASP.NET app to spin while it executes Global.asax the first time!

Hircine solves this problem by moving the index building process to build time - that way your application's startup time and the state of RavenDB's indexes are fully decoupled from each other.

Working with Hircine

Hircine's goal is to give you a simple, fast solution for building RavenDB indexes on your servers independently of the execution of your application.

You'll be amazed at how much better your ASP.NET application performs when it doesn't try to build all of its indexes from Global.asax!

How RavenDB Indexes Are Built by the RavenDB Client

RavenDB indexes are C# classes which derive from Raven's AbstractIndexCreationTask object.

When the RavenDB client builds indexes on your remote server what it's really doing is taking instances of your index classes and serializes them over HTTP into a format that the remote RavenDB server can use to define a searchable / sortable index internally.

Most people typically use this method of the RavenDB client to build all of their indexes at once:

Raven.Client.Indexes.IndexCreation.CreateIndexes(typeof(SimpleIndex).Assembly, documentStore);

Where SimpleIndex is a type derived from AbstractIndexCreationTask and documentStore is an initialized IDocumentStore instance connecting to a live RavenDB database.

When this method is called, Raven iterates over all of the classes defined in SimpleIndex's assembly and creates instances of every type that is assignable from AbstractIndexCreationTask - once it has that full list of indexes, it synchronously builds those indexes against the IDocumentStore instance, which can be really slow and can even fail sometimes.

This is how RavenDB indexes are typically built and it's not an optimal solution. So let's see what Hircine does differently.

How RavenDB Indexes Are Built by Hircine

Hircine does things a little differently, but let's talk about what it has in common with the RavenDB Client approach:

  • Hircine also looks for index definitions contained inside user-defined .NET / C# assemblies.
  • Hircine uses the same method (ExecuteIndex) as the RavenDB client for building each individual index, so the instructions being sent to the RavenDB server are consistent with what the RavenDB Client does.

So what does Hircine do differently?

  • Hircine runs in its own stand-alone executable (hircine.exe), rather than inside your application.
  • Hircine can builds all of its indexes in parallel by default, using multiple HTTP requests and threads to get the job done faster.
  • Hircine can build indexes found in multiple user defined assemblies at the same time, rather than relying on successive calls to IndexCreation.CreateIndexes.
  • Hircine can build indexes against multiple RavenDB servers in parallel, rather than doing them one at a time like the RavenDB client.
Clone this wiki locally