If there is a word that first comes to mind when running virtual machines (VM), I would say "lean". Meaning, if the VM does not need to run a certain service, then, disable it; ensure that only the services required should be running. This will not only improve utilization but it does free up resources, thereby minimizing the probability of contention. If you are using cloud services, the pay-per-use model pays out the leaner the virtual machine.
On the flip side, knowing which services really do contribute to a big reduction to wastage is key. The question then: How do you quantifiably measure which optimizations give the most bang for your buck? Read on..
One thing to note, this tweak will only work on modern Linux operating systems with systemd. The old-school "init"-run systems will not be able to run the command, as the required binaries will not be present.
The above statement is the give-away to the command used. In order to do this, execute the command "sudo systemd-analyze plot > some-file.svg" on a terminal window. Then open the resulting output file, in this case "some-file.svg" in your browser. Prior to making tweaks, take a baseline measurement and see where optimizations can be applied. Subsequently, after another tweak, run the same command again to measure and compare the results with the baseline.
The added benefit of executing this procedure is that, you also get an idea of the time it takes to boot-up your virtual machine.
Having done this baseline measurement in my virtual machine, I now know that it takes ~16seconds to boot-up. And that, the postfix service is taking its time to start-up causing my virtual machine a few seconds delay to completely boot. Understandably, mysql.service takes a while to start causing an additional ~7secs to boot time. I really cannot disable that service but I could optimize elsewhere.
If I really don't require postfix running there. It would shave off ~1sec off the boot time. But really, ~16secs boot time is not bad.
Out of curiosity, I ran the same command in my AWS EC2 instance. The screenshot is below.
It is amazing to see that the EC2 instance, with a MySQL database running, only takes ~8secs to boot-up. Now that is lean or what!
RELATED: P2V (Physical to Virtual) Prep Work for Ubuntu
Go ahead and see if you can make tweaks in your environment. Let me know if this has helped by your comments and feedback.