We help IT Professionals succeed at work.

IIS Web Server PHP slow load times - cookie related

YorkData
YorkData asked
on
We currently have a pair of IIS servers using NLB to load balance web requests. We are currently having an issue with one of the servers where it takes a long time on the first visit for the time to first byte. On a repeat visit the load time loads within a normal time.

We have narrowed it down creating the session cookie. If we remove the cookie from the browser the web page takes a long time to load, but when the cookie is already there the page loads normally.

Thanks in advance
Oliver.
Comment
Watch Question

Commented:
I would use process monitor (free Technet tool from Microsoft) and run it on the server that's having the problems. Start capturing, then replicate the problem and stop capturing. Filter the results down to the IIS/PHP process(es) and look for any issues related to the session data being written.

Also, check your php.ini file and find out where your session files are being stored. Then create a standalone PHP script that tries to create a new file in that same folder and see if it takes a long time to do so.

Author

Commented:
Ok so we have pinpointed it to the session files not being destroyed.. It ended up with 2million session files in folder which was fun to delete.

I've checked permisisons on both IIS servers and they are exactly the same, the files themselves have exactly the same permission also but I can see the session files are still not being removed.

Any clues? We run each website with its own user which is in the permissions of the file.

Thanks.
Commented:
That sounds strange. I'm not sure why IIS wouldn't clean up session files automatically. I'm assuming that those 2 million sessions also included very old sessions (session files that were last modified over a day ago, for example)?

I would check out this page and pay attention to the session configuration section at the bottom:
http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/install-and-configure-php

Also, if you're not using the FastCGI approach mentioned in that same guide, it's worth checking out. Not only is it faster (performance-wise), but it separates out PHP to its own process, which can be much easier to debug than trying to monitor what IIS does.
Commented:
We are using FastCGI.. I've ended up running a script on the Temp folder to clean up the session files every day. Thanks for your help.

Script below
forfiles /P C:\Windows\Temp\ /S /M sess* /D -4 /C "cmd /c del @PATH"

Commented:
Thanks. One side note - if you're using FastCGI, then it's likely running as its own process. If the user running that FastCGI process doesn't have full privileges to the temp folder where the sessions are stored, then it might be unable to remove those sessions. You really shouldn't have to manually clean up files.

Author

Commented:
my solution also resolved the issue.