2

Am running a PHP based web app on our Windows 2008 cloud-based server. The app, which runs fine outside of our environment (e.g. a different IIS server), but is VERY slow in our environment. Based on googling this is a relatively common situation.

I installed PHP and MySQL via the IIS web deployment method...

Here's our setup:

  • Windows 2008 Server Enterprise SP2 (32-bit)
  • Microsoft-IIS/7.0
  • MySQL client version: mysqlnd 5.0.8-dev - 20102224 $Revision: 321634 $
  • PHP extension: mysqli
  • Update for IIS 7.0 FastCGI
  • Windows Cache Extension 1.1 for PHP 5.3

I had read elsewhere that ipv6 might be an issue, so I turned this off on the network adapter.

The app is using: localhost as its connection

Be easy on me, as I'm a bit green about some of these components... Also, rewriting the PHP app or modifying it is NOT an option. I'm reasonably SURE that our config is the issue.

3 Answers 3

4

I had a similar issue. Migrated a php app from iis6 to iis8, and on iis8 was very very slow!

Solution: In the application itself, point it to 127.0.0.1 as the mysql server name (rather than localhost). Seems that there are either resolution issues or IPv6 issues related to using the host name localhost.

127.0.0.1 solves.

2
  • 1
    Our server has IPv6 enabled and this change gave us a 400% speedup.
    – Howie
    Dec 15, 2015 at 9:59
  • 1
    This is a crazy weird fix. Worked for me too. The PHP webpage was talking to local MySQL, changed the config to use 127.0.0.1 and I probably sped it up more than 400%
    – ScottN
    May 7, 2022 at 20:34
1

There is a good presentation on PHP on Windows here

This article suggests you get the non-thread safe php binaries for Windows. Have you looked at that?

Did you use the Microsoft web installer or configure php et al. yourself?

Wincache seems like a good idea too: http://www.iis.net/download/WinCacheForPhp

5
  • I used the Microsoft web installer. How do I know whether I'm running thread-safe or non-thread?
    – Kendor
    Apr 6, 2012 at 16:33
  • Look at phpinfo() for Thread safety.
    – uSlackr
    Apr 6, 2012 at 17:07
  • Thread Safety = disabled
    – Kendor
    Apr 6, 2012 at 17:51
  • Read through the presentation is my best recommendation
    – uSlackr
    Apr 6, 2012 at 19:26
  • 1
    Just FYI, Wincache can lead to frequent server crashes, so I don't recommend it.
    – Vincent
    Jan 31, 2018 at 23:25
1

Based on this blog post, Fix: php mysql is VERY slow, I determined that in my case the problem is a result of MySQL name resolution. Please see this for full documentation, but you should be able to correct the issue by modifying adding the following to your my.ini and restarting mysqld.

# Do cache host names.
skip-host-cache

# Do not resolve hostnames. All hostnames are IP's or 'localhost'.
skip-name-resolve

Your response times should dramatically increase. Unfortunately, you will no longer be able to connect to MySQL using hostnames and will instead be required to use IP addresses.

3
  • can you write your answer in english, please?
    – imel96
    Jun 14, 2013 at 2:15
  • I went ahead and translated that for you, by way of Google. Please feel free to fix it if I misstepped anywhere.
    – Scott Pack
    Jun 14, 2013 at 3:44
  • Have you considered - i mean - FIXING YOUR NAME RESOLUTION? If that takes long the solution is not to disable it, but to fix the bug.
    – TomTom
    Oct 27, 2013 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .