I'm running IIS and PHP and we're running into some bottlenecks under load testing. The pages are cached, but sometimes we can get load times up to 30 seconds for a user. This seems to happen when the cache expires. We're looking into a lot of different things to fix this issue, so one of our first places to look is at IIS and PHP. Normally I run PHP under Apache and don't really have these issues. Anyone have some good tips/best practices for running PHP under IIS? We do have FastCGI turned on already.

  • What version of Windows is this running on? – uSlackr May 10 '11 at 19:28
  • Win server 2008 and IIS7 – JoeCianflone May 10 '11 at 20:13

PHP on IIS runs fine. It's not perfect, and it's probably not "optimal", but the marriage of the two is not going to inherently cause 30 second load times.

You will be best served by inserting a timer throughout your PHP code to determine what line(s) are causing the huge delay, if it is indeed an issue on the page generation side. If it's an issue with loading embedded elements, you may be well-served analyzing it with Firebug or the Google Code analysis tools: http://code.google.com/speed/tools.html

  • Yep, I'm looking into all of that stuff too, and this app has a lot of stuff going on under the hood. I just want to make sure that I eliminate as many potential issues as possible. I just know that PHP on Apache runs better normally and I'm looking for some good performance tweaks for PHP on IIS – JoeCianflone May 10 '11 at 20:15
  • 1
    This apepars to be a helpful article on optimizing IIS & PHP learn.iis.net/page.aspx/779/… – uSlackr May 10 '11 at 20:22

Also, one thing to keep in mind, you said there's a lot going on "under the hood" of the app.. I'm assuming there is a database backend. With that being said, if its MySQL I have this text that I've used in the past to help diagnose slow MySQL queries which could be part of the problem. I'm assuming there are similar options with MSSQL, etc.

To enable slow query logging of mysql Enter the following lines in /etc/my.cnf and restart mysql

Enable slow query log This is a great tool for checking what queries take too long log-slow-queries=/tmp/slow_queries.log log-update = /var/lib/mysql/updates.log

MySQL has built-in functionality that allows you to log SQL queries to a file , You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable , The slow query log is used to find queries that take a long time to execute and are therefore candidates for optimization.

To enable you just need to add some lines to your my.cnf file, and restart. Add the following:

To enable slow Query Log only log-slow-queries = /var/log/mysql/mysql-slow.log long_query_time = 1

After enabling slow query, mysqld writes a statement to the slow query log file and it consists of all SQL statements that took more than long_query_time seconds to execute. The time to acquire the initial table locks is not counted as execution time. mysqld only log after SQL statements has been executed and after all locks have been released, so log order might be different from execution order. The minimum and default values of long_query_time are 1 and 10, respectively.

To enable full Log Query log=/var/log/mysqldquery.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.