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";
store.Initialize();
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.SaveChanges();
session.Dispose();
session = store.OpenSession();
}
}
session.SaveChanges();
session.Dispose();
timer.Stop();
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.