Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-15-2012, 12:26 PM   PM User | #1
rmglez
New to the CF scene

 
Join Date: Nov 2012
Location: Spain
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
rmglez is an unknown quantity at this point
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?
rmglez is offline   Reply With Quote
Old 11-15-2012, 02:40 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
I'm assuming you're running on a Windows platform-- which OS version? And what versions of PHP and Apache are you using exactly-- what install packages? Did you match the compilers up between PHP and Apache? (VC6 vs. VC9) That will all have an impact.
__________________
Fumigator is offline   Reply With Quote
Old 11-15-2012, 03:08 PM   PM User | #3
rmglez
New to the CF scene

 
Join Date: Nov 2012
Location: Spain
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
rmglez is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
I'm assuming you're running on a Windows platform-- which OS version? And what versions of PHP and Apache are you using exactly-- what install packages? Did you match the compilers up between PHP and Apache? (VC6 vs. VC9) That will all have an impact.
I've tested this behavior in Ubuntu 12.10 and also in a Centos server.

Ubuntu configuration:
apache2 -V
Server version: Apache/2.2.22 (Ubuntu)
Server built: Nov 6 2012 20:27:22
Server's Module Magic Number: 20051115:30
Server loaded: APR 1.4.6, APR-Util 1.4.1
Compiled using: APR 1.4.6, APR-Util 1.4.1
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"

php -v
PHP 5.4.6-1ubuntu1 (cli) (built: Aug 22 2012 21:15:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
rmglez is offline   Reply With Quote
Old 11-15-2012, 04:10 PM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Well shoot, there goes my theory.

Can you narrow down where the bottleneck is-- connecting? fetching? Any errors being reported in Apache error log?
__________________
Fumigator is offline   Reply With Quote
Old 11-15-2012, 04:30 PM   PM User | #5
rmglez
New to the CF scene

 
Join Date: Nov 2012
Location: Spain
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
rmglez is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
Well shoot, there goes my theory.

Can you narrow down where the bottleneck is-- connecting? fetching? Any errors being reported in Apache error log?
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

Remember that both executions where done in the same server and the DB2 server is a remote server.

Last edited by rmglez; 11-15-2012 at 04:36 PM..
rmglez is offline   Reply With Quote
Old 11-15-2012, 07:49 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This reeks of communication. And what spot, not sure.
PDO appears to have generics compatible with DB2: http://ca2.php.net/manual/en/ref.pdo-odbc.php, so I'd suggest you establish the connection via PDO to the DB2 db, and see how that goes.
If its still slow via httpd, I'd suggest that its definitely communication. Make sure you are working through local (assuming local yeah?) connections and not attempting to go offsite. Check the iptables, firewall or whatever you are using to block to make sure that its not being bottlenecked there.

If it fixes the problem, I'd suggest an issue in the odbc package itself. In which case I'd suggest not to bother with the odbc. I don't believe that the package is deprecated, but it is getting rather antiquated.

Typically you will see better performance on direct CLI, but not like 1/150th of a difference. More like 20% savings being normal.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
apache, db2, odbc, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:05 PM.


Advertisement
Log in to turn off these ads.