Architecture and Performance |
|
2024-11-24 |
|
|
12 |
|
|
Non-persistent: 370 requests/second
Persistent: 525 requests/second
This is with MySQL's query cache enabled. But Callgrind shows us that we are actually
calling MySQL's internal prepare/execute API.
Callgraph [mysql.out]
Use direct queries
<?php
$config = array(
'db' => 'mysql',
'db_user' => 'nobody',
'db_pwd' => 'foobar',
'db_host' => 'localhost',
'db_db' => 'users',
'db_opts' => array(PDO::ERRMODE_EXCEPTION => true,
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_EMULATE_PREPARES=>true)
);
?>
PDO::ATTR_EMULATE_PREPARES was added in PHP 5.1.3. You can use PDO::MYSQL_ATTR_DIRECT_QUERY in earlier versions.
That brings us to 580 requests/second. Down to 3 servers!
The same tests with InnoDB reveal similar numbers.
Sqlite3 comes in at around 550 requests/second with persistent connections.