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,026 | Comments: 44,842

filter by tags archive

Raven Streams architecture thoughts: Storage

time to read 5 min | 890 words

Raven Streams is a working title.

So far, I have been working mostly on getting things working from an infrastructure perspective. That is, I want to be able to successfully write & read from the streams, and I have a general architecture for it.

Basically, we have something like this:


This is a single stream (of which we expect to have more than one, but not a very high number). The stream makes all writes to a mem table, backed by a log. When the mem table is full, we switch to a new memtable and write all the data to a sorted string table (SST). This is very much like the design of leveldb.

Internally, however, we represent all data as etags. That is, you don’t have an actual key that you can use, the stream will generate an etag for you. And the SST are sorted in order, so the oldest events are in the oldest file, etc.

On startup, if we haven’t flushed properly, we will translate the log file into a new SST and start from scratch. I am not sure yet if we want / need to implement compaction. Maybe we will do that for very small files only.

Right now there are two methods that you actually care about:

  • AppendAsync(data)
  • ReadFrom(etag)

This is how you use them:

   1: for (int i = 0; i < 15; i++)
   2: {
   3:     eventStream.AppendAsync(new RavenJObject { { "counter", i } }).Wait();
   4: }
   6: int x = 0;
   7: foreach (var item in eventStream.ReadFrom(Etag.Empty))
   8: {
   9:     var value = item.Value<int>("counter");
  10:     Assert.Equal(x++, value);
  11: }

This is all working pretty nicely right now. It isn’t nearly ready for production or even test usage, but this is encouraging. Next, I’ll discuss the intended implementation of map/reduce against this.


Daniel Marbach

Oren, why don't you just hire greg youngs event store team and use their knowledge to build blazing fast storage engine. Performance vise I doubt your solution can compete with that. Why reinvent the wheel?

Ayende Rahien

Daniel, Because we aren't talking about the same thing. I am not trying to create an event store.

Daniel Marbach

Yeah but you need fast and transactional appen only store or not? That is present there

Ayende Rahien

Daniel, Different things altogether. One append only store doesn't match the needs of another.

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats