./configure --with-oci8=$ORACLE_HOME --with-apxs2=/usr/sbin/apxs --with-config-file-path=/etc/httpd/conf --enable-sigchild --without-sqlite --without-mysql
compiled it and installed. Everything went fine, and on sample page I've displayed phpinfo():
I've changed php.ini to enable Database Resident Connection Pooling:
oci8.connection_class="TESTPOOL"and tested that it is used in PHP.
Then I've decided to test and compare performance of different methods of connection to Oracle from PHP. I've created simple PHP page, that connects to Oracle, execute simple query that returns one row, and inserts one row to another table. I've prepared test script for Apache JMeter against this page.
Test specification:
- Run on single processor machine
- Oracle and Apache+PHP run in VMware
- DRCP setup to have max 4 processes (3 processes effectively used, 4th for authentication only)
- 6 simultaneous users opening the same web page 200 times
-
4 versions of PHP script were used:
- oci_connect used to connect to Oracle without using DRCP (Database
Resident Connection Pooling)– in this case new connection is created for
every request from web browser. Connection is then closed at the end of
script
- oci_pconnect used to connect to Oracle without using DRCP – in this
case new connection is created for every apache process that is responding
to request from web browser. Connection is then closed at the end of
script
- oci_connect used to connect to Oracle with using DRCP (Database
Resident Connection Pooling)– in this case for every request connection is
obtained from pool and given back to pool at the end of script, seems that
in this case only process is reused (PURITY=NEW), while session is not (see my observations when using SQL*Plus )
- oci_pconnect used to connect to Oracle with using DRCP (Database Resident Connection Pooling)– in this case for every request connection is obtained from pool and given back to pool at the end of script. But in this case full potential of DRCP is used (PURITY=SELF)
Version | Description | # Requests | Average | Median | Standard Deviation | Throughput |
|
---|---|---|---|---|---|---|---|
1 | oci_connect without DRCP | 1200 | 989 | 875 | 828 | 359 |
|
2 | oci_pconnect without DRCP | 1200 | 123 | 94 | 187 | 2505 |
|
3 | oci_connect with DRCP | 1200 | 117 | 94 | 115 | 2907 |
|
4 | oci_pconnect with DRCP | 1200 | 82 | 78 | 30 | 4060 |
|
I must say that I'm positively impressed by performance achieved by version 3 where oci_pconnect with DRCP was used. I expected that performance for version 2,3,4 will be very similar. But I've observed 60% increase in Throughput and 33% shorter response times when comparing version 2 and 4 (oci_pconnect with and without DRCP). I've changed one setting for my test in JMeter: I've turned on Keep-Alive for http transfer and here are the results:
Version | Description | # Requests | Average | Median | Standard Deviation | Throughput |
|
---|---|---|---|---|---|---|---|
1 | oci_connect without DRCP |
|
|
|
|
|
Not tested |
2 | oci_pconnect without DRCP | 1200 | 84 | 63 | 116 | 4077 |
|
3 | oci_connect with DRCP | 1200 | 104 | 94 | 45 | 3265 |
|
4 | oci_pconnect with DRCP | 1200 | 78 | 78 | 23 | 4396 |
|
- oci_pconnect with DRCP works stable in both cases (with and without Keep-Alive) giving maximun throughput and very low standard deviation,
- oci_pconnect with DRCP has high standard deviation what means that there are lot of request with response time much higher then average,
- In both cases connecting to Oracle with use of DRCP performed better than without.
Cheers, Paweł