Continuous profiling on Upsun
Upsun Continuous Profiling is powered by Blackfire. It is available directly from the Console under theProfiling tab of your environments.
The Node.js continuous profiling is currently made across 3 dimensions:
- CPU Time: Time spent running on the CPU
- Wall-time: Elapsed time per function call
- Heap: Memory allocation and reserved space over time
Prerequisites
Upsun Continuous Profiler requiresNode.js >= 16.0.0.
Installation
Get the Blackfire Continuous Profiler NodeJS library:NodeJS continuous profiler API
The NodeJS continuous profiler API has two functions:function start(config) {}
The start function starts the continuous profiler probe.
It collects profiling information in the background and periodically uploads it to the Blackfire Agent until the stop function is called.
start function accepts an object as a parameter with the following keys:
-
appName: name of the application -
durationMillis: time in milliseconds for which to collect profile (default: 45_000) -
cpuProfileRate: average sampling frequency in Hz. (default: 100) -
labels: Labels to add to the profile. (default: ) -
uploadTimeoutMillis: Timeout in milliseconds for the upload request (default: 10000)
function stop() {}
Stops the continuous profiling probe.
An example application
- Get the Continuous Profiler NodeJS library
- Create
index.jswith the following code
- Run the Node.js server