Azure Database for MySQL - Flexible Server is very slow
Dariusz Maciejewski
21
Reputation points
Hi. I have a problem with performance of my mysql flexible server. When I use the same mysql version with default configuration but as a separate VM I see much better performance.
I am pretty sure it's not database/application configuration issue but network issue.
I created a script to test the performance:
function after($msg)
{
global $tsts;
if (isset($tsts)) {
$time = floor((microtime(true) - $tsts) * 1000);
} else {
$time = 0;
}
print "{$msg}: {$time} ms\n";
$tsts = microtime(true);
}
$options = [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::MYSQL_ATTR_SSL_CA => '/home/azureuser/certs/ssl.pem',
PDO::ATTR_PERSISTENT => true,
PDO::ERRMODE_EXCEPTION => true,
];
$pdo = new PDO(
'mysql:host=' . $host . ';dbname=db',
$username,
$password,
$options
);
after("init");
$res = $pdo->query('SHOW TABLES;');
after("show tables");
for ($i = 1; $i <= 10; $i++) {
$res = $pdo->query('SELECT * FROM test LIMIT 50');
}
after('selects');
and for the flexible server it prints:
$ php mysql_test.php
init: 0 ms
show tables: 6 ms
selects: 18 ms
$ php mysql_test.php
init: 0 ms
show tables: 6 ms
selects: 18 ms
$ php mysql_test.php
init: 0 ms
show tables: 23 ms
selects: 18 ms
but for mysql installed on app vm directly it prints:
$ php mysql_test.php
init: 0 ms
show tables: 5 ms
selects: 3 ms
$ php mysql_test.php
init: 0 ms
show tables: 4 ms
selects: 2 ms
$ php mysql_test.php
init: 0 ms
show tables: 4 ms
selects: 3 ms
Maybe these values seem to be low but when I look at my real app it takes 1m30s vs 25s to execute db migrations.
Where is the problem and how can I fix it?
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
986 questions
Sign in to answer