I am using PHP with Oracle Database 12c and i want to implement connection pooling for improve my application performance Can you help me please ?
Asked
Active
Viewed 1,914 times
0
-
What you have tried so far? – Muhammad Hassaan May 21 '20 at 09:29
-
well, i tried this example https://workwiththebest.intraway.com/blog-post/performance-oracle-pool-with-php/, but it's showing TNS error only when i put this :POOLED string after service name – Jafor Iqbal May 21 '20 at 10:16
1 Answers
1
Check the Database Resident Connection Pooling (DRCP) chapter of Oracle's free The Underground PHP and Oracle Manual.
First determine if you need DRCP. I assume you are already using persistent oci_pconnect()
calls, which is the first thing to do to improve connection performance.
Like any pool, DRCP is a shared resource so there is some overhead and you need to make sure that connections are not held open which would block other users. If you're not running out of memory on the DB server host, I would suggest not using it.
If you decide to try it, the basic steps are:
- start the pool, something like
SQL> execute dbms_connection_pool.start_pool()
- update your php.ini and set a connection class:
oci8.connection_class = MYPHPAPP
- Use a pooled connect string like
or$c = oci_pconnect('myuser', 'mypassword', 'myhost/sales:POOLED');
where the connect alias is in a tnsnames.ora file:$c = oci_pconnect('myuser', 'mypassword', 'salespool');
salespool=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=myhost.dom.com) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales) (SERVER=POOLED)))

Christopher Jones
- 9,449
- 3
- 24
- 48
-
currently, I am using "oci_connect", So if oci_pconnect is better than oci_connect than should I change it to oci_pcoonect first instead of connection pooling technique? – Jafor Iqbal May 22 '20 at 04:57
-
Just letting you know my DB server configuration is very good enough. – Jafor Iqbal May 22 '20 at 05:04
-
Yes, use oci_pconnect() first. Make sure that your number of mid-tier PHP processes is as small as possible (don't oversize the number), since each will now keep a DB connection open. Each of these will take some memory on the DB host. – Christopher Jones May 22 '20 at 06:47