#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    PHP + Apache + DB2 slow odbc_connect


    Hi,

    I'm using a script with odbc_connect in order to connect to a remote DB2 instance. When the script is executed from command line everything works as expected, but when the same script is executed using Apache web server the call to odbc_connect is extremely slow.

    I've compared the php.ini for CLI and for Apache and the configuration of memory and ODBC are the same in both files.

    I'm using iSeries driver, PHP 5 and Apache 2.

    Does anybody knows how to solve this annoying problem?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,496
    Rep Power
    594
    When you say it works as expected from the command line, are you using the same server that runs Apache or are you doing it from the same client that seems slow?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by gw1500se
    When you say it works as expected from the command line, are you using the same server that runs Apache or are you doing it from the same client that seems slow?
    The command line execution is from the same server where Apache is running, thus the problem seems to be related with Apache.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,496
    Rep Power
    594
    Have you tried running the query from a browser on the Apache server? That will be a true apples to apples test.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by gw1500se
    Have you tried running the query from a browser on the Apache server? That will be a true apples to apples test.
    Any connection attempt from Apache is very slow.

    I guess the problem is with the function odbc_connect. Once the connection resource is available everything works fine.

    Script execution time from command line (in milliseconds):
    odbc_connect : 754 (0.7 second)
    odbc_prepare : 104
    odbc_execute : 80
    odbc_fetch_object : 3
    odbc_fetch_object : 0
    odbc_fetch_object : 1
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 1
    odbc_fetch_object : 0

    Script execution time from Apache (in milliseconds):
    odbc_connect : 127125 (127.125 seconds)
    odbc_prepare : 94
    odbc_execute : 96
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 1
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0

    No errors where logged in Apache log.

    Remember that both executions where done in the same server and the DB2 server is a remote server.
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    Originally Posted by rmglez
    Any connection attempt from Apache is very slow.

    I guess the problem is with the function odbc_connect. Once the connection resource is available everything works fine.

    Script execution time from command line (in milliseconds):
    odbc_connect : 754 (0.7 second)
    odbc_prepare : 104
    odbc_execute : 80
    odbc_fetch_object : 3
    odbc_fetch_object : 0
    odbc_fetch_object : 1
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 1
    odbc_fetch_object : 0

    Script execution time from Apache (in milliseconds):
    odbc_connect : 127125 (127.125 seconds)
    odbc_prepare : 94
    odbc_execute : 96
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 1
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0
    odbc_fetch_object : 0

    No errors where logged in Apache log.

    Remember that both executions where done in the same server and the DB2 server is a remote server.
    Have you tried switching the remote host name to an IP? Maybe it's something with dns ...
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by msteudel
    Have you tried switching the remote host name to an IP? Maybe it's something with dns ...
    Unfortunately, I'm already using the IP address of the remote server.

    I don't know if the environment where httpd process is running (available memory, permissions,...) is a key point for this problem.

    In the effort to isolate the bottleneck I used an ODBC datasource with a MySQL database and the connection went ok, from both the command line and Apache. Therefore, it might be possible that the DB2 driver used through mod_php (Apache) have some problems.

IMN logo majestic logo threadwatch logo seochat tools logo