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.
- Like this content and don’t want to miss the next post? Follow us on Twitter, Facebook or Google +.
- Want to read more “how to” articles like this? Check out “Practical Examples of the New Node.js Streams API” and “How to Improve Node.js HTTPS Server Performance”
- If you want to play with StrongOps or the rest of StrongLoop Suite, we’ve made it easy to get started. Sign up and get access to a pre-configured Cloud Workspace, downloads or builds for your favorite cloud.