php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44497 file_exists() slow on samba server.
Submitted: 2008-03-21 15:10 UTC Modified: 2008-04-02 09:38 UTC
From: damien at zaide dot org Assigned: fb-req-jani (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.5 OS: Windows 2003 Server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: damien at zaide dot org
New email:
PHP Version: OS:

 

 [2008-03-21 15:10 UTC] damien at zaide dot org
Description:
------------
Hi,
I have installed php on our Windows 2003 Server from 1 or 2 year but we have a recurrent problem.
The MySQL connection is very slow, Php is fast but when it use Mysql the performance fall.
I have made some research to fix the bug.
Firstly think it was a DNS problem because the mysql on not on the localhost but on a remote server (Debian 4.0 with MySQL 5).
So i insert the resolv DNS in the host file, but it didn't solve.

After this i monitor my MySQL server to check if it come from him, so i make the request to the page on my Win2k3 server and receive the MySQL connection just 5/10 seconds after my request (and 1 or 2 second after my page is printed) ... So the problem is on the Win2k3 side.

I have checked if the libmysql.dll is in a directory in the PATH variables. And it was.

The sames scripts (PhpBB and other) run very fast on our Linux server, on the same MySQL server asked.

If you want me to trace a process, or debug something there is no problem ;)
Thanks

Reproduce code:
---------------
Use a phpbb or a huge php/mysql script

Expected result:
----------------
Run quickly

Actual result:
--------------
The request is very long

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-25 15:22 UTC] damien at zaide dot org
I have setting up the cvs version and the problem occurs again.
 [2008-03-25 19:30 UTC] jani@php.net
And you really updated ALL dlls using the ones from the snapshot package?
 [2008-03-25 23:38 UTC] damien at zaide dot org
Yes i have copied the .dll/.exe/.lib from the .zip to my C:\Program Files\PHP directory.
Then restart IIS and the problem occurs again.
 [2008-03-26 10:36 UTC] damien at zaide dot org
More informations :
- The problem occurs since the php installation with the installation package. So i have the problem from the beggining i start using php with IIS.
- My customers php files is on a Samba Server and PHP is installed on 2 HTTP servers (load balancing answer) and the problem occurs for both.
- I have no problem with ODBC MySQL connector (fast connection) and ASP run fast on these servers.
- I have set to "on" the "output_buffering" option. I have see it could solve my problem but no finally.
- I have "C:\Program Files\PHP" in my PATH variable.

I think the progress of the execution of this script is like this:
1/ File is loaded from the samba server. Everything is OK.
2/ Php is launched and start interpreting it. Everything is OK.
3/ Php needs to use MySQL ! The slowdown occurs here. Maybe problem to locate phpmysql.dll or anything else.
4/ Php contacts MySQL Server and sends requests. Eveything is OK.
5/ Php prints result to the browser.
 [2008-03-26 12:02 UTC] jani@php.net
How exactly are you connecting to Mysql? Exactly _what_ line is used? Do you connect using the IP of the mysql server?
 [2008-03-26 13:57 UTC] damien at zaide dot org
I have tested with the fqdn and with the IP address, result is the same.
I have added the fqdn in my host file in windows and result is the same.
It's big application like phpbb or joomla who get this problem ... So i think they use mysql_connect(). I haven't tested small scripts on the servers.
 [2008-03-26 21:27 UTC] jani@php.net
Try the smallest possible script. Just "mysql_connect()" with proper parameters..
 [2008-03-27 15:25 UTC] damien at zaide dot org
I have make a very small script and the connection, execution is fast.
Everything is fine. Very strange.

Here the small script:
$db_link = mysql_connect("xxxxx", "user", "pass");
mysql_select_db("database");
$ret = mysql_query("SELECT * FROM zp_options");
while ($tmp = mysql_fetch_array($ret))
  print_r($tmp);
mysql_close($db_link);
 [2008-03-29 17:57 UTC] jani@php.net
Then you need to figure out what really is the bottleneck. It doesn't seem to be mysql_connect(), so check the phpbb/joomla/whatever you're experiencing with, what they're actually using to connnect to mysql. I'd use something like Xdebug to figure out where the real problem is..
 [2008-03-31 13:36 UTC] damien at zaide dot org
I have seting-up the xdebug module on 1 of our production server.
I got a big backtrace for the script and i take 16 seconds to get executed.

Finally I have see that some operation on files take severals times, like file_exists(), example:
   3.2642    1477720               -> file_exists('\\\\192.168.0.1\\windows\\website\\ssp_director\\app\\vendors\\cache_engines/file.php') \\192.168.0.1\windows\website\ssp_director\app\cake\basics.php:621
                                     >=> FALSE
    3.4922    1477840               -> file_exists('\\\\192.168.0.1\\windows\\website\\ssp_director\\app\\vendors\\cache_engines/file.php') \\192.168.0.1\windows\website\ssp_director\app\cake\basics.php:623

So this function take 228ms to execute, and the file_exists is executed 30 times so 7 seconds only for this function.
Every access to the files on the server seems to be quite slow. Does php for windows use a special lock system who is slow on the samba server?
 [2008-04-02 09:38 UTC] jani@php.net
No, this is just inherent behaviour and nothing to do with PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 01:01:30 2024 UTC