Hi.
I've got a new Centos 5.1 x86-64 server that uses PHP to communicate with MySQL5. On this server, PHP/Mysql connections are dead slow and unresponsive. It takes sometimes up to a minute to list tables in phpmyadmin for example.
I've verified on the server that the issue has to be PHP/Mysql related. If I use a CGI based Mysql admin tool, communication is fast and there are no delays.
The server is Xeon based and has 4GB of RAM.
SElinux is enabled, and ModSecurity for Apache too. Disabling these two does not help.
SElinux allows Apache to network connect.
Some php.ini settings: =============================== safe_mode = On max_execution_time = 60 max_input_time = 60 memory_limit = 128M open_basedir is active, and there are no conflicts. disable_functions also contain several functions in order to secure server. allow_fopen_url is disabled ===============================
Could there be a bug somewhere that is causing this slowness for PHP/Mysql connections.
Feedback and tips for solving this problem will be greatly appreciated :)
Regards, /PGE (aka mysteron)
--- Link to forum post:
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=14575&start=0...
--- Answer I've recieved and answered:
Q: Sounds like the server is trying to do a reverse DNS lookup and timing out after a minute plus. Is DNS set up on the server correctly?
A: Yes, DNS is working correctly. I tried with the IP address of the database server instead of its DNS name, but there is no difference, PHP/Mysql connections are still dead slow.
---
Now I've also tried running a MySQL server on the webserver, and setting for example phpmyadmin to connect to localhost does not change any kind of behaviour. PHP/Mysql connections are still very slow.
/PGE
--- On Mon, 6/9/08, Pro Green European pro_green_european@yahoo.com wrote: From: Pro Green European pro_green_european@yahoo.com Subject: [CentOS] Help, PHP/Mysql connections are so slow. To: centos@centos.org Date: Monday, June 9, 2008, 9:42 AM
Hi.
I've got a new Centos 5.1 x86-64 server that uses PHP to communicate with MySQL5. On this server, PHP/Mysql connections are dead slow and unresponsive. It takes sometimes up to a minute to list tables in phpmyadmin for example.
I've verified on the server that the issue has to be PHP/Mysql related. If I use a CGI based Mysql admin tool, communication is fast and there are no delays.
The server is Xeon based and has 4GB of RAM.
SElinux is enabled, and ModSecurity for Apache too. Disabling these two does not help.
SElinux allows Apache to network connect.
Some php.ini settings: =============================== safe_mode = On max_execution_time = 60 max_input_time = 60 memory_limit = 128M open_basedir is active, and there are no conflicts. disable_functions also contain several functions in order to secure server. allow_fopen_url is disabled ===============================
Could there be a bug somewhere that is causing this slowness for PHP/Mysql connections.
Feedback and tips for solving this problem will be greatly appreciated :)
Regards, /PGE (aka mysteron)
--- Link to forum post:
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=14575&start=0...
--- Answer I've recieved and answered:
Q: Sounds like the server is trying to do a reverse DNS lookup and timing out after a minute plus. Is DNS set up on the server correctly?
A: Yes, DNS is working correctly. I tried with the IP address of the database server instead of its DNS name, but there is no difference, PHP/Mysql connections are still dead slow.
---
_______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
communicate with MySQL5. On this server, PHP/Mysql connections are dead slow and unresponsive. It takes sometimes up to a minute to list tables in phpmyadmin for example.
Have you tried other protocols? Is it really only http transfers that are slow?
Have you tried pinging 100 times and see if you get dropped packets?
Are there any errors from the netcards showing up in log files?
BR Bent
Hi.
Have you tried other protocols? Is it really only http transfers that are slow?
Yes. Ftp works perfectly, and regular http with cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
Have you tried pinging 100 times and see if you get dropped packets?
0% packet loss
Are there any errors from the netcards showing up in log files?
None.
I am really baffeled with this problem. I have no idea what to do next. Have enabled server-status in Apache and when the scripted site is being access the cpu load is around 2.5%.
Regards, /mysteron
--- On Mon, 6/9/08, Bent Terp bent@nagstrup.dk wrote:
From: Bent Terp bent@nagstrup.dk Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: "CentOS mailing list" centos@centos.org Date: Monday, June 9, 2008, 10:42 AM
communicate with MySQL5. On this server, PHP/Mysql
connections are dead
slow and unresponsive. It takes sometimes up to a
minute to list tables
in phpmyadmin for example.
Have you tried other protocols? Is it really only http transfers that are slow?
Have you tried pinging 100 times and see if you get dropped packets?
Are there any errors from the netcards showing up in log files?
BR Bent _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
If it's a table listing check your MySQL settings. How have you set up my.cnf? What does your slow query log tell you? Have you logged into your MySQL server from another machine and ran queries from there? Have you enabled verbose logging for PHP and Apache? Are you tailing all 3 while you run the query from phpadmin? One of them will say something interesting.
I think your issue smells like something in how you compiled PHP or a setting in php.ini itself.
Put a test.php in the doc-root and see what it tells you it's using. (re; mysql & the php version & the location of the php.ini) I've done installs where I had conflicting libs from both PHP and MySQL. Also I get stupid locations for php.ini all the time and have to manaully move that file to the correct location.
[root@altair htdocs]# cat test.php <?php phpinfo(); ?> <? var_dump($GLOBALS['_PHPA']); ?>
I generally compile everything when I do a similar install - and give explicit declarations to where the apxs is for PHP as well as the root mysql libraries. Check that everything is where you think it is.
*from recent installation of vtiger: (for example)
APACHE 2 ==================== --prefix=/data/CRM/apache2 --with-mpm=prefork --enable-ssl --enable-setenvif --enable-proxy --enable-proxy-http --enable-so --disable-charset-lite --disable-include --disable-env --disable-status --disable-autoindex --disable-asis --disable-negotiation --disable-actions --disable-userdir --disable-alias make make install
PHP 5.2.5 ==================== --prefix=/data/CRM/php-5.2.5 --with-zlib-dir=/data/CRM/src/rrdbuild/lb --with-gd --with-png-dir=/data/CRM/src/rrdbuild/lb --with-freetype-dir=/data/CRM/src/rrdbuild/lb --with-jpeg-dir=/data/CRM/src/rrdbuild/lb --with-imap=/data/CRM/src/rrdbuild/lb --with-mysql=/usr/local/include/mysql --with-apxs2=/data/CRM/apache2/bin/apxs make make test make install
=====================================================================
XCACHE (this is the PHP accelerator we're using)
*you'll have to force it to see the non-standard install locations we're using. =============== Make a build directory: mkdir xcache-build cd src/xcache-build/ phpize --clean && phpize env CPPFLAGS="-I/data/CRM/php-5.2.5/include -I/data/CRM/apache2/include" LDFLAGS="-L/data/CRM/php-5.2.5/lib -I/data/CRM/apache2/lib" CFLAGS="-O3 -fPIC" ../xcache-1.2.2/configure --prefix=/data/CRM/ --enable-xcache make make install
*You must re-install each time you upgrade or re-compile PHP make distclean && phpize --clean && phpize (now continue w/ original instructions)
Locate a php.ini and copy it to /data/CRM/php-5.2.5/lib/php.ini Append the xcache options to this file: cd ../xcache-1.2.2 cat xcache.ini >> /etc/php.ini
Edit the php.ini to comply with the vtiger installation notes:
;Your php.ini must configured with the following parameters:
; * safe_mode = Off ; * display_errors = On *this is stupid. Turn it off after you tweak vtiger to how you like it. ; * file_uploads = On ; * register_globals = Off ; * max_execution_time = 600 ; * output_buffering= On ; * memory_limit = 32M *is 128 by default - ignore ; * error_reporting = E_WARNING & ~E_NOTICE ; * allow_call_time_reference = On ; * log_errors = Off *again, stupid - ignore ; * short_open_tag= On *again, why the code is a bit crap in vtiger that we'd need to enable this. ; * extension=php_gd2.dll *ignore - it's for windows ; * extension=php_imap.dll *ignore - it's for windows ; * extension=php_mysql.dll *ignore - it's for windows ; * extension=php_mysqli.dll *ignore - it's for windows
===========================================================
-Peter
2008/6/9 Pro Green European pro_green_european@yahoo.com:
Hi.
Have you tried other protocols? Is it really only http transfers that are slow?
Yes. Ftp works perfectly, and regular http with cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
Have you tried pinging 100 times and see if you get dropped packets?
0% packet loss
Are there any errors from the netcards showing up in log files?
None.
I am really baffeled with this problem. I have no idea what to do next. Have enabled server-status in Apache and when the scripted site is being access the cpu load is around 2.5%.
Regards, /mysteron
--- On Mon, 6/9/08, Bent Terp bent@nagstrup.dk wrote:
From: Bent Terp bent@nagstrup.dk Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: "CentOS mailing list" centos@centos.org Date: Monday, June 9, 2008, 10:42 AM
communicate with MySQL5. On this server, PHP/Mysql
connections are dead
slow and unresponsive. It takes sometimes up to a
minute to list tables
in phpmyadmin for example.
Have you tried other protocols? Is it really only http transfers that are slow?
Have you tried pinging 100 times and see if you get dropped packets?
Are there any errors from the netcards showing up in log files?
BR Bent _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Maybe if you trust DNS resolution names to make the connection to the Database servers could be a problem. Did you try to use IP addresses directly in the code?
Regards,
Peter Farrell escribió:
If it's a table listing check your MySQL settings. How have you set up my.cnf? What does your slow query log tell you? Have you logged into your MySQL server from another machine and ran queries from there? Have you enabled verbose logging for PHP and Apache? Are you tailing all 3 while you run the query from phpadmin? One of them will say something interesting.
I think your issue smells like something in how you compiled PHP or a setting in php.ini itself.
Put a test.php in the doc-root and see what it tells you it's using. (re; mysql & the php version & the location of the php.ini) I've done installs where I had conflicting libs from both PHP and MySQL. Also I get stupid locations for php.ini all the time and have to manaully move that file to the correct location.
[root@altair htdocs]# cat test.php
<?php phpinfo(); ?>
<? var_dump($GLOBALS['_PHPA']); ?>
I generally compile everything when I do a similar install - and give explicit declarations to where the apxs is for PHP as well as the root mysql libraries. Check that everything is where you think it is.
*from recent installation of vtiger: (for example)
APACHE 2
--prefix=/data/CRM/apache2 --with-mpm=prefork --enable-ssl --enable-setenvif --enable-proxy --enable-proxy-http --enable-so --disable-charset-lite --disable-include --disable-env --disable-status --disable-autoindex --disable-asis --disable-negotiation --disable-actions --disable-userdir --disable-alias make make install
PHP 5.2.5
--prefix=/data/CRM/php-5.2.5 --with-zlib-dir=/data/CRM/src/rrdbuild/lb --with-gd --with-png-dir=/data/CRM/src/rrdbuild/lb --with-freetype-dir=/data/CRM/src/rrdbuild/lb --with-jpeg-dir=/data/CRM/src/rrdbuild/lb --with-imap=/data/CRM/src/rrdbuild/lb --with-mysql=/usr/local/include/mysql --with-apxs2=/data/CRM/apache2/bin/apxs make make test make install
=====================================================================
XCACHE (this is the PHP accelerator we're using)
*you'll have to force it to see the non-standard install locations we're using.
Make a build directory: mkdir xcache-build cd src/xcache-build/ phpize --clean && phpize env CPPFLAGS="-I/data/CRM/php-5.2.5/include -I/data/CRM/apache2/include" LDFLAGS="-L/data/CRM/php-5.2.5/lib -I/data/CRM/apache2/lib" CFLAGS="-O3 -fPIC" ../xcache-1.2.2/configure --prefix=/data/CRM/ --enable-xcache make make install
*You must re-install each time you upgrade or re-compile PHP make distclean && phpize --clean && phpize (now continue w/ original instructions)
Locate a php.ini and copy it to /data/CRM/php-5.2.5/lib/php.ini Append the xcache options to this file: cd ../xcache-1.2.2 cat xcache.ini >> /etc/php.ini
Edit the php.ini to comply with the vtiger installation notes:
;Your php.ini must configured with the following parameters:
; * safe_mode = Off ; * display_errors = On *this is stupid. Turn it off after you tweak vtiger to how you like it. ; * file_uploads = On ; * register_globals = Off ; * max_execution_time = 600 ; * output_buffering= On ; * memory_limit = 32M *is 128 by default - ignore ; * error_reporting = E_WARNING & ~E_NOTICE ; * allow_call_time_reference = On ; * log_errors = Off *again, stupid - ignore ; * short_open_tag= On *again, why the code is a bit crap in vtiger that we'd need to enable this. ; * extension=php_gd2.dll *ignore - it's for windows ; * extension=php_imap.dll *ignore - it's for windows ; * extension=php_mysql.dll *ignore - it's for windows ; * extension=php_mysqli.dll *ignore - it's for windows
===========================================================
-Peter
2008/6/9 Pro Green European pro_green_european@yahoo.com:
Hi.
Have you tried other protocols? Is it really only http transfers that are slow?
Yes. Ftp works perfectly, and regular http with cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
Have you tried pinging 100 times and see if you get dropped packets?
0% packet loss
Are there any errors from the netcards showing up in log files?
None.
I am really baffeled with this problem. I have no idea what to do next. Have enabled server-status in Apache and when the scripted site is being access the cpu load is around 2.5%.
Regards, /mysteron
--- On Mon, 6/9/08, Bent Terp bent@nagstrup.dk wrote:
From: Bent Terp bent@nagstrup.dk Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: "CentOS mailing list" centos@centos.org Date: Monday, June 9, 2008, 10:42 AM
communicate with MySQL5. On this server, PHP/Mysql
connections are dead
slow and unresponsive. It takes sometimes up to a
minute to list tables
in phpmyadmin for example.
Have you tried other protocols? Is it really only http transfers that are slow?
Have you tried pinging 100 times and see if you get dropped packets?
Are there any errors from the netcards showing up in log files?
BR Bent _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi.
Yes, I have tried that too, no difference. I've even tried running MySQL with a database populated with identical data on localhost (even tried 127.0.0.1), but there is no difference in performance. Delays in the connection to the db server is still around 20-30 seconds.
So, the problem has to be with either the php-mysql module, PHP itself, MySQL or then it may be hardware related.
Thx, /mysteron
--- On Mon, 6/9/08, Lorenzo Martínez Rodríguez Lawwait@yahoo.es wrote:
From: Lorenzo Martínez Rodríguez Lawwait@yahoo.es Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: "CentOS mailing list" centos@centos.org Date: Monday, June 9, 2008, 1:30 PM Maybe if you trust DNS resolution names to make the connection to the Database servers could be a problem. Did you try to use IP addresses directly in the code?
Regards,
Peter Farrell escribió:
If it's a table listing check your MySQL settings.
How have you set up
my.cnf? What does your slow query log tell you? Have you logged into your MySQL server from another
machine and ran
queries from there? Have you enabled verbose logging
for PHP and
Apache? Are you tailing all 3 while you run the query
from phpadmin?
One of them will say something interesting.
I think your issue smells like something in how you
compiled PHP or a
setting in php.ini itself.
Put a test.php in the doc-root and see what it tells
you it's using.
(re; mysql & the php version & the location of
the php.ini)
I've done installs where I had conflicting libs
from both PHP and
MySQL. Also I get stupid locations for php.ini all the
time and have
to manaully move that file to the correct location.
[root@altair htdocs]# cat test.php
<?php phpinfo(); ?>
<? var_dump($GLOBALS['_PHPA']); ?>
On Mon, 2008-06-09 at 04:28 -0700, Pro Green European wrote:
Delays in the connection to the db server is still around 20-30 seconds.
It sounds like the MySQL server is configured to do reverse DNS lookups on incoming connections, and those DNS lookups are timing out. For small systems (a few web servers and a db server) I tend to add the web servers to the system's hosts file, so the mysql server doesn't have to do a DNS lookup for every connection.
Have you checked that the nameservers in resolv.conf on the MySQL server are reachable?
Erek Dyskant wrote:
It sounds like the MySQL server is configured to do reverse DNS lookups on incoming connections, and those DNS lookups are timing out. For small systems (a few web servers and a db server) I tend to add the web servers to the system's hosts file, so the mysql server doesn't have to do a DNS lookup for every connection.
mysqld always does reverse lookup by default. to change that, you need the 'skip-name-resolve' option in the [mysqld] section of your config file ( usually /etc/my.cnf and make sure there is no /var/lig/mysql/my.cnf )
The query log on the database server tells me that there are around 20-30 seconds between each data request from the webserver to the database server. Accessing the same database from another server, Apache/CGI/Mysql or even through the mysql command line is fast, and there are no 20-30 sec delays.
Apache & PHP are the default x86-64 rpm packages that comes with CentOS 5.1:
httpd-devel-2.2.3-11.el5_1.centos.3 httpd-2.2.3-11.el5_1.centos.3 httpd-manual-2.2.3-11.el5_1.centos.3 httpd-devel-2.2.3-11.el5_1.centos.3
php-mbstring-5.1.6-15.el5 php-ldap-5.1.6-15.el5 php-cli-5.1.6-15.el5 php-gd-5.1.6-15.el5 php-common-5.1.6-15.el5 php-5.1.6-15.el5 php-pdo-5.1.6-15.el5 php-mysql-5.1.6-15.el5 php-pear-1.4.9-4
The php.ini file is located in the /etc/ folder.
I also have the same identical site accessing the same database on the same mysql server, running on a CentOS4 server without any problem. Reason for switching server is that I need PHP5 support, and as the CentOS4 based server is a production server, I cannot compile PHP5 from source and use that on the server. I have It is a mystery ;)
I'm starting to wonder if this is a broken hardware issue...
Regards, /mysteron
--- On Mon, 6/9/08, Peter Farrell peter.d.farrell@gmail.com wrote:
From: Peter Farrell peter.d.farrell@gmail.com Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: "CentOS mailing list" centos@centos.org Date: Monday, June 9, 2008, 1:03 PM If it's a table listing check your MySQL settings. How have you set up my.cnf? What does your slow query log tell you? Have you logged into your MySQL server from another machine and ran queries from there? Have you enabled verbose logging for PHP and Apache? Are you tailing all 3 while you run the query from phpadmin? One of them will say something interesting.
I think your issue smells like something in how you compiled PHP or a setting in php.ini itself.
Put a test.php in the doc-root and see what it tells you it's using. (re; mysql & the php version & the location of the php.ini) I've done installs where I had conflicting libs from both PHP and MySQL. Also I get stupid locations for php.ini all the time and have to manaully move that file to the correct location.
[root@altair htdocs]# cat test.php
<?php phpinfo(); ?>
<? var_dump($GLOBALS['_PHPA']); ?>
I generally compile everything when I do a similar install
- and give
explicit declarations to where the apxs is for PHP as well as the root mysql libraries. Check that everything is where you think it is.
*from recent installation of vtiger: (for example)
APACHE 2
--prefix=/data/CRM/apache2 --with-mpm=prefork --enable-ssl --enable-setenvif --enable-proxy --enable-proxy-http --enable-so --disable-charset-lite --disable-include --disable-env --disable-status --disable-autoindex --disable-asis --disable-negotiation --disable-actions --disable-userdir --disable-alias make make install
PHP 5.2.5
--prefix=/data/CRM/php-5.2.5 --with-zlib-dir=/data/CRM/src/rrdbuild/lb --with-gd --with-png-dir=/data/CRM/src/rrdbuild/lb --with-freetype-dir=/data/CRM/src/rrdbuild/lb --with-jpeg-dir=/data/CRM/src/rrdbuild/lb --with-imap=/data/CRM/src/rrdbuild/lb --with-mysql=/usr/local/include/mysql --with-apxs2=/data/CRM/apache2/bin/apxs make make test make install
=====================================================================
XCACHE (this is the PHP accelerator we're using)
*you'll have to force it to see the non-standard install locations we're using. =============== Make a build directory: mkdir xcache-build cd src/xcache-build/ phpize --clean && phpize env CPPFLAGS="-I/data/CRM/php-5.2.5/include -I/data/CRM/apache2/include" LDFLAGS="-L/data/CRM/php-5.2.5/lib -I/data/CRM/apache2/lib" CFLAGS="-O3 -fPIC" ../xcache-1.2.2/configure --prefix=/data/CRM/ --enable-xcache make make install
*You must re-install each time you upgrade or re-compile PHP make distclean && phpize --clean && phpize (now continue w/ original instructions)
Locate a php.ini and copy it to /data/CRM/php-5.2.5/lib/php.ini Append the xcache options to this file: cd ../xcache-1.2.2 cat xcache.ini >> /etc/php.ini
Edit the php.ini to comply with the vtiger installation notes:
;Your php.ini must configured with the following parameters:
; * safe_mode = Off ; * display_errors = On *this is stupid. Turn it off after you tweak vtiger to how you like it. ; * file_uploads = On ; * register_globals = Off ; * max_execution_time = 600 ; * output_buffering= On ; * memory_limit = 32M *is 128 by default - ignore ; * error_reporting = E_WARNING & ~E_NOTICE ; * allow_call_time_reference = On ; * log_errors = Off *again, stupid - ignore ; * short_open_tag= On *again, why the code is a bit crap in vtiger that we'd need to enable this. ; * extension=php_gd2.dll *ignore - it's for windows ; * extension=php_imap.dll *ignore - it's for windows ; * extension=php_mysql.dll *ignore - it's for windows ; * extension=php_mysqli.dll *ignore - it's for windows
===========================================================
-Peter
2008/6/9 Pro Green European pro_green_european@yahoo.com:
Hi.
Have you tried other protocols? Is it really only
http
transfers that are slow?
Yes. Ftp works perfectly, and regular http with
cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
Have you tried pinging 100 times and see if you
get dropped
packets?
0% packet loss
Are there any errors from the netcards showing up
in log
files?
None.
I am really baffeled with this problem. I have no idea
what to do next. Have enabled server-status in Apache and when the scripted site is being access the cpu load is around 2.5%.
Regards, /mysteron
--- On Mon, 6/9/08, Bent Terp bent@nagstrup.dk
wrote:
From: Bent Terp bent@nagstrup.dk Subject: Re: [CentOS] Help, PHP/Mysql connections
are so slow.
To: "CentOS mailing list"
Date: Monday, June 9, 2008, 10:42 AM
communicate with MySQL5. On this server,
PHP/Mysql
connections are dead
slow and unresponsive. It takes sometimes up
to a
minute to list tables
in phpmyadmin for example.
Have you tried other protocols? Is it really only
http
transfers that are slow?
Have you tried pinging 100 times and see if you
get dropped
packets?
Are there any errors from the netcards showing up
in log
files?
BR Bent _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
If the database is on a different server. and the CLI access to mysql is normal. and other php / apache instances can access the database;
then it has to be either a problem with apache <--> php communication or a problem with php <--> mysql communication.
Write a test query in php and execute at the command line on this server and see what output you get.
I think the previous poster that recommended the DNS investigation might have been on to something as well. That 20-30 seconds could be name failure resolution, etc. Worth looking at. In your phpadmin are you giving the FQDN or the IP address? I've many times forgotten to add a new default route w/ multi-homed machines. The DNS explanation would make sense as well if nothing (as you say) is being logged as errors in any of your log files. The delay could be purely DNS related.
Check your httpd: ldd /path/to/httpd for the libs compiled with httpd.
# httpd -l for the moduled compiled into httpd.
cat your httpd.conf and double check your php5 module is included as well.
Really take a minute as well to check your php options.
# php -i
And double check your PATHS and MYSQL_HOME and MYSQL_BIN.
With linux it's always something bitty like this that can screw you up.
-Peter
2008/6/9 Pro Green European pro_green_european@yahoo.com:
The query log on the database server tells me that there are around 20-30 seconds between each data request from the webserver to the database server. Accessing the same database from another server, Apache/CGI/Mysql or even through the mysql command line is fast, and there are no 20-30 sec delays.
Apache & PHP are the default x86-64 rpm packages that comes with CentOS 5.1:
httpd-devel-2.2.3-11.el5_1.centos.3 httpd-2.2.3-11.el5_1.centos.3 httpd-manual-2.2.3-11.el5_1.centos.3 httpd-devel-2.2.3-11.el5_1.centos.3
php-mbstring-5.1.6-15.el5 php-ldap-5.1.6-15.el5 php-cli-5.1.6-15.el5 php-gd-5.1.6-15.el5 php-common-5.1.6-15.el5 php-5.1.6-15.el5 php-pdo-5.1.6-15.el5 php-mysql-5.1.6-15.el5 php-pear-1.4.9-4
The php.ini file is located in the /etc/ folder.
I also have the same identical site accessing the same database on the same mysql server, running on a CentOS4 server without any problem. Reason for switching server is that I need PHP5 support, and as the CentOS4 based server is a production server, I cannot compile PHP5 from source and use that on the server. I have It is a mystery ;)
I'm starting to wonder if this is a broken hardware issue...
Regards, /mysteron
--- On Mon, 6/9/08, Peter Farrell peter.d.farrell@gmail.com wrote:
From: Peter Farrell peter.d.farrell@gmail.com Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: "CentOS mailing list" centos@centos.org Date: Monday, June 9, 2008, 1:03 PM If it's a table listing check your MySQL settings. How have you set up my.cnf? What does your slow query log tell you? Have you logged into your MySQL server from another machine and ran queries from there? Have you enabled verbose logging for PHP and Apache? Are you tailing all 3 while you run the query from phpadmin? One of them will say something interesting.
I think your issue smells like something in how you compiled PHP or a setting in php.ini itself.
Put a test.php in the doc-root and see what it tells you it's using. (re; mysql & the php version & the location of the php.ini) I've done installs where I had conflicting libs from both PHP and MySQL. Also I get stupid locations for php.ini all the time and have to manaully move that file to the correct location.
[root@altair htdocs]# cat test.php
<?php phpinfo(); ?>
<? var_dump($GLOBALS['_PHPA']); ?>
I generally compile everything when I do a similar install
- and give
explicit declarations to where the apxs is for PHP as well as the root mysql libraries. Check that everything is where you think it is.
*from recent installation of vtiger: (for example)
APACHE 2
--prefix=/data/CRM/apache2 --with-mpm=prefork --enable-ssl --enable-setenvif --enable-proxy --enable-proxy-http --enable-so --disable-charset-lite --disable-include --disable-env --disable-status --disable-autoindex --disable-asis --disable-negotiation --disable-actions --disable-userdir --disable-alias make make install
PHP 5.2.5
--prefix=/data/CRM/php-5.2.5 --with-zlib-dir=/data/CRM/src/rrdbuild/lb --with-gd --with-png-dir=/data/CRM/src/rrdbuild/lb --with-freetype-dir=/data/CRM/src/rrdbuild/lb --with-jpeg-dir=/data/CRM/src/rrdbuild/lb --with-imap=/data/CRM/src/rrdbuild/lb --with-mysql=/usr/local/include/mysql --with-apxs2=/data/CRM/apache2/bin/apxs make make test make install
=====================================================================
XCACHE (this is the PHP accelerator we're using)
*you'll have to force it to see the non-standard install locations we're using. =============== Make a build directory: mkdir xcache-build cd src/xcache-build/ phpize --clean && phpize env CPPFLAGS="-I/data/CRM/php-5.2.5/include -I/data/CRM/apache2/include" LDFLAGS="-L/data/CRM/php-5.2.5/lib -I/data/CRM/apache2/lib" CFLAGS="-O3 -fPIC" ../xcache-1.2.2/configure --prefix=/data/CRM/ --enable-xcache make make install
*You must re-install each time you upgrade or re-compile PHP make distclean && phpize --clean && phpize (now continue w/ original instructions)
Locate a php.ini and copy it to /data/CRM/php-5.2.5/lib/php.ini Append the xcache options to this file: cd ../xcache-1.2.2 cat xcache.ini >> /etc/php.ini
Edit the php.ini to comply with the vtiger installation notes:
;Your php.ini must configured with the following parameters:
; * safe_mode = Off ; * display_errors = On *this is stupid. Turn it off after you tweak vtiger to how you like it. ; * file_uploads = On ; * register_globals = Off ; * max_execution_time = 600 ; * output_buffering= On ; * memory_limit = 32M *is 128 by default - ignore ; * error_reporting = E_WARNING & ~E_NOTICE ; * allow_call_time_reference = On ; * log_errors = Off *again, stupid - ignore ; * short_open_tag= On *again, why the code is a bit crap in vtiger that we'd need to enable this. ; * extension=php_gd2.dll *ignore - it's for windows ; * extension=php_imap.dll *ignore - it's for windows ; * extension=php_mysql.dll *ignore - it's for windows ; * extension=php_mysqli.dll *ignore - it's for windows
===========================================================
-Peter
2008/6/9 Pro Green European pro_green_european@yahoo.com:
Hi.
Have you tried other protocols? Is it really only
http
transfers that are slow?
Yes. Ftp works perfectly, and regular http with
cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
Have you tried pinging 100 times and see if you
get dropped
packets?
0% packet loss
Are there any errors from the netcards showing up
in log
files?
None.
I am really baffeled with this problem. I have no idea
what to do next. Have enabled server-status in Apache and when the scripted site is being access the cpu load is around 2.5%.
Regards, /mysteron
--- On Mon, 6/9/08, Bent Terp bent@nagstrup.dk
wrote:
From: Bent Terp bent@nagstrup.dk Subject: Re: [CentOS] Help, PHP/Mysql connections
are so slow.
To: "CentOS mailing list"
Date: Monday, June 9, 2008, 10:42 AM
communicate with MySQL5. On this server,
PHP/Mysql
connections are dead
slow and unresponsive. It takes sometimes up
to a
minute to list tables
in phpmyadmin for example.
Have you tried other protocols? Is it really only
http
transfers that are slow?
Have you tried pinging 100 times and see if you
get dropped
packets?
Are there any errors from the netcards showing up
in log
files?
BR Bent _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Pro Green European wrote on Mon, 9 Jun 2008 03:37:33 -0700 (PDT):
I also have the same identical site accessing the same database on the same mysql server, running on a CentOS4 server without any problem.
How did you move the database? You moved from PHP4 to 5 and from MySQL4 to 5. You *have* to expect problems.
I'm starting to wonder if this is a broken hardware issue...
I think what you have not done yet, is test a simple PHP page with a simple SQL query to a *different* simple, new database with just a few data.
BTW: the mysqladmin list of connections can show the current connection status of queries, the statement etc. and thus help in debugging. The same list can be obtained from within PHPMyadmin.
Kai
Thank you for all your time and replies :)
I solved the problem by switching to RHEL 5.2 x86_64 on the same server. Now PHP/Mysql is working properly.
Strange thing though, every setting is identical to that of the CentOS 5.1 x86_64 install.
Regards, /mysteron
--- On Mon, 6/9/08, Kai Schaetzl maillists@conactive.com wrote:
From: Kai Schaetzl maillists@conactive.com Subject: Re: [CentOS] Help, PHP/Mysql connections are so slow. To: centos@centos.org Date: Monday, June 9, 2008, 2:51 PM Pro Green European wrote on Mon, 9 Jun 2008 03:37:33 -0700 (PDT):
I also have the same identical site accessing the same
database on
the same mysql server, running on a CentOS4 server
without any problem.
How did you move the database? You moved from PHP4 to 5 and from MySQL4 to 5. You *have* to expect problems.
I'm starting to wonder if this is a broken
hardware issue...
I think what you have not done yet, is test a simple PHP page with a simple SQL query to a *different* simple, new database with just a few data.
BTW: the mysqladmin list of connections can show the current connection status of queries, the statement etc. and thus help in debugging. The same list can be obtained from within PHPMyadmin.
Kai
-- Kai Schätzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Pro Green European wrote:
Thank you for all your time and replies :)
I solved the problem by switching to RHEL 5.2 x86_64 on the same server. Now PHP/Mysql is working properly.
Strange thing though, every setting is identical to that of the CentOS 5.1 x86_64 install.
I recall reading something about there being a bug with InnoDB and causing 20-30 second queries with mysql 5.0.22. The solution, I think, was to upgrade to at least MySQL 5.0.30.
What version is RHEL 5.2 running?
I believe this is the bug:
http://bugs.mysql.com/bug.php?id=15815
Regards, Max
- -- # find . "*imbecile" -exec sed -ie "s/stupidity/commonsense/g" '{}' ;
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Ralph Angenendt wrote:
5.0.45 AFAICS.
That would answer the upgrade to at least 5.0.30 part. :) Thanks, Ralph.
Regards, Max
- -- # find . "*imbecile" -exec sed -ie "s/stupidity/commonsense/g" '{}' ;
Yes. Ftp works perfectly, and regular http with cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
What happens if you include a largish file in php? Is that also slow?
Have you tried MySQL without php? Ie a mysql dump'n'reload on the command line?
What's your memory status? (free -m) Swapping is painful....
On Mon, Jun 9, 2008 at 1:05 PM, Bent Terp bent@nagstrup.dk wrote:
Yes. Ftp works perfectly, and regular http with cgi/perl connections to the same database server works perfectly. Also rendering of standard HTML works as it should. It is only when a scripted site uses PHP/Mysql the connection to the server takes forever.
What happens if you include a largish file in php? Is that also slow?
Have you tried MySQL without php? Ie a mysql dump'n'reload on the command line?
Ah well you already tried these.... sorry