Ayende @ Rahien

It's a girl

RavenDB MVC Profiler Support

I am not sure if you have noticed, but for the last few weeks, we have had a small tag on the top left side of the blog. Clicking on this would reveal the following information:

image

As you can see, generating the main page took 6 sessions and 8 calls to the RavenDB server. This reflect the fact that when building RaccoonBlog, we were far more focused on the architecture and paid very little attention to the actual performance of the system and mostly focus on being correct and architecturally sound.

I’ll point out that with no attention to performance, the new blog out performs the old blog quite handily.

We can dig a bit deeper into what is going on here:

image

As you can see, we have a list of requests made to the server, including all of the queries made. This make it quite easy to figure out what is actually going on. For bonus points, we can even dig deeper and look at an individual request:

image

From debugging stand point, it is incredibly helpful. From a performance optimization perspective, it is invaluable. This feature alone has been responsible for three different bug fixes (all of them very hard to figure out without it) and has guided us into several performance improvements for the blog.

We took the idea from the Mini MVC Profiler, I really liked the idea of that, but didn’t really like the code, so we set out to build Raven.Client.MvcIntegration.dll.

In your MVC application, you need to reference that assembly and:

  • In the Application_Start method, call Raven.Client.MvcIntegration.RavenProfiler.InitializeFor(documentStore).
  • In your main layout, include the following line: @Raven.Client.MvcIntegration.RavenProfiler.CurrentRequestSessions()

That would setup the RavenDB Profiler for MVC applications, giving you direct access to whatever is going on in that request. We even handle Ajax requests as well Smile

And a minor point as well, this feature is probably not something that you would use in production, but since I wanted to show it off for you, I made sure that it can be run in production. In order to facilitate this, there is a way to redact the information sent to the client, scrubbing it from any personal information. That has been done on this blog, but it is a fairly simple system, compromised mostly of the ability to black list specific fields by name. I would be careful when exposing this to the world, but especially if you are using this to see what is going on against a remote RavenDB instance, it can be invaluable tool.

Tags:

Posted By: Ayende Rahien

Published at

Originally posted at

Comments

configurator
07/18/2011 09:44 AM by
configurator

One of the requests is to /databases/blog.ayende.com/indexes/Posts/ByMonthPublished/Count , but has two sort parameters. Does this affect performance in any way in raven?

Matt Warren
07/18/2011 10:07 AM by
Matt Warren

@configurator

Possibly on large datasets, but as that index is going to return at most 120 (12 * 10, for ~10 years of blog entires), I don't think it's a big problem. Lucene is pretty fast at searching and sorting.

Jerry
07/18/2011 12:02 PM by
Jerry

I like the Response Headers...

"Ayende:Is Awesome"

Daniel Lang
07/18/2011 07:53 PM by
Daniel Lang

What about non-MVC application? How can they be profiled? Even for MVC application I would really like to have a standalone version too, because someone (like me) might want to start the profiler on a running production server and monitor database-usage "live"...

With NHProfiler I do this quite often for production servers and would like to do that with Raven too.

Rob Ashton
07/18/2011 09:39 PM by
Rob Ashton

"When building RavenDB"

You mean "When building Racoonblog" surely? One would rather hope that performance was cared about when building RavenDB ;-)

Ayende Rahien
07/18/2011 10:58 PM by
Ayende Rahien

Configurator, It doesn't really matter, really. Sorting has some additional cost, of course, but that is about it.

Ayende Rahien
07/18/2011 11:00 PM by
Ayende Rahien

Daniel, For non MVC apps, we have a debugger visualizer, and we probably will have something more in the future.

Ayende Rahien
07/18/2011 11:01 PM by
Ayende Rahien

Rob, Um, yes. :-) I actually get them confused on a regular basis, thanks, I fixed that.

Daniel Lang
07/18/2011 11:08 PM by
Daniel Lang

Ayende, Please let us know, when "RVProfiler" is ready, but I have no doubt you won't... Beside that, there seem to be some issues with your blog: the comments dates are completely wrong (in the future) and your nick also links to ayende.com/blog/blog.

Jeff
07/19/2011 06:16 PM by
Jeff

How do you scale RavenDb horizontally? Can you? If you need to add node to a cluster, are the clients aware of the change?

Anonymious
07/19/2011 06:37 PM by
Anonymious

Is this available on Nuget?

Ayende Rahien
07/20/2011 08:42 PM by
Ayende Rahien

Jeff, RavenDB supports sharding OOTB. You need to using ShardingDocumentStore instead of DocumentStore, but except for that, it is the same for all client code.

Ayende Rahien
07/20/2011 08:43 PM by
Ayende Rahien

Anonymious, Not yet, will be in the next stable build

Jeff
07/21/2011 06:38 AM by
Jeff

@Ayende - thanks, I have some more questions, but I'll take them offline and send you an email if that's ok.

Ayende Rahien
07/23/2011 12:18 AM by
Ayende Rahien

Daniel, Thanks, this is now fixed

Matt
08/12/2011 01:05 PM by
Matt

Great little tool.

I had a page with three html tables on, all using the same query result (displaying 'published', 'draft' and 'trashed' posts) and only the one query in my controller. I thought I had it running as efficiently as possible, but having setup the profiler I noticed it was actually making three GET requests to raven. After a little investigation I discovered calling ToList() on my query results reduced those requests down to the one I was expecting.

I would've never noticed those three requests if it weren't for the profiler. Thanks for the great work.

Ayende Rahien
08/15/2011 12:55 AM by
Ayende Rahien

Matt, Yep, that is exactly the idea. To make sure that you are aware about what is going on in your application, and make it EASY

Comments have been closed on this topic.