CPU and Memory Profiling

If you observe low throughputs or high memory usage, you can enable CPU and/or Memory profiling for your Flogo app. Enabling this profiling impacts performance. Hence, we do not recommend enabling them in a production environment.

Before you begin
  • You must have GO version 1.9.0 or higher installed.
  • Make sure that the pprof tool is installed on your machine. Refer to PPOF for more details on the pprof tool.

Enabling CPU Profiling

To enable CPU profiling:

    Procedure
  1. Open a command prompt or terminal.
  2. Change the directory to the folder in which your app binary is located.
  3. Run the following command:
    ./<app_binary> -cpuprofile <file>
    where <file> is the profile file. For example, ./StockService -cpuprofile /home/users/StockService_cpu.prof

Enabling Memory Profiling

To enable memory profiling:

    Procedure
  1. Open a command prompt or terminal.
  2. Change the directory to the folder in which your app binary is located.
  3. Run the following command:
    ./<app_binary> -memprofile <file>
    where <file> is the profile file. For example, ./StockService -memprofile /home/users/StockService_mem.prof

Enabling CPU and Memory Profiling in a Single Command

To enable CPU and memory profiling in a single command:

    Procedure
  1. Open a command prompt or terminal.
  2. Change the directory to the folder in which your app binary is located.
  3. Run the following command:
    ./<app_binary> -memprofile <file> -cpuprofile <file>

Analyzing your profiling data

Once you capture the profiling data, analyze it using pprof by running the following command:

go tool pprof <profile file>