New install of Win2008 and IIS7... setup php using following instructions http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/
php pages are slow, especially the ones that connect to the mysql database. One page in particular will take so long that I get a 500 error (assuming this is timeout problem).
I am only calling up 10 records with 2 fields to display.
PHP error log shows nothing. IIS log shows nothing relating to this problem.
I have copied the exact code to our IIS6 server and the pages come up fast. I coped the pages to the Apache/Windows server and the pages come up fast.
Have you compared the php.ini from your IIS 6 server to your IIS 7 server? I can't think of anything off the top of my head that would cause PHP to be slow on IIS other than networking related issues such as TCP/IP connectivity/name resolution, etc. Is
it just PHP that is slow, or is other content served by IIS slow as well?
----------------
Dominic Ryan
Microsoft IIS MVP
IIS Aid IIS and Open Source
HTML pages come up fine. the php page is fine as long as their is no mysql connection from what I can tell.
Slow down with PHP pages connecting to MySQL locally are slow too. This one particular page will take 5 - 10 seconds to display and at times a 500 error will occur or content is blank.
What happens if you run the SQL locally via the MySQL command line client? Does it still take a long time? Might be an idea to enable the MySQL slow query log if you haven't already.
----------------
Dominic Ryan
Microsoft IIS MVP
IIS Aid IIS and Open Source
What version of PHP are you using? I've heard anecdotally that some people have database connectivity issues with 5.2.6...you might try going back to 5.2.5 to see if it gets any better. bill
Anyone have more insight in how to troubleshoot and remedy this? PH 4 currently outperfoms PHP 5 10 fold using FCCGI for us, in fact PHP 5 is so slow using MySQL as to be unusable.
I haven’t tried ISAPI as I am using NTS version of PHP5(problem still occurs on TS version, but I will try TS ISAPI). Problem does not happen using FCGI on IIS 6. MySQL is on a dedicated server separate to the
web server, so network connection are being made(latency <1ms and gigabit links). PHP 4 running FCGI works fine, PHP 5 slow as a dog(as in times out 8 out of 10 times) and really have run out of ideas, communication appears fine between the servers otherwise.
Platform is as such. Web edition web servers, with content stored on file server, accessed via UNC paths with AD authentication. Problem still occurs if data
stored on local drives with local users however, and even if I install MySQL on the web server performance is no better. Only thing I can think of is that the web servers are virtualised on Xen and/or the MySQL server runs Linux, but am not sure how to dig
deeper to see where the problem lies. Problem is with FCGI PHP 5 and MySQL only, other languages(classic asp, ASP.net, Perl) all working fine when using MySQL as the data store.
You're right, that doesn't seem to make a whole lot of sense on face value. So you're saying that PHP 4 using FastCGI on the same servers, connecting to the same MySQL server and running the same PHP application is performing better? Is this custom code,
or are you using a publically available PHP app? What sort of page loading times are we talking about (2 secs, 5 secs, etc)?
----------------
Dominic Ryan
Microsoft IIS MVP
IIS Aid IIS and Open Source
If it is timing out (rather than just running slow) I'd be looking at enabling and checking your php log. Rather than bothering with ISAPI I would give normal CGI a go as it's output can sometimes be a little more verbose than the other API's.
----------------
Dominic Ryan
Microsoft IIS MVP
IIS Aid IIS and Open Source
We switched over to fastcgi on friday so we could move to the new sqlsrv driver for php. However, we no have the delay problem as described above.
I tried the mysql solution to turn of the dns lookup, but this had not effect.
The problem is not related to the sqlsrv driver, as we have not implemented it.
Under isapi, the system runs correctly. But after switching to fastcgi and following the guide at http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/, it now performs very slowly.
Whilst observing the mysql perfromance, only towards the end of the 15 second response time, does the mysql kick in and the queries are seen coming through.
What I don't understand is why under isapi it works fine, but under fastcgi it doesn't, ans furthermore, how could this be then related to mysql?
I can imagine two possible sources for this problem:
<div mce_keep="true">IPv6 is enabled and localhost does not exist or ::1</div>
<div mce_keep="true">Mysql's libmysql is used instead of PHP's libmysql.</div>
It happens that the IPv6 problem was the cause for this problem (as you stated later). The 2nd possibility happens a lot when someone installs mysql after PHP, or do a mysql update after having installed PHP.
The latest Mysql's libmysql is not compatible with php's libmysql (and many other, that's not a php specific problem). They suffer from ABI compatibilities issues. The solution is to alter your PATH to be sure that php is first defined( PATH=c:\PHP;c:\mysql
for example).
I solved the problem be starting with the php.ini-recommended file and building it up slowly to what I needed, removing some extensions in the process. Unfortunately I could not find what was causing the speed problem, which is a little frustrating.
However, I think the solution i found illustrates a strategy that should ideally be taken when upgrading / changing php modes / version. Start first with the basic setup, and slowly updated the settings to be equal or at least the base requirements of ones
own system.
Just making the changes to the current php.ini file for the new setup is not really ideal.
I have read this post many times and tried all possible solutions. None of them worked for me. So I will share my solution with you guys. It as simple as can be sometimes...
We had fastcgi setup on IIS7 and php installed on our d: drive in the dir d:\php5. Yes the NTS version. Pages we're really loading slow and f.e. a zencart shop would take about 4 seconds to load. Then finally after a lot of testing (and i mean a lot: different
faster hardware, parse times, query times and so on) i found out that installing php with the web platform installer in the default directory C:\Program Files (x86)\PHP solved all our performance issues!
I had the same problem. Had me baffled for hours. But, it would appear that is an IPv6 issue or and issue with localhost to be precise. With IPv6 enabled, PHP struggl;es to resolve localhost to the loopback address of
127.0.0.1.
You can disable IPv6, but if you need to leave IPv6 enabled changing 'localhost' to '127.0.0.1' in your scripts haas the same result. Maybe this will be addressed in the next version of PHP?
I had the same problem. Had me baffled for hours. But, it would appear that is an IPv6 issue or and issue with localhost to be precise. With IPv6 enabled, PHP struggl;es to resolve localhost to the loopback address of
127.0.0.1.
You can disable IPv6, but if you need to leave IPv6 enabled changing 'localhost' to '127.0.0.1' in your scripts haas the same result. Maybe this will be addressed in the next version of PHP?
I know this is an old discussion, but I thought I'd just reply to say qwarrior's post instantly solved my slow loading issue.
Having uninstalled PHP, reinstalled using Web Platform installer, changing PHP install from thread safe to non-thread safe and a multitude of other suggestions I found, simply changing the db connection settings in the PHP script from localhost to 127.0.0.1
transformed the PHP site from very slow loading to virtually instantaneous.
The eventual install was through Web Platform Installer with PHP 5.3.7 on IIS 7 with FastCGI update.
I am also having this issue although in my case it is random. sometimes pages will load fine and then randomly some pages will take ages to load. MySQL is not on the same server so it is not a localhost/ipv6 issue. I am using the Web Platform Installer default
PHP 5.3.x install with fastcgi. I have also installed the latest wincache update to fix known php issues.
we has iis7, php5.3.10, mysql running on one box. Our problem is that first byte response slow, even i used 127.0.0.1 as the connection host, it doesn't work. Someone talked about ipv6 issue. we set the Type 0xffffffff to disable all IPv6 components in regedit.
how to disable ipv6 link http://support.microsoft.com/kb/929852 anyone knows how to solve the problem?
We've had that problem long time ago. We found out that ( for us) it had to do with the order we've installed PHP and MySql. But I can't remember which one had to be first... I know we've de-installed both and re-installed it after. Logically I would think
it has to be PHP. Maybe this works for you too. Good luck!
I am having more of a random issue. every so often pages on any php sites will go slow and might take a minute or more to load, then if I reload the page it will be fine. MySQL is not on the same server, so it is not a localhost issue.
I have a Windows Server 2008R2 Environment with IIS7 and PHP 5.3.
When working with php based CMS's, mainly Wordpress, it was awfully slooooow!
I thought it has something to do with slow MySQL connection issues (for the machine is also running SQL Server), so I purposely set up a Linux Server from an old PC, just to install MySQL.
Same issue, so it was clear it had nothing to do with MySQL..
Then I checked php.ini line by line, and I found that my problem was related with this particular setting:
Using 127.0.0.1 instead of localhost for connecting to MySQL worked for me as well (MySQL 5.5,PHP 5.3.28, IIS 8). My web page loads went from 3-6 seconds to less than 2.
11 Posts
PHP very slow on IIS7
Nov 30, 2008 04:20 PM|SWD|LINK
New install of Win2008 and IIS7... setup php using following instructions http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/
php pages are slow, especially the ones that connect to the mysql database. One page in particular will take so long that I get a 500 error (assuming this is timeout problem).
I am only calling up 10 records with 2 fields to display.
PHP error log shows nothing. IIS log shows nothing relating to this problem.
I have copied the exact code to our IIS6 server and the pages come up fast. I coped the pages to the Apache/Windows server and the pages come up fast.
This tells me something wrong on the IIS7 server.
How to resolve??
Thank you!
387 Posts
Re: PHP very slow on IIS7
Nov 30, 2008 06:27 PM|brashquido|LINK
Have you compared the php.ini from your IIS 6 server to your IIS 7 server? I can't think of anything off the top of my head that would cause PHP to be slow on IIS other than networking related issues such as TCP/IP connectivity/name resolution, etc. Is it just PHP that is slow, or is other content served by IIS slow as well?
Dominic Ryan
Microsoft IIS MVP
IIS Aid
IIS and Open Source
11 Posts
Re: PHP very slow on IIS7
Dec 01, 2008 12:32 AM|SWD|LINK
IIS6 is using ISAPI.
HTML pages come up fine. the php page is fine as long as their is no mysql connection from what I can tell.
Slow down with PHP pages connecting to MySQL locally are slow too. This one particular page will take 5 - 10 seconds to display and at times a 500 error will occur or content is blank.
387 Posts
Re: PHP very slow on IIS7
Dec 01, 2008 04:42 AM|brashquido|LINK
What happens if you run the SQL locally via the MySQL command line client? Does it still take a long time? Might be an idea to enable the MySQL slow query log if you haven't already.
Dominic Ryan
Microsoft IIS MVP
IIS Aid
IIS and Open Source
415 Posts
Microsoft
Re: PHP very slow on IIS7
Dec 05, 2008 06:28 PM|bills|LINK
Bill Staples
Product Unit Manager, IIS
blog: http://blogs.iis.net/bills
11 Posts
Re: PHP very slow on IIS7
Dec 05, 2008 06:54 PM|SWD|LINK
Thanks to everyone for help. Figured out the problem was a tcp/ip problem between iis7 server and mysql server!
58 Posts
Re: PHP very slow on IIS7
Dec 07, 2008 03:30 AM|festuc|LINK
Can you tell us more about the problem and how you have resolved it?
Thanks.
5 Posts
Re: PHP very slow on IIS7
Jun 01, 2009 07:46 AM|Onionman|LINK
Anyone have more insight in how to troubleshoot and remedy this? PH 4 currently outperfoms PHP 5 10 fold using FCCGI for us, in fact PHP 5 is so slow using MySQL as to be unusable.
387 Posts
Re: PHP very slow on IIS7
Jun 02, 2009 07:09 PM|brashquido|LINK
Dominic Ryan
Microsoft IIS MVP
IIS Aid
IIS and Open Source
5 Posts
Re: PHP very slow on IIS7
Jun 02, 2009 08:03 PM|Onionman|LINK
I haven’t tried ISAPI as I am using NTS version of PHP5(problem still occurs on TS version, but I will try TS ISAPI). Problem does not happen using FCGI on IIS 6. MySQL is on a dedicated server separate to the web server, so network connection are being made(latency <1ms and gigabit links). PHP 4 running FCGI works fine, PHP 5 slow as a dog(as in times out 8 out of 10 times) and really have run out of ideas, communication appears fine between the servers otherwise.
Platform is as such. Web edition web servers, with content stored on file server, accessed via UNC paths with AD authentication. Problem still occurs if data stored on local drives with local users however, and even if I install MySQL on the web server performance is no better. Only thing I can think of is that the web servers are virtualised on Xen and/or the MySQL server runs Linux, but am not sure how to dig deeper to see where the problem lies. Problem is with FCGI PHP 5 and MySQL only, other languages(classic asp, ASP.net, Perl) all working fine when using MySQL as the data store.387 Posts
Re: PHP very slow on IIS7
Jun 03, 2009 01:20 AM|brashquido|LINK
You're right, that doesn't seem to make a whole lot of sense on face value. So you're saying that PHP 4 using FastCGI on the same servers, connecting to the same MySQL server and running the same PHP application is performing better? Is this custom code, or are you using a publically available PHP app? What sort of page loading times are we talking about (2 secs, 5 secs, etc)?
Dominic Ryan
Microsoft IIS MVP
IIS Aid
IIS and Open Source
5 Posts
Re: PHP very slow on IIS7
Jun 03, 2009 04:07 AM|Onionman|LINK
All PHP code that makes mysql connections (wordpress, Joomla, Drupal) etc.
PHP 4 loading times - normal ~1 second. PHP 5 same application (Joomla just tested on) Timout after 30 seconds. Same server.
387 Posts
Re: PHP very slow on IIS7
Jun 03, 2009 09:07 AM|brashquido|LINK
Dominic Ryan
Microsoft IIS MVP
IIS Aid
IIS and Open Source
2 Posts
Re: PHP very slow on IIS7
Sep 20, 2009 06:00 AM|lordg|LINK
Hi Guys,
We switched over to fastcgi on friday so we could move to the new sqlsrv driver for php. However, we no have the delay problem as described above.
I tried the mysql solution to turn of the dns lookup, but this had not effect.
The problem is not related to the sqlsrv driver, as we have not implemented it.
Under isapi, the system runs correctly. But after switching to fastcgi and following the guide at http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/, it now performs very slowly.
Whilst observing the mysql perfromance, only towards the end of the 15 second response time, does the mysql kick in and the queries are seen coming through.
What I don't understand is why under isapi it works fine, but under fastcgi it doesn't, ans furthermore, how could this be then related to mysql?
Would greatly appreciate anyones input.
Thanks.
G
387 Posts
Re: PHP very slow on IIS7
Sep 24, 2009 03:34 AM|brashquido|LINK
Have you tried under standard CGI? Also, have you set up your PHP logging?
Dominic Ryan
Microsoft IIS MVP
IIS Aid
IIS and Open Source
66 Posts
Re: PHP very slow on IIS7
Sep 24, 2009 05:57 AM|pierrejoye|LINK
I can imagine two possible sources for this problem:
It happens that the IPv6 problem was the cause for this problem (as you stated later). The 2nd possibility happens a lot when someone installs mysql after PHP, or do a mysql update after having installed PHP.
The latest Mysql's libmysql is not compatible with php's libmysql (and many other, that's not a php specific problem). They suffer from ABI compatibilities issues. The solution is to alter your PATH to be sure that php is first defined( PATH=c:\PHP;c:\mysql for example).
PHP mysql ipv6 timeout error 500
2 Posts
Re: PHP very slow on IIS7
Sep 24, 2009 08:36 AM|lordg|LINK
Hi Brash and Pierre,
I meant to update this post!
I solved the problem be starting with the php.ini-recommended file and building it up slowly to what I needed, removing some extensions in the process. Unfortunately I could not find what was causing the speed problem, which is a little frustrating.
However, I think the solution i found illustrates a strategy that should ideally be taken when upgrading / changing php modes / version. Start first with the basic setup, and slowly updated the settings to be equal or at least the base requirements of ones own system.
Just making the changes to the current php.ini file for the new setup is not really ideal.
So, my lesson learnt!
Thanks for the advice though.
G.
2 Posts
Re: PHP very slow on IIS7
Nov 29, 2009 03:26 PM|RinseD|LINK
Hello,
As I have the same problem and your solution seems to be worth the try, can you tell me in what file I need to set the path?
Thanks!
30 Posts
Re: PHP very slow on IIS7
Jan 04, 2010 02:43 PM|DubOhio|LINK
My problme was resolved by disabling IPv6
11 Posts
Re: PHP very slow on IIS7
Mar 18, 2010 09:03 AM|ronaldk|LINK
Hello Guys,
I have read this post many times and tried all possible solutions. None of them worked for me. So I will share my solution with you guys. It as simple as can be sometimes...
We had fastcgi setup on IIS7 and php installed on our d: drive in the dir d:\php5. Yes the NTS version. Pages we're really loading slow and f.e. a zencart shop would take about 4 seconds to load. Then finally after a lot of testing (and i mean a lot: different faster hardware, parse times, query times and so on) i found out that installing php with the web platform installer in the default directory C:\Program Files (x86)\PHP solved all our performance issues!
Ronald Kunenborg
Reda Internet.
10 Posts
Re: PHP very slow on IIS7
May 04, 2010 01:53 AM|yourguide|LINK
I thought PHP was slow on IIS7 for me also... but I think it is actually a MySQL thing for me.
1 Post
Re: PHP very slow on IIS7
May 11, 2010 01:47 PM|qwarrior|LINK
I had the same problem. Had me baffled for hours. But, it would appear that is an IPv6 issue or and issue with localhost to be precise. With IPv6 enabled, PHP struggl;es to resolve localhost to the loopback address of 127.0.0.1.
You can disable IPv6, but if you need to leave IPv6 enabled changing 'localhost' to '127.0.0.1' in your scripts haas the same result. Maybe this will be addressed in the next version of PHP?
1 Post
Re: PHP very slow on IIS7
Jul 18, 2011 05:24 PM|florenhg|LINK
I had similar problem updating 5.2 to 5.3. The only solution was downgrade to 5.2. Must be a bug on 5.3.
1 Post
Re: PHP very slow on IIS7
Aug 18, 2011 02:31 PM|richyrich|LINK
Having uninstalled PHP, reinstalled using Web Platform installer, changing PHP install from thread safe to non-thread safe and a multitude of other suggestions I found, simply changing the db connection settings in the PHP script from localhost to 127.0.0.1 transformed the PHP site from very slow loading to virtually instantaneous.
The eventual install was through Web Platform Installer with PHP 5.3.7 on IIS 7 with FastCGI update.
Thanks for posting this! :)
4 Posts
Re: PHP very slow on IIS7
Jan 13, 2012 02:11 PM|mknebel|LINK
Same issue - now fixed. Changed "localhost" for MySql Connections in my PHP code to "127.0.0.1". Instantly fixed. Must be the IPv6 issue noted.
Thanks to everyone for your posts!!
2 Posts
Re: PHP very slow on IIS7
Feb 27, 2012 04:36 PM|bfaulk1|LINK
For me as well the solution recommended by qwarrior took care of the issue here. We have PHP 5.3.10, if that helps.
-bill
61 Posts
Re: PHP very slow on IIS7
Feb 29, 2012 07:29 AM|russmichaels|LINK
1 Post
Re: PHP very slow on IIS7
Apr 10, 2012 04:05 AM|williamnz|LINK
2 Posts
Re: PHP very slow on IIS7
Apr 10, 2012 04:15 AM|RinseD|LINK
61 Posts
Re: PHP very slow on IIS7
Jun 27, 2012 08:59 AM|russmichaels|LINK
1 Post
Re: PHP very slow on IIS7
Feb 06, 2014 02:29 PM|this.functional|LINK
Hi lordg,
I have a Windows Server 2008R2 Environment with IIS7 and PHP 5.3.
When working with php based CMS's, mainly Wordpress, it was awfully slooooow!
I thought it has something to do with slow MySQL connection issues (for the machine is also running SQL Server), so I purposely set up a Linux Server from an old PC, just to install MySQL.
Same issue, so it was clear it had nothing to do with MySQL..
Then I checked php.ini line by line, and I found that my problem was related with this particular setting:
output_buffering = 4096
I changed it to output_buffering = Off
Now it's running like a breeze
Thanks for suggesting to check php.ini!!
1 Post
Re: PHP very slow on IIS7
Apr 15, 2016 10:28 PM|ctrlaltdl|LINK
Using 127.0.0.1 instead of localhost for connecting to MySQL worked for me as well (MySQL 5.5,PHP 5.3.28, IIS 8). My web page loads went from 3-6 seconds to less than 2.