Saturday, February 12, 2011

Realtime Performance Visualizations using Node.js

Preamble


This article outlines how to create a realtime heatmap of your syscall latency using HTML5, some great node modules, and DTrace. It was inspired by talk that Bryan Cantrill and Brendan Greg gave on Joyent's cool cloud analytics tools. While specific, the code provided could easily be adapted to provide a heatmap of any type of aggregation Dtrace is capable of providing.

System Requirements



First thing's first, you're going to need a system with DTrace. This likely means Solaris (or one of its decedents), OS X, or a BSD variant. There doesn't appear to be Dtrace available for Linux.

Security


Secondly, please be aware that at the time of writing the demo code contains a fairly substantial secruity vulnerabilty. Namely the d script is sent from the client with no authentication what so ever. If you bind to localhost this shouldn't be a big deal for a demo. Time permitting I intend to clean up the code.

Dependencies


For this tutorial you'll also need:

node - http://nodejs.org/#download (duh)
npm - https://github.com/isaacs/npm (makes installing modules a breeze)
node-libdtrace - https://github.com/bcantrill/node-libdtrace (provides dtrace functionality)
Socket.IO - 'npm install socket.io' (websockets made easy)

Server


Now we're ready to start writing our web server:

heat_tracer.js

Client


In order to display our heatmap, we're going to need some basic HTML with a canvas element:

heat_tracer.html

Finally the JavaScript client which translates the raw streaming data into pretty picture:

heat_tracer_client.js

Run It!


Run Heat Tacer with the following. Note, sudo is required by dtrace as it does kernal magic.

sudo node heat_tracer.js

If all goes well you should see a moving version of something like the image below.



Contribute


You can find the latest version of Heat Tracer here. It is my hope that this article will provide the ground work for a much more abitious performance analytics project. If you're interested in contributing please let me know.

Further Research


More information about Bryan and Brendan's demo can be found here
Socket.IO can be found here.

Labels: , , ,

2 Comments:

At March 22, 2012 at 4:27 AM , Blogger Interesting facts said...

I have no words for this great post such a awe-some information i got gathered. Thanks to Author.
youtube html5 player| html5 converter

 
At April 14, 2023 at 2:52 AM , Blogger Essien said...

Thanks for this marvelous Performance Visualization content. I really enjoyed reading it. I want to encourage you to continue the great job. Thank you so much for the great share and I’m extremely impressed with your writing skill. Once more thanks. uniabuja institute of education admission form

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home