0

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 ?

2
  • What you have tried so far? Commented May 21, 2020 at 9:29
  • well, i tried this example workwiththebest.intraway.com/blog-post/…, but it's showing TNS error only when i put this :POOLED string after service name Commented May 21, 2020 at 10:16

1 Answer 1

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
    $c = oci_pconnect('myuser', 'mypassword', 'myhost/sales:POOLED');
    
    or
    $c = oci_pconnect('myuser', 'mypassword', 'salespool');
    
    where the connect alias is in a tnsnames.ora file:
    salespool=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)
    (HOST=myhost.dom.com)
      (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales)
    (SERVER=POOLED)))
    
Sign up to request clarification or add additional context in comments.

3 Comments

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?
Just letting you know my DB server configuration is very good enough.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.