Take the 2-minute tour ×

I've been looking for a good NoSQL database for some of our projects for quite some time and I recently discovered RavenDB which looks pretty awesome from a .NET support perspective, so I decided to try it out and write a little benchmark. First order of business was testing insert speed, using the following code:

class Program
    private const int TEST_COUNT = 10000;
    static void Main(string[] args)

        var store = new DocumentStore();
        store.Url = "http://localhost:8117";

        var timer = Stopwatch.StartNew();
        var session = store.OpenSession();
        for (var i = 0; i < TEST_COUNT; i++)
            session.Store(new TestEntity()
                Name = "Test Entity"

            if (i % 127 == 0)
                session = store.OpenSession();


        Console.WriteLine("Processed {0:n0} records", TEST_COUNT);
        Console.WriteLine("Time elapsed: {0:n0} ms", timer.ElapsedMilliseconds);
        Console.WriteLine("Records / sec: {0:n0}", TEST_COUNT / (timer.ElapsedMilliseconds / 1000d));

class TestEntity
    public string Name { get; set; }
    public DateTime Created { get; set; }

    public TestEntity()
        Created = DateTime.UtcNow;

The output is as follows:

Processed 10,000 records
Time elapsed: 9,531 ms
Records / sec: 1,049
Press any key to continue . . .

This is on a relatively fast machine (3ghz, 2gb ram running Windows 7)

Call me crazy, but 1000 inserts / sec is horribly slow, especially for documents that contain a mere two fields. Is this to be expected? I know RavenDB is optimized for reads, not writes, but this is pretty bad.

share|improve this question
Did you allow for a warm up period, such that JIT and other startup activities were factored out? –  Jerry Bullard Aug 11 '11 at 14:33

1 Answer 1

up vote 8 down vote accepted

I don't know if you're going to get much faster than that due to the whole "optimised for reads, not write" thing.

But if you read through this thread there are some suggestions:

  • Batch up writes (which you are doing). I'm not sure you need to close and then re-open the session though, you should just be able to call SaveChanges()
  • Set the transaction mode to lazy (Raven/TransactionMode)
  • Do the imports asynchronously, i.e from several threads

One other thing you could try is the embedded mode, i.e change your session to

var documentStore = new DocumentStore { DataDirectory = "path/to/database/directory" };

This bypasses the HTTP traffic and inserts documents directly, see the docs for more info.

share|improve this answer
I did try all of these and the performance gain wasn't noticable. I guess RavenDB is just too slow for my usage scenarios (write heavy). I'll give you the answer anyway, but the issue is kind of unresolvable at this point. –  Chris Jul 8 '10 at 19:46
You might want to post this on the RavenDB mailing list groups.google.com/group/ravendb. I'm far from a RavenDB expert so you might get a better answer. –  Matt Warren Jul 9 '10 at 9:40
There was some performance tuning done for write heavy scenarios earlier in 2011. You would probably get better results now. –  Frank Schwieterman Aug 17 '11 at 20:14

Your Answer


