Tracking Down Performance Bottlenecks in Node.js with Meteor & StrongLoop

Please note that as of Aug 3, 2015, StrongOps has been EOL’d. Check out StrongLoop Arc for the same capabilities and more.

A few weeks ago our friend Matt Debergalis from Meteor reached out and said they’d been seeing intermittent slowdowns on Percolate Studio‘s AtmosphereJS, the package management system for Meteor packages. They could reproduce the problem with enough time and load on certain applications and suspected an issue of libuv or event loop interaction with the fibers infrastructure in Meteor. Could StrongLoop lend some of it’s expertise to help get to the root of the problem? To set about investigating, we worked with the Percolate team to leverage the pre-release version of lapse, an upcoming strong-agent feature.

Upon running with lapse for some time they were able to catch the problem. For now lapse creates a log file because we don’t yet have a visualization. In analyzing the log file, the critical portions I noticed looked like this:

Read more

Understanding the Node.js Event Loop

Ah, the great and crazy Node.js Event Loop. Often talked about, rarely intimately known. What does the Node event Loop do? What does it provide the programmer? Let’s dive in and talk about what the event loop is and does and how it can help you in your day to day development.

In the case of most pre-node Javascript, it existed in the browser and took user events manipulate the content of the rendered page in the browser. Manipulating these events were the only real interaction the code had. It was a single route of actions that the programmer had to deal with. Besides the DOM (that’s another whole discussion) the Javascript world on the browser side was relatively simple.
Read more

A Look at the Tech Behind the GlueCon Hackathon’s Node.js Winning App

A vehicle location hack powered by GM, Nexmo, and Cloud9

I had never been to Gluecon, but I had read good things about it. StrongLoop hooked me up with a free ticket (thanks guys!), and May is the perfect time to soak up the cool dry Colorado mountain air. The presentation agenda looked great, but I’ll confess I was also pretty excited for the hackathon.

I’m a sucker for hackathons, at least the true “hack”-athons, which are different than the “I’m really here to pitch my latest startup idea so let me walk you through the deck”-athons that have become too common. Thankfully, the Gluecon event was definitely the former. There’s something refershing about the quick and dirty prototyping spirit, and the lack of concern for security, scalability, maintainable code, or commercial viability. I’ve already confessed that I don’t like writing tests, and a hackathon is the perfect excuse to skip all that.

Meeting new people, trying out new technologies, and thriving on a bit of friendly competition are all great reasons to participate. And of courses the prizes don’t hurt. 🙂

For the Gluecon event I teamed up with native Coloradoan Aaron Nielsen, whom I met the first evening.


Aaron and I wanted to use the soon-to-be-released GM Remote API. It lets you poll for realtime telemetry data and find out where your vehicle is, how fast its traveling, and in what direction. We built a simple map-based interface with two kinds of triggers: speed limits and geo-fences. When either of those triggers is tripped, the app sends you a text alert.

Screenshot of map with truck


Neither of us had done much with Cloud9 IDE before, so we thought this would be a great chance to test it out. On the whole, it’s really impressive how nice the coding experience is for something just running in a browser. We had a couple of hiccups where we were editing the same file and had to coordinate saves, but it was no more annoying than working out a merge in git.

The added bonus is that our code was already “deployed.” Each project gets a unique URL that is private by default, so you need to be logged in to your account in order to access it. It’s perfect for a quick demo.

Screenshot of Cloud 9 IDE Dashboard


Being the lazy developer that I am, I really like APIs that require nothing more than a key parameter included in your requests. The OAuth style of GM’s API requires more than that, but it wasn’t too bad once we got it set up. The tokens expire every 15 minutes, so we just added this check:

if (res.statusCode == 401)

and repeated the call after retrieving a fresh token.


Twilio has sponsored just about every hackathon I’ve participted in over the past 3 years. I’ve used them in many small hacks and a couple of production applications. Nexmo describes themselves as a “wholesale” SMS API, and that’s a pretty accurate summary; their rates are cheaper, they have better international support, and their developer experience – while adequate – lacks the level of polish and friendliness that you get from Twilio. Both of these companies tempted participants with prizes, but who doesn’t love an underdog? We decided to give Nexmo a shot.

I found one big advantage and one drawback to using Nexmo. The advantage is that all incoming SMS messages are free. That could be huge for certain applications. The downside is that you can’t directly respond to an incoming SMS like you can with Twilio (via TwiML). Twilio will read the TwiML and send an SMS back to the phone that sent your app the SMS, whereas Nexmo requires you to initiate a new send API request. It’s not that I mind writing the one line of code to do that, it’s that your app needs to be authorized to send an SMS through the Nexmo number that’s interacting with your app. That didn’t matter in our particular case, but I have written a few little apps in the past that were public open end points which any Twilio number could use.

Google Maps & Geolib

Google Maps is arguably the reigning champ of mashups in terms of sheer number of inclusions. The only thing that trips me up when I work with the maps API is weeding through documentation and samples that are outdated because they’re based on older versions.

I always like starting with the Styled Maps Wizard to strip out some labels and features for a cleaner simpler map.

I’ve done a bit of geo work using the handy built-in functions of MongoDB, but Aaron found us a great little Node.js library aptly named Geolib. Thanks to the isPointInCircle method, it was a snap to set up the geo-fence triggers.

It’s not about the money, but…

GM gave out two generous cash (literally a stack of bills) prizes, and we were lucky enough to win one! Our bet on Nexmo also paid off since they kicked in a Nexus 4.

Thanks again to Gluecon, Kevin Whinnery of Twilio and all the hackathon sponsors.

StrongLoop’s Announcements at Gluecon

StrongLoop introduced two new things at the conference that are worth noting. First, their core product has reached the GA 1.0 release (and has since had a 1.0.1 maintenance update). Even if you’re comfortable running stock Node.js installations and maintaining libraries through the primary NPM repository, you should check out StrongLoop’s distro. It provides some pretty cool tools for managing your applications without getting in the way of all the core things you love about Node.js.

Second, Matt Pardee showed off the Meetup in a Box project he created. Whether you want to start a Node meetup in their own town, or share your Node presentations with the world, check it out!