PHP factor 30 performance difference from Linux to Windows PHP factor 30 performance difference from Linux to Windows wordpress wordpress

PHP factor 30 performance difference from Linux to Windows


Windows has lots of services/policies that restrict, prevent, protect, control and etc usage of the computer in every situation.

A good Microsoft certified specialist will be able to solve your question within minutes, because they will have the experience to tell exactly which settings/services/policies to check and disable/enable/change settings, so that the PHP scripts are executed faster.

Out of my memory, I can only suggest you to check everything that deals with RAM, Hard Drive access, Environmental variables, Limits and Security (like Firewall). Everything that can affect the execution of php script, starting with some Remote Procedue Call policies and ending with the operating stack memory.

The logic is that is php.exe calls some external .dll file to execute some operation, there might be checks on the way done by OS, that will slow both sending request via such .dll, and receiving the response from it. If the .dll uses hard drive to access something - hard drive access policies enter into the scene. Also, how everything is situated in the memory - in RAM or hard-drive cache of RAM. Application policies. Threads policies. Limits on max percentage available for use for applications.

I am not saying that Windows-based hosts are bad, just that they are much more difficult to setup properly for a general admin. If you have Microsoft specialist on hands, he can tune your server to be as fast as Linux-based server.


  • enable APC, when using PHP5.4

    • if you do not notice a speed gain, when APC is on, something is misconfigured

      [APC]extension=php_apc.dllapc.enabled=1apc.shm_segments=1apc.shm_size=128Mapc.num_files_hint=7000apc.user_entries_hint=4096apc.ttl=7200apc.user_ttl=7200

  • enable Zend Opcode when on PHP 5.5

    [Zend]zend_extension=ext/php_zend.dllzend_optimizerplus.enable=1zend_optimizerplus.use_cwd=1zend_optimizerplus.validate_timestamp=0zend_optimizerplus.revalidate_freq=2
    zend_optimizerplus.revalidate_path=0zend_optimizerplus.dups_fix=0zend_optimizerplus.log_verbosity_level=1zend_optimizerplus.memory_consumption=128zend_optimizerplus.interned_strings_buffer=16zend_optimizerplus.max_accelerated_files=2000zend_optimizerplus.max_wasted_percentage=25zend_optimizerplus.consistency_checks=0zend_optimizerplus.force_restart_timeout=60zend_optimizerplus.blacklist_filename=zend_optimizerplus.fast_shutdown=0zend_optimizerplus.optimization_level=0xfffffbbfzend_optimizerplus.enable_slow_optimizations=1opcache.memory_consumption=128opcache.interned_strings_buffer=8opcache.max_accelerated_files=10000opcache.revalidate_freq=60opcache.fast_shutdown=1opcache.enable_cli=1

  • disable Wordpress extensions step-wise, to find the memory usage monster

  • set Wordpress: define('WP_MEMORY_LIMIT', '128M');, unless you use image converting plugins that should suffice
  • set unlimited memory in php.ini ini_set('memory_limit', -1);
  • profile without running Xdebug, this sounds crazy, but the debugger itself has a high impact
  • use memory_get_usage and spread calls all over the system to find the code position, where the memory leaks
  • give zend.enable_gc=1 a try, scripts will be slower, but use less memory
  • maybe just disable checking for the user browser in the SlimStats settings..
  • if that is not possible, try to override SlimStats getBrowser() function, with a faster getBrowser() substitute
  • for a speed comparison of user-agent fetchers, see https://github.com/quentin389/ua-speed-tests
  • https://github.com/garetjax/phpbrowscap


I took a look at that plugin on Github:

https://github.com/wp-plugins/wp-slimstat

And the offending file being included is a filethat has been minified to some degree and reallyis data (not code), there are 5 variations each ofwhich is about 400KB

There is also that maxmind.dat file that is 400KB,although I don't know if it uses both.

You are using an older version of the plugin, version3.2.3 and there is a much newer one that may solveyour problem.

Comparing the differences is hard because the authoror whoever has not kept the git history in order,so I had to manually diff the file. Most of the changesrelated to _get_browser seem to be adding a cache.

It's possible loading that file is slow to parse, butI would expect PHP to be load both files at similarrates in both platforms granted that IO caching isworking.

EDIT Looking a bit closer that might not solve yourproblem. Those files are basically large Regular Expressionlookup tables. Did your Linux system have an APC cacheon it and this one does not? The APC cache would probablykeep the PHP file data cached (although not the compiledregex patterns)