

Since we are always concerned about the security of our applications, we implemented it in the following way:

GOLANG FREE MEMORY CODE
There are a lot of in-depth guides on the internet about how this tool works, therefore I’m not going to write about this, but more about how we used it and what we saw.įirst things first, we had to implement a little bit of code which is using the pprof package. Pprof is for profiling your applications. If you are trying to search the internet regarding memory issues of Golang, you are definitely going to find articles related to pprof. Putting out fire (Or how you should start debugging) Just imagine yourself sitting in front of an application for half a minute doing absolutely nothing. You could carry the load from the hardware side for a while, but these kinds of issues need immediate fixes.Īs you can see we almost went up to half a minute sometimes. If your application dies, it should be because of the number of requests you receive, and not because of an unfortunate memory leak. The Go struct has the basic data type int and a pointer to the next node struct, all of which were set and accessed in the program. Consistent alarming from the monitoring system We created a corresponding freeNode function, which can free up the memory once we were done with the struct.Ungracefully terminated processes (Because of the forced restarts).Increased response time (And I mean REALLY increased times).If there’s no memory left to allocate you are going to experience things like: It took about 40 minutes for a node to go down because of the 1 GB memory limit we set before to be a healthy margin.Īs you can see if a node reached the limit, Kubernetes just killed and restarted it.

Our production environment is a Kubernetes cluster with 6 monolith nodes and a bunch of micro-services. When we reached 10k requests per minutes, it became unbearable. So we’ve spent quite some time in production since our product was released, but our memory issues got visible for us only when users actually started to use the application. The language utilizes automated garbage collection, so there should be no memory issues then right? Well let’s take a look at a real life example that we encountered with my team. Despite being easy to learn, there are issues which are not trivial to debug in the language and I feel like memory issues are one of them. We already know, that Golang is a blazing fast language with one of the smoothest learning curve ever.
