Correct way to use Go Pprof to compare execution-time differences in two versions of a same functionality

232 views Asked by At

I am running a Golang project in a container environment which has two pods.

  1. Pod1: user-interaction and data-access layer.
  2. Pod2: Database server.

The data-access layer involves functions like data validation, do get on db to check if data already exist, insert data, and many more data manipulation tasks...

I have two versions of the project with two differnt databases. (Database APIs in data-access layers are abstracted so that I can replace the redis with postgres or any other databases.)

  1. Redis db (data access layer implemented with redis package).
  2. Postgresql db (data access layer implemented with pgx package).

Now to compare the two versions I ran a command at pod1 to create 100000 records in each, and observed huge difference in command execution time.

  • Redis: 2m30s
  • Postgres: 9m20s

I need to debug which part of the code is taking more time, so what is the correct way to use Pprof tool? (should I run pprof for entire time of the command execution and compare? or should I run both for a minute and compare?, which pprof profiling should I use?).

Thanks

0

There are 0 answers