Calculate the disk size needed for an Event

We are playing around with a new projection for building report on different types, counts and the size of the events (our disk usage is through the roof)

The way we are calculating an estimate if disk usage is this function:

getSizeOfDataInBytes = (e) => {
return JSON.stringify(e).length;
}

Take the whole event, convert to a string, and .length is the number of bytes.
Now, I my guess is the data is being written in unicode, so I could take that into consideration, but the state we have coming out are no where near the actual size of the chunk files.

We did a clean load of an eventstore with some data.
Chunks files are 3.2gb
Are rough calculation is 900mb with the function above, so say we took unicode into consideration (2 bytes right?) we would still be well short of the 3.2gb.

Any thoughts on this, or I am on the wrong route for trying to do this from a projection?

I’m not an expert, but in my experience System events and Link events (which might not be part of your projection) can take up a lot of space. Especially if you are using stream-projections a lot and/or very rarely scavenge.

Julian,

I hadn’t really considered linkTo’s (yet). The first cut I am running is to get a rough idea of the footprint our actual events are eating.
It’s very rough, but is helping us where to look.

I created a feature request over at ES Github, but maybe it’s no scientific enough this approach: