ARTICLE AD BOX
We are currently investigating huge performance problem with our PHP backend, and we discovered that the connection to the database, using Doctrine DBAL, is pretty slow - around 1 second. Since this connection to the database has to be made for every single execution of our script (or HTTP request if you will), we end with a 1 second unavoidable overhead.
Here is the minimal index.php script that I used to measure the overhead of connecting to an Oracle database:
<?php require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; use Doctrine\DBAL\DriverManager; $conn = DriverManager::getConnection([ 'dbname' => 'REDACTED', 'user' => 'REDACTED', 'password' => 'REDACTED', 'host' => 'REDACTED', 'driver' => 'oci8' ]); $conn->connect(); exit; $ time php index.php real 0m 0.97s user 0m 0.01s sys 0m 0.02sWhat are we doing wrong here? How can we fix this script so that the connection is not created o every single execution, but cached in some way?
