B
B
Boris Korobkov2017-07-11 19:17:46
MySQL
Boris Korobkov, 2017-07-11 19:17:46

Why does MySQL run much faster in a virtual machine than on a clean OS?

The same SQL query in pure Ubuntu runs 10 times slower than on the same computer in an Ubuntu virtual machine inside Windows. How to find out the problem?
The computer is the same: Intel Core i5-2500, 4 cores, 8GB RAM, Seagate 500Gb SATA hard drive.
The SQL queries are the same: expanding the database to run tests, about 100 tables, each with an average of 10 fields and 10 records.
Test 1. Full format, fresh install Ubuntu 17.04 64-bit, ext4 file system, one partition without swapping. MySQL 5.7. All default settings.
The database is deployed in about 1 minute. A separate query "alter table add column..." takes 0.5 sec.
The OS and all running applications take up 4GB, during the test too. Processor cores are usually occupied by 20-30%, during the test by 30-40%.
Test 2. The same computer. Full formatting, installation from scratch Windows 7, NTFS file system. It contains Virtualbox with 4 GB allocated, it contains Ubuntu and everything else from point 1 with the same settings.
The database in Ubuntu is deployed in about 5 seconds. A separate query "alter table add column..." takes 0.05 sec.
The OS and all running applications take up 6GB, during the test too. Processor cores are usually occupied by 40-50%, during the test by 50-60%.
Conclusion: inside a virtual machine, the same thing works an order of magnitude faster than on a clean OS. It's illogical.
Maybe Virtualbox keeps the entire virtual machine in RAM if possible?
Then what needs to be tweaked so that the specific tests in clause 1 also begin to fly, as in a virtual machine?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
Wexter, 2017-07-11
@BorisKorobkov

Because the hypervisor caches disk operations of the virtual machine in memory

S
Stalker_RED, 2017-07-11
@Stalker_RED

A database for running tests, about 100 tables, each with an average of 10 fields and 10 records.
synthetic tests are so synthetic!
Much has been written about database and virtual machine optimization, but with such testing it is a waste of time.

D
DmitriyA1, 2017-07-12
@DmitriyA1

There was the same situation.
MySQL database - took ~30 minutes to deploy on a local Linux machine (Ubuntu).
On the same machine, under Windows 7, under VirtualBox, Ubuntu is running. The same base is poured ~15 minutes.
The equipment has not changed. MySQL server versions are the same.
There is an assumption that this is due to the drivers on the motherboard.
How to check where the plug is?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question