Go performance
Another fundamental piece of API performance is to make things work faster, and one of the things that we normally want to go faster is the code we are executing. To be fair, Go is already really fast and is rarely the bottleneck of your API. The most common bottleneck is going to be your database and the access patterns that you have for that, but still, your project can be one of those cases where Go code CPU or memory usage is the place that needs to be optimized. So, let’s explore some of the tools Go provides to analyze and improve your performance, starting with the profiling part.
Profiling
As we said before, it is important to know what to optimize, so the first thing we need to know is how to measure the performance of our application. For that, Go comes with its own built-in profiler, named pprof. This allows you to collect CPU and memory profiles in your applications in different ways. Still, one of my favourite ways is exposing an HTTP interface...