I was pretty amazed by a problem with resources.
For months I was trying to fix a performance issue concerning resources I had with an automated Google AdWords Software that I developed for my company OMP Tools.
The problem was that we always had to transfer big amounts of data from AdWords to our Server, do a lot calculations, and send the adjustments back. This is not a problem for a single campaign, but now, after some good growth, we manage and optimise a big amount of accounts, budgets and clients.
As my server got overloaded, I tried to allocate resources (mainly RAM) accordingly.
For the sake of the argument, I am going to pick some random numbers.
With RAM being 32GB on the server, and 24 processes working parallel, my initial Idea was to restrict the memory limit for each process to 1,5GB. Sounds pretty cool – enough for everything.
With the load on the server still being way to high, I decided to restrict the resources even further to 1GB per process. 24 gigs of 32 gigs used, sounds even better, except it wasn’t. Nothing really changed, if anything, got worse.
Per coincidence I had to run a script needing far more than 1GB of ram, so I temporarily upped it to 4GB. Did some tests. Ran all the scripts. And to my big surprise – the load just peaked a tiny little bit, as everybody would expect while doing expensive operations.
A few tests later, I realized that this actually solved my resource problem. Allowing each process to take „far too much“ turned out to be cheaper altogether.
Really happy, I told a nice girl about it. And she did not understand what I was talking about, so I came up with a nice anology 🙂
Imagine you have 500 building blocks, and 5 kids playing with them. You allow everyone to take 100 blocks to finish their project to create fairness. But one kid needs 137 blocks, and starts crying being a pain in the ass, so you can not keep track of other things anymore, and soon again everybody starts to cry.
The next time you allow each kid to use 200 blocks, even though you only have 500. But with no hard limit on the size of the project, one kid needs said 137, another one only 50 to build what they imagined, and everybody gets what they want.
Sounds strange, but being prepared to spend more can actually save you a lot of effort and ressources in the total picture.