Tip #94: Did you know … How to improve the performance of PHP application on Windows?

Today the Microsoft IIS team has released the beta of the Windows Cache Extension 1.0 for PHP.

The Windows Cache Extension for PHP is a PHP accelerator, that is used to increase the speed of PHP applications running on the Windows operating systems.

Any PHP application can take advantage of the functionality provided by the Windows Cache Extension for PHP without any code modifications. All that is required is that the extension is enabled and loaded by the PHP engine.

Install the Windows Cache Extension 1.0 for PHP - Beta

clip_image002

or, download:

Windows Cache Extension 1.0 for PHP 5.2 - Beta

Windows Cache Extension 1.0 for PHP 5.3 – Beta

Follow the instructions at "Using Windows Cache Extension for PHP" to install, enable and configure the extension.

Note:

  • The extension can only be used with non-thread-safe builds of PHP
  • The extension can only be used when IIS is configured to run PHP via FastCGI
  • The Windows Cache Extension 1.0 for PHP 5.3 can only be used with the x86 VC9 build of PHP 5.3.
Benefits and Features

The extension includes three caches that can be enabled or disabled independently of each other:

  • PHP opcode cache - PHP is a script processing engine, which reads an input stream of data that contains text and/or PHP instructions and produces another stream of data, most commonly in the HTML format. This means that on a web server the PHP engine reads, parses, compiles and executes a PHP script each time that it is requested by a Web client. The reading, parsing and compilation operations put additional load on the web server's CPU and file system and thus affect the overall performance of a PHP web application. The PHP bytecode (opcode) cache is used to store the compiled script bytecode in shared memory so that it can be re-used by PHP engine for subsequent executions of the same script.
  • File cache - Even with the PHP bytecode cache enabled, the PHP engine has to accesses the script files on a file system. When PHP scripts are stored on a remote UNC file share, the file operations introduce a significant performance overhead. The Windows Cache Extension for PHP includes a file cache that is used to store the content of the PHP script files in shared memory, which reduces the amount of file system operations performed by PHP engine.
  • Relative file path cache - PHP scripts very often include or operate with files by using relative file paths. Every relative file path has to be converted to an absolute file path by the PHP engine. When a PHP application uses many PHP files and accesses them by relative paths, the operation of resolving relative paths to absolute paths may negatively impact the application's performance. The Windows Cache Extension for PHP provides a Relative File Path cache, which is used to store the mappings between relative and absolute file paths, thereby reducing the number of relative path resolutions that the PHP engine has to perform.
More information

Use the Windows Cache Extension for PHP Forum to ask questions, report bugs and provide feature suggestions.

Don Raman
SDET, IIS Team