Then I started to wonder how Ghost and Node.js would perform under load. How does the “stack” hold up if a post is picked up on Reddit or Hacker News. I stopped wondering and started monitoring the health (or stress) of my Digital Ocean Node.js Ghost configuration with StrongLoop’s Strong-Ops. This posting is about step #2, integrating StrongLoop’s Strong-Ops Node Performance Monitoring into your new Node.js ghost instance.
(If you need some help with step #1 standing up your ghost server there is an excellent guide on Digital Ocean that walks you through this.)
After you stand up your Ghost blog come back to this post and stop wondering and start monitoring.
Installing and configuring strong-agent with Ghost
1. Install the strong-agent node package on your newly-instantiated Ghost droplet.
I did this from the virtual web terminal, but it works the same if you ssh into the server.
npm install 'strong-agent' --save
2. Configure strong-agent with your StrongLoop API Key
Register with StrongLoop.com; and then get your API_KEY.
The Strong-Ops API_KEY can be a little tricky to find, so make sure and follow the next steps carefully. Once authenticated on StrongLoop.com go to your dashboard at strongloop.com/ops. Then select the drop down under your name and click ‘Account’.
Your API key is at the bottom of the page.
//add this to the top of index.js
var APPLICATION_NAME = 'My Great App';
var API_KEY = '<your API key from the website>';
3. Snapshot and restart your droplet.
Since you will need to restart your server now is also a good time to take a snapshot your Digital Ocean server for later use.
Node.js Performance Monitoring with Strong-Ops
Strong-Ops has several performance metrics, but I am going to focus on the three that matter the most to me: Memory, cycles, and latency. The first two because it gives me actionable information on my Ghost instance, and the second because it indicates the performance experience to my end user.
CPU usage (cycles) will help me answer if my machine stressed.
The resulting action would be to upgrade to a larger virtual machine.
Remember, Node.js applications are single threaded and will maximizes CPU core usage. So I can get a very clear picture of the stress of my system in this single chart. Like a server EKG, this chart will be my primary indicator for an under provisioned machine.
The memory heap profiler will tell me if my application stack robust. Is the combination of Ghost and Node.js efficient in its memory management, or is it possibly leaking memory?
Do I need to file a bug report on the ghost bugs forum or possibly upgrade my Node.js version?
The three memory profiles to watch are:
– Heap: Current heap size
– RSS: Resident set size
– V8 GC: Heap size sampled immediately after a full garbage collection
The response time latency will gives me an indication of:
– How is the experience to my end users? are pages served quickly and consistently?
– Is my machine under-provisioned for my desired user experience and usage load.
The ‘http’ line shows the average total time for any incoming HTTP request.
There are several other useful (some would say critical) metrics that Strong Ops helps you track and measure such as:
Now that I have my indicators and actions outlined, I can check in on my machine and evaluate as my posts are consumed and the ghost blogging platform is used.
Since it’s a fresh server and domain, none of my articles are “blowing up” on Reddit or Hacker News. … yet 🙂
I’ll report back next week as my stats grow and usage starts to put my Ghost stack through its paces.
- What’s in the upcoming Node v0.12 release? Six new features, plus new and breaking APIs.
- Ready to develop APIs in Node.js and get them connected to your data? Check out the Node.js LoopBack framework. We’ve made it easy to get started either locally or on your favorite cloud, with a simple npm install.
- Need training and certification for Node? Learn more about both the private and open options StrongLoop offers.