Optimizing performance of the virtual machines in an Oracle VirtualBox

The Mikrotik User Meeting or MUM Serbia 2016 was only a few days ago, during which I delivered a presentation related to the Mikrotik IPSec services. Rather than repeat the presentation, I decided to combine the slides and live demonstration.

I will write about Mikrotik IPSec services in some another post. I mention this presentation because the demo part is important for today’s though. One of the virtual machines booted very slowly and this had some impact on the presentation.

I made many VMs to simulate a very complex scenario; I used different platforms and operating systems, like Mikrotik RouterOS, Tiny Core Linux and the different Windows platforms. I decided after the presentation to discover where the problem lies.


Necessary hardware prerequisites

Whenever we need to use a large number of the VMs, we need to put a higher load on the physical machine itself. The resources on any physical computer (desktop, laptop or even server) are limited.

In the other hand, the VM is very similar to the physical computer. We just do not have separate hardware from some specific manufacturer. Instead of that, all VMs are using same simulated hardware presented for them by the virtualization software.

On one side, we must spare resources and limit their usage with the every single VM. On the other side, we must allocate sufficient resources to the VM. Please, keep in mind that the VM is just a computer without the real hardware.



We need the computer (desktop, laptop or server) to have a CPU with (minimum) two physical cores. The CPUs with the single-core multi-threating CPUs are not adequate for this role. You can equally use either Intel or AMD CPUs for this job.

If you are not sure about the specifications of the CPU inside your computer, you can check them on the website of the manufacturer. My virtual labs are laptops with the Intel i5 CPU. Here are details about it from this site. In case that you are using AMD processor, check this site.


At this point I would like to draw something to your attention. Every core of the CPU became one virtual processor or the vCPU. We must assign at least one vCPU per VM. Furthermore, the VMs will share the same core and, at the same time, every machine will see this core as its own CPU.


The memory

The more RAM we have, the more VMs can be running at the same time. For smaller lab inside the laptop, you can give away with at least as 4GBs of RAM. However, I will suggest that you try to obtain 8-16GBs for the lab or smaller virtualization solutions.

If you planning a full-scale production project, than you should consider the larger server platforms with significantly more resources and probably other virtualization software, like VMWare or Microsoft Hyper-V. In such case, we are speaking about the server platforms with multiple multi-core CPUs and even hundreds of gigabytes of RAM.


The hard disks

Last, but not least, prerequisite for a successful virtualization platform is the hard disk. You can use a wide range of the disk drives. Moreover, they are not equally efficient and some choices are better then others. We already discussed in details the benefits of the SSD drives over magnetic hard disks.


The hardware supported virtualization

If we really want the best results, we should have a laptop (or desktop) built in the last 5-6 years, which has a hardware capable of supporting virtualization. Actually, computers that support hardware virtualization will work faster.

You can still use even the computer without the hardware virtualization support, but you must be ready to accept the performance penalty; everything will be slower, so this solution is useful only if you do not have large demands for the VMs.


The anti-virus program

My advice is that you should reduce the number of the running processes on the host to a minimum. Additionally, you must tune your antivirus software to avoid scanning of the configuration folder for the Oracle VirtualBox (usually on the path C:\Users\%username%.VirtualBox).

02 - config path for VBox

We should also omit antivirus from scanning the folder where you are building and storing the VMs. You can check the path from the VirtualBox interface, from the menu File > Preferences > General. I never use the default path. And, I never place VMs on the C: drive.



Tuning the VM

I told you on the beginning of this article that I was not satisfied with the performances of some VMs during the presentation. Now, with the presentation completed, I have more time to check all those small mistakes I made. Furthermore, I decided to take this opportunity to find the optimal balance of the parameters for the VMs.

My problems are not at a hardware level. Obviously, I made something wrong. I chose the most problematic VM. I decided to carefully test this machine and to find the optimal performance settings. My goal is to archive a performance level where the VM works fast and, at the same time, and allows me to run many VMs.

We can manipulate the parameters that simulating the following parts of the virtual computer:

  • Motherboard
  • Processor
  • Hardware acceleration
  • Video card and display
  • Storage controller

We will not consider the storage controllers here. In most cases, we will be fine with either an IDE or SATA controller.

I would like to make an important notice here. If you are using the hard disk drive, then you should consider using fixed size virtual disks. With the SSD drives, you are free to use the dynamically expanding virtual disks.

We can also configure the networking, USB ports, serial (COM) ports or audio cards. In most cases, those parts are not crucial for the regular operations of the VMs and we will not considering them in this discussion.


The virtual motherboard

This group of settings is related to the motherboard and simulation of the chipset. The motherboard holds the computer BIOS, memory slots, ports and buses.


VirtualBox will create every new VM with predefined optimal parameters. In most cases, you should stay with them. However, if you have reason to change them, be very careful.

  • Assign enough RAM to the virtual computer, as it will need when it is physical. I assigning bare minimum of the RAM to the VM so that it can works smooth, keeping rest of the RAM for other purposes.
  • Chipset should be PIIX3. The ICH9 chipset is still in experimental phase and it is required for some newer operating systems.
  • If you are building the Windows based VM, you can use the virtual PS/2 mouse. If you cannot install the integration package, like with some Linux based machines, then you should use the USB tablet.
  • The I/O APIC is a new advanced interrupt controller. You need it with either the ICH9 chipset or more than one processor in the VM. Keep in mind that this option cannot be altered after the installation of the Windows based VMs.
  • Use the option Hardware clock in UTC Time only with those VMs that expecting it and otherwise will show incorrect time, like 1-2 hours difference. I using this on the Mikrotik RouterOS machines.


The virtual processor

Any computer must have a processor or the CPU. We can make a few choices here.



We can assign one or more vCPUs with the VM. This is the same as the real computer. More cores in the CPU + more tasks we can finish at the same time. If we build the lab only system, we can assign only one vCPU to it.

The second option is crucial for regular operations. We can assign more or less the host’s processor time to the VM. This setting can dramatically affect the performances of the VM. Alternatively, if you assign 100% of the host’s processor time to every VM, you are risking overloading the physical processor itself.

I would like to mention here one important thing. We have the slider for the vCPUs with four values. However, values 1 and 2 are green, while three and four are red. The reason for this is the existence of only two physical cores inside the processor.


You can find more about the hyper-threating technology on this Web page.


A hardware acceleration for the virtualization

We could gain an additional performance boost if we can directly use the hardware of the host computer. That acceleration is not small, often 2 or 3 times more.



This tab is available only if the host computer is capable of supporting this feature.

The Paravirtualization interface will simulate different virtualization environments. The most usual choice is Default. However, to gain the maximum benefits from the VM make the following choices:

  • Hyper-V for Windows 7/2008 Server and later operating systems
  • KVM for the Linux based operating systems, including the Mikrotik RouterOS x86 version.

The option Hardware Virtualization is a plain switch between hardware based and software-only virtualization. This option does not depend on the installed operating system in the VM.


The virtual graphics card

Almost every computer has a graphics card.



The video card needs some RAM for its own work. In most cases, we won’t need too much RAM or any special accelerating functions.

Keeping this in mind, we can tune performances for our VM. If we just need to simulate an average workstation for the office and the Internet, we probably can assign the minimal amount of the RAM and leave unchecked both field for the 2D and 3D accelerations. The 3D acceleration functions are still experimental and there is no guarantee that they will work.

If you want to use at least 2D acceleration, you will need more video RAM. You should not assign less RAM than recommended. In some very limited cases, when you are working with the DOS based or Mikrotik RouterOS x86 machines, you can assign the least amount of memory of only 1MB.

Bear in mind that assigned RAM for the virtual video card is also taken from the RAM of the host machine. This means that the total amount of the RAM assigned to the VM is equal to the sum of the assigned RAM inside the Motherboard tab and video RAM assigned in the Screen tab.


I achieved objective

My goal was to build a large smooth working lab that can be used for purposes of learning, testing or presenting.

I optimized all VMs in the lab following these guidelines. Even if my original configuration was not optimal, it was very near it. Moreover, in most cases the problem was boot time. As usage progressed, I rarely saw any problem.

Stay tuned.


4 thoughts on “Optimizing performance of the virtual machines in an Oracle VirtualBox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.