PHP factor 30 performance difference from Linux to Windows

后端 未结 5 1514
不知归路
不知归路 2020-12-13 09:05

Our team is working is developing WordPress plugins and provides hosted instances on a couple of independent servers. Our WordPress installation is managed by Git, all serve

5条回答
  •  醉酒成梦
    2020-12-13 09:52

    • 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.dll apc.enabled=1 apc.shm_segments=1 apc.shm_size=128M apc.num_files_hint=7000 apc.user_entries_hint=4096 apc.ttl=7200 apc.user_ttl=7200

    • enable Zend Opcode when on PHP 5.5

      [Zend] zend_extension=ext/php_zend.dll zend_optimizerplus.enable=1 zend_optimizerplus.use_cwd=1 zend_optimizerplus.validate_timestamp=0 zend_optimizerplus.revalidate_freq=2
      zend_optimizerplus.revalidate_path=0 zend_optimizerplus.dups_fix=0 zend_optimizerplus.log_verbosity_level=1 zend_optimizerplus.memory_consumption=128 zend_optimizerplus.interned_strings_buffer=16 zend_optimizerplus.max_accelerated_files=2000 zend_optimizerplus.max_wasted_percentage=25 zend_optimizerplus.consistency_checks=0 zend_optimizerplus.force_restart_timeout=60 zend_optimizerplus.blacklist_filename= zend_optimizerplus.fast_shutdown=0 zend_optimizerplus.optimization_level=0xfffffbbf zend_optimizerplus.enable_slow_optimizations=1 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.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

提交回复
热议问题