CPU profiling allows you to understand where opportunities exist to improve the speed and load capacity of your node process. N|Solid provides multiple ways to profile your CPU.
The N|Solid Console allows you to take and analyze profiles in one action. This is particularly useful if you need to take a series of profiles as it saves you the overhead of switching from one environment to another. The console also saves a history of profiles so you can quickly flip through profiles to identify troublesome areas.
N|Solid's Command Line Interface (CLI) is a great way to quickly pull profiles from remote processes for local examination. With NSolid installed and on your path, a pair of commands are used to accomplish this.
nsolid-cli -- socket XXXX profile_start
nsolid-cli -- socket XXXX profile_stop > my.cpuprofile
Collection will commence immediately after ‘profile_start’ hits the wire and will continue for up to 60 seconds. If profile_stop is not entered before 60 seconds then the process times out and the profile data is discarded. Order of execution is always profile_start, then profile_stop.
Looking to do a timed test?
You can do this with some simple scripting!
nsolid-cli --socket 5000 profile_start\n
ab -n 1000 -c 100 http://localhost:8000\n
nsolid-cli --socket 5000 profile_stop > 1.cpuprofile
This will do a CPU profile while running a load test with ab (Apache Bench). If you wanted to do a timed one, replace the ab invocation with
sleep 10(to sleep for 10 seconds)."
Once the .cpuprofile file has been created, it can be opened using Chrome’s Development Tool’s CPU Profile Debugging Tool. It’s important to note that Chrome requires the generated file to have the extension .cpuprofile so be sure to use that.
Need Help Installing the Console?