Query database size in RavenHQ

I decided to give RavenHQ a try and use it for our upcoming website (although it still hasn’t European instances available which sucks very much). I’m happy to pay for the service, but since a free plan is available I want to start with this one and upgrade to a paid when necessary.

The free plan is limited to 15MB and it has a hard storage limit, which means that you will get exceptions on write operations as soon as you hit this wall.

I don’t want my visitor to be the first to notice that when they try to leave a comment. I also don’t want to check the size regularly on my own. What I want is an email that tells me I should enter my credit card details and upgrade to a paid plan as soon as my database reaches 13MB or so.

To do so, I decided to check the database size upon startup and send myself an email when some threshold is reached.

Admittedly, it took me some time to figure how I can query the current size of the database… Here is the code – hopefully it will be useful for someone as well:

image

Edit: Jonathan Channon contacted me and told me that he has already done the same before. Actually, he has a more advanced approach and deletes old documents to stay withing the limit (I don’t want to do this but it’s interesting). Take a look at his blog post here: http://blog.jonathanchannon.com/2012/09/21/nancyfx-ravendb-nerddinner-and-me/

2 Responses to Query database size in RavenHQ

  1. Lorenzo Melato October 10, 2012 at 09:59 #

    Great tip. Thank you very much!

  2. Sean Kearon October 31, 2012 at 16:01 #

    Good tip, and +1 on no EU-only instances in RavenHQ sucking :( . Soon, hopefully though…

Leave a Reply