Summary
In this chapter, we explored the most common approach of optimizing APIs in general, and more specifically in Go, using techniques such as instructing the client’s cache to properly store information that is needed, adding a way to properly revalidate caches whenever possible using ETag, and adding server-side caches to avoid database server latencies and processing time. Finally, we went through the tooling provided by Go for performance analysis and bottleneck detections with pprof and Go benchmarks.
Performance is complex, and this is just a glance over some of the techniques that you can follow to improve it in the context of an API, but it always depends on your project and the usage patterns that your users have. This brings us to the next step in our journey. To have users, they need access to your API. To provide access to your API, you need to have it deployed somewhere. In the next chapter, we will cover how to deploy your Go program, exploring options...