Arrays and slices Allocate memory for slices in advance We have finished with the theory, now let’s look at practical advice grouped by standard entities. You will have to determine this balance for your projects yourself. You also need to understand that most optimizations complicate the readability of the code. We must prove and show how much profit it brought us. That is, each optimization should be built on a benchmark. that every optimization must be justified. We need a quick result, MVP, and only then we will think about his problems.
#Scum map size 2021 code
I hope you all understand why we do not prematurely optimize and against it?! This is likely to be useless work, since we will need to study the entire application first and your piece of code will most likely not be a bottleneck. Too much resource consumption hurts the wallet, which means it requires immediate action. And memory leaks are closer to bugs and you can talk about them. Of course, this is not always a leak, it can also be a common overspending of resources, and we will try to avoid this today. We move to a Kubernetes cluster, set limits for all our applications and see that some of our applications are restarting - OOM-killer comes and solves the problem of our memory “leaks”. And one of them sometimes takes up all the resources, so much so that you cannot access the server via ssh. The second case is when you have, for example, your own VPS running several services. But if something goes wrong - you will pay a lot for it! And when it comes to money, you will definitely react to it somehow. If our service is lightly loaded, then it really can be practically free. And if we create them for our pet projects, then the infrastructure maintenance budget comes to the front. In the era of cloud computing, we often create serverless applications. We will not discuss the theory, but we will start immediately with practical examples. To begin with, I wanted to talk a little about the optimizations themselves. Today I want to bring to your attention an article on the simplest optimizations in Golang projects.