Search code examples
phpiiscpu-usagewincache

Wincache extension has no impact on IIS 7.5


On my IIS 7.5 webserver I am running PHP 5.6 together with the wincache extension (1.3.6.1) for caching the opcode of my PHP scripts. This is supposed to reduce CPU load on the server, because the PHP scripts don't have to be recompiled every time a request comes in.

However I don't see the CPU load decreasing noticably. With 3 clients my web service is practically maxed out (80% cpu utilization on average) and that's just as much as without wincache.

Here's the relevant section from php.ini

[PHP_WINCACHE]
extension=php_wincache.dll
; Full reference: http://php.net/manual/en/wincache.configuration.php
wincache.fcenabled = 0
wincache.ocenabled = 1
wincache.ucenabled = 0
wincache.fcachesize = 64
wincache.fcndetect = 0
wincache.maxfilesize = 256
wincache.chkinterval = 10
wincache.enablecli = 0

I had to disable file caching, because of this: https://serverfault.com/questions/643458/failure-in-php-minit-functionwincache-with-wordpress-microsoft-azure-and-iis

print_r(wincache_ocache_fileinfo()) prints this:

Array
(
    [total_cache_uptime] => 303
    [is_local_cache] => 1
    [total_file_count] => 42
    [total_hit_count] => 32160
    [total_miss_count] => 42
    [file_entries] => Array
    ... (skipped precise file info for brevity)

And print_r(wincache_ocache_meminfo()) gives me this:

Array
(
    [memory_total] => 100663296
    [memory_free] => 99769616
    [num_used_blks] => 1677
    [num_free_blks] => 1
    [memory_overhead] => 26880
)

Any suggestions on why I don't see wincache having any impact? What else can I try to reduce CPU load on my webserver?


Solution

  • So it looks as if PHP now has an inbuilt opcode cache, the Zend Opcache. Activating/configuring that instead of Wincache worked for me. I now see the caching of opcode having an effect, although it's not as big as I expected it to be.

    From PHP 5.5 on one can activate the Zend Opcache extension by adding the following lines to php.ini:

    zend_extension=php_opcache.dll
    [opcache]
    opcache.enable=1
    

    Also see this page on how to configure/tweak the Zend Opcode extension: http://php.net/manual/en/book.opcache.php