PHP 5.3-5.6と7.0のDrupalコード実行速度の比較。 Battle of Code Optimizers apc vs xcache vs opcache












記事の続き:


PHPサイトを高速化し、最適化します。 PHP用のサーバーをセットアップするときに選択するテクノロジー








前の資料とは異なり、この記事では、PHP 7 beta3を含むPHPのさまざまなバージョンの応答速度とコード解釈の比較に焦点を当てています。



PHPの初期バージョンでは、コードオプティマイザーapc、xcache、opcacheの間でテストが行​​われました。

この記事には、abやsiegeのストレステストなどのパフォーマンステストは含まれていません。 おそらく、次の記事のいずれかでこれについて書くでしょう。

この場合、このバージョンまたはそのバージョンのphpインタープリターが生成できる1秒あたりのページ数ではなく、ページを生成する速度と遅延については興味がありません。

この場合の違いは、パフォーマンステストでは、サーバーの総リソースに対するインタープリターの速度の比率、および高負荷で動作するWebシステムの他の関連コンポーネントの準備が測定されることです。

速度と応答について説明します。 明らかに、パフォーマンスは速度に依存しますが、高速では高いパフォーマンスを保証できません。 これはおそらく、Webサーバーまたはデータベースが適切に構成されていないという事実と、たとえばネットワークスタックなどのいくつかの制限によるものです。

広大さを把握しようとしないために、すべての被験者に対して同じ構成のWebサーバー、データベース、オペレーティングシステムを使用して、負荷のない強力なサーバーでPHPインタープリターの速度と応答を測定します。 php-fpm + nginx構成を使用します。 データベースMariaDB。 すべての技術的な詳細は、以下のネタバレの下に隠されています。












「理想」クラスターのトピックに関する他の出版物も読むことができます。












技術的な詳細と構成
テストサーバー:


CPU:Intel Xeon E5-1620v2 4c / 8t 3.7 GHz + / 3.9 GHz +

RAM:64 GB DDR3 ECC 1600 MHz

Intel DC S3500シリーズ300GB









Centos 6.7:


Linux 2.6.32-40-pve#1 SMP Fri Jul 24 11:16:05 CEST 2015 x86_64 x86_64 x86_64 GNU / Linux









sysctl:


net.ipv4.ip_forward = 1

kernel.sysrq = 1

net.ipv4.tcp_syncookies = 1

net.bridge.bridge-nf-call-ip6tables = 0

net.bridge.bridge-nf-call-iptables = 0

net.bridge.bridge-nf-call-arptables = 0

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 4294967295

kernel.shmall = 268435456

net.netfilter.nf_conntrack_max = 99999999

fs.inotify.max_user_watches = 99999999

net.ipv4.tcp_max_tw_buckets = 99999999

net.ipv4.tcp_max_tw_buckets_ub = 65535

net.ipv4.tcp_max_syn_backlog = 65536

net.core.somaxconn = 65535

fs.file-max = 99999999

kernel.sem = 1000 128000 128512

vm.dirty_ratio = 5

fs.aio-max-nr = 262144

kernel.panic = 1

net.ipv4.conf.all.rp_filter = 1

net.ipv4.conf.default.send_redirects = 1

net.ipv4.conf.all.send_redirects = 0

net.ipv4.ip_dynaddr = 1

kernel.shmmni = 4096

net.ipv4.tcp_keepalive_time = 15

net.ipv4.tcp_keepalive_intvl = 10

net.ipv4.tcp_keepalive_probes = 5

net.ipv4.tcp_fin_timeout = 30

net.ipv4.tcp_window_scaling = 0

net.ipv4.tcp_sack = 0

net.ipv4.tcp_timestamps = 0










Php


PHP 5.3.29(cli)(構築日:2014年8月14日14:15:02)

Copyright 1997-2014 The PHP Group

Zend Engine v2.3.0、著作権1998-2014 Zend Technologies



PHP 5.3.29(cli)(構築日:2014年8月14日14:15:02)

Copyright 1997-2014 The PHP Group

Zend Engine v2.3.0、著作権1998-2014 Zend Technologies

XCache v3.2.0、Copyright 2005-2014、mOo

XCache Cacher v3.2.0、Copyright 2005-2014、mOoによる



PHP 5.3.29(cli)(構築日:2014年8月14日14:15:02)

Copyright 1997-2014 The PHP Group

Zend Engine v2.3.0、著作権1998-2014 Zend Technologies

Zend OPcache v7.0.5、著作権1999-2015、Zend Technologiesによる





インストールされているZend Engine APIバージョン220100525は新しいです。

Zend Guard Loaderの新しいバージョンについては、 www.zend.comの Zend Technologiesに問い合わせください。

PHP 5.4.42(cli)(ビルド:2015年6月12日09:19:10)

Copyright 1997-2014 The PHP Group

Zend Engine v2.4.0、著作権1998-2014 Zend Technologies



PHP 5.4.42(cli)(ビルド:2015年6月12日09:19:10)

Copyright 1997-2014 The PHP Group

Zend Engine v2.4.0、著作権1998-2014 Zend Technologies

XCache v3.2.0、Copyright 2005-2014、mOo

XCache Cacher v3.2.0、Copyright 2005-2014、mOoによる



PHP 5.5.27(cli)(構築日:2015年7月10日23:40:40)

Copyright 1997-2015 The PHP Group

Zend Engine v2.5.0、著作権1998-2015 Zend Technologies



PHP 5.6.11(cli)(構築日:2015年7月10日22:43:20)

Copyright 1997-2015 The PHP Group

Zend Engine v2.6.0、著作権1998-2015 Zend Technologies



PHP 7.0.0beta3(cli)(ビルド:2015年8月5日19:11:12)

Copyright 1997-2015 The PHP Group

Zend Engine v3.0.0-dev、著作権1998-2015 Zend Technologies










XCache


[xcache]

xcache.shm_scheme = "mmap"

xcache.size = 1G

xcache.count = 8

xcache.slots = 8K

xcache.ttl = 3600

xcache.gc_interval = 3600

xcache.var_size = 64M

xcache.var_count = 2

xcache.var_slots = 8K

xcache.var_ttl = 3600

xcache.mmap_path = "/ tmp / xcache"

xcache.cacher =オン

xcache.stat =オン

xcache.optimizer =オン

xcache.test =オフ

xcache.readonly_protection =オフ

[xcache.coverager]

xcache.coverager =オフ

xcache.coveragedump_directory = ""










Opcache


zend_extension = opcache.so

opcache.enable = 1

opcache.enable_cli = 1

opcache.memory_consumption = 1024

opcache.interned_strings_buffer = 8

opcache.max_accelerated_files = 3907

opcache.fast_shutdown = 1

opcache.blacklist_filename = / etc / php.d / opcache * .blacklist





APC


拡張子= apc.so

apc.enabled = 1

apc.shm_size = 1024M

apc.ttl = 86400

apc.user_ttl = 7200

apc.num_files_hint = 20000

apc.enable_cli = 1

apc.cache_by_default = 1





Nginx:


nginxバージョン:nginx / 1.9.3

gcc 4.4.7 20120313(Red Hat 4.4.7-16)(GCC)によって構築

OpenSSL 1.0.1e-fipsで構築2013年2月11日

TLS SNIサポートが有効

引数の設定:--prefix = / etc / nginx --sbin-path = / usr / sbin / nginx --conf-path = / etc / nginx / nginx.conf --error-log-path = / var / log / nginx / error.log --http-log-path = / var / log / nginx / access.log --pid-path = / var / run / nginx.pid --http-client-body-temp-path = / var / cache / nginx / client_body --http-proxy-temp-path = / var / cache / nginx / proxy --http-fastcgi-temp-path = / var / cache / nginx / fastcgi --http-uwsgi-temp -path = / var / cache / nginx / uwsgi --http-scgi-temp-path = / var / cache / nginx / scgi --lock-path = / var / run / nginx.lock --pid-path = / var / run / nginx.pid --lock-path = / var / lock / subsys / nginx --user = nginx --group = nginx --with-file-aio --with-ipv6 --with-http_ssl_module- with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-stream_ssl_module --with-stream --with-threads --with-http_image_filter_module --with-http_geoip_module --with-http with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-mail_ssl_module --with-htt p_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-pcre --with-debug --d src / nginx-1.9.3 / ModSecurity-master / nginx / modsecurity --add-module = / usr / src / nginx-1.9.3 / ngx_cache_purge-master --add-module = / usr / src / nginx-1.9 3 / ngx_pagespeed-master --add-module = / usr / src / nginx-1.9.3 / nginx-push-stream-module-master --with-cc-opt = '-O2 -g -pipe -Wall -Wp 、-D_FORTIFY_SOURCE = 2 -fexceptions -fstack-protector --param = ssp-buffer-size = 4 -m64 -mtune = generic '--with-ld-opt = -Wl、-E





worker_processes auto;

timer_resolution 100ms;

pid /var/run/nginx.pid;

thread_poolのデフォルトスレッド= 32 max_queue = 655360;

イベント{

worker_connections 10000;

multi_accept on;

epollを使用します。

}

http {

/etc/nginx/mime.typesを含めます。

default_type application / octet-stream;

log_format main '$ host-$ remote_user [$ time_local] "$ request"' '$ status $ body_bytes_sent "$ http_referer"' '"$ http_user_agent" "$ http_x_forwarded_for"';

log_format defaultServer '[$ time_local] [$ server_addr] $ remote_addr($ http_user_agent)-> "$ http_referer" $ host "$ request" $ status';

log_format downloadsLog '[$ time_local] $ remote_addr "$ request"';

log_formatカウンター '[$ time_iso8601] $ remote_addr $ request_uri?$ query_string';

access_log off;

access_log / dev / null main;

error_log / dev / null;



connection_pool_size 256;

client_header_buffer_size 4k;

client_max_body_size 600m;

large_client_header_buffers 8 32k;

request_pool_size 4k;

output_buffers 1 32k;

postpone_output 1460;

gzip on;

gzip_min_length 1000;

gzip_proxied any;

gzip_typesテキスト/プレーンテキスト/ cssアプリケーション/ jsonアプリケーション/ x-javascriptテキスト/ xmlアプリケーション/ xmlアプリケーション/ xml + rssテキスト/ javascriptテキスト/ x-javascriptアプリケーション/ javascript;

gzip_disable "msie6";

gzip_comp_level 6;

gzip_http_version 1.0;

gzip_vary on;



sendfile on;

aioスレッド。

directio 10m;

tcp_nopush on;

tcp_nodelay on;

server_tokens off;



keepalive_timeout 75 20;

server_names_hash_bucket_size 128;

server_names_hash_max_size 8192;

ignore_invalid_headers on;

server_name_in_redirect off;



ssl_stapling on;

ssl_stapling_verify on;

リゾルバ8.8.4.4有効な8.8.8.8 = 300秒。

resolver_timeout 10s;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers 'AES128 + EECDH:AES128 + EDH';

ssl_dhparam /etc/ssl/certs/dhparam.pem;

ssl_session_cache shared:SSL:50m;

ssl_prefer_server_ciphers on;

ssl_trusted_certificate /etc/ssl/certs/ca-certs.pem;



spdy_headers_comp 1;

add_header代替プロトコル443:npn-spdy / 3;

add_header Strict-Transport-Security "max-age = 63072000; includeSubdomains; ";

add_header X-Content-Type-Options nosniff;



proxy_buffering off;

proxy_buffer_size 8k;

proxy_buffers 8 64k;

proxy_connect_timeout 300m;

proxy_read_timeout 300m;

proxy_send_timeout 300m;

proxy_store off;

proxy_ignore_client_abort on;



fastcgi_read_timeout 300m;

open_file_cache max = 200000非アクティブ= 20s;

open_file_cache_valid 30s;

open_file_cache_min_uses 2;

open_file_cache_errors on;



proxy_cache_path / var / cache / nginx / page levels = 2 keys_zone = pagecache:100m inactive = 1h max_size = 10g;



fastcgi_cache_path / var / cache / nginx / fpm levels = 2 keys_zone = FPMCACHE:100m inactive = 1h max_size = 10g;

fastcgi_cache_key "$スキーム$ request_method $ホスト";

fastcgi_cache_use_staleエラータイムアウトinvalid_header http_500;

fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

アップストリームmemcached_backend {server 127.0.0.1:11211; }



real_ip_header X-Real-IP;

proxy_set_header Host $ host;

proxy_set_header X-Real-IP $ remote_addr;

proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;

すべて許可;

サーバー{

80の再利用ポートを聞きます。

}

include /etc/nginx/conf.d/*.conf;

}





サーバー{

listen *:80;

server_name habratest.livelinux.ru www.habratest.livelinux.ru;

root /var/www/habratest.livelinux.ru/web;

index index.html index.htm index.php index.cgi index.pl index.xhtml;

error_page 400 /error/400.html;

error_page 401 /error/401.html;

error_page 403 /error/403.html;

error_page 404 /error/404.html;

error_page 405 /error/405.html;

error_page 500 /error/500.html;

error_page 502 /error/502.html;

error_page 503 /error/503.html;

recursive_error_pages;

location = /error/400.html {

内部;

}

location = /error/401.html {

内部;

}

location = /error/403.html {

内部;

}

location = /error/404.html {

内部;

}

location = /error/405.html {

内部;

}

location = /error/500.html {

内部;

}

location = /error/502.html {

内部;

}

location = /error/503.html {

内部;

}

error_log /var/log/ispconfig/httpd/habratest.livelinux.ru/error.log;

access_log /var/log/ispconfig/httpd/habratest.livelinux.ru/access.logの組み合わせ;

場所〜/ \。 {

すべてを拒否します。

access_log off;

log_not_found off;

}

場所= /favicon.ico {

log_not_found off;

access_log off;

}

location = /robots.txt {

すべて許可;

log_not_found off;

access_log off;

}

場所/統計/ {

index index.html index.php;

auth_basic「メンバーのみ」;

auth_basic_user_file /var/www/clients/client1/web1/web/stats/.htpasswd_stats;

}

場所^〜/ awstats-icon {

エイリアス/ usr / share / awstats /アイコン;

}

場所〜\ .php $ {

try_files /70b2e8b422a0dce8501e61dafabafa26.htm php ;

}

ロケーションphp {

try_files $ uri = 404;

include / etc / nginx / fastcgi_params;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;

fastcgi_intercept_errors on;

}

場所/ {

try_files $ uri @rewrite;

}

場所@rewrite {

書き換え^ /index.php;

}

}










php-fpm:


[web1]

listen = /var/lib/php5-fpm/web1.sock

listen.owner = web1

listen.group = client1

listen.mode = 0660

ユーザー= web1

グループ= client1

pm =動的

pm.max_children = 10

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 5

pm.max_requests = 0

chdir = /

php_admin_value [open_basedir] = / var / www / clients / client1 / web1 / web:/ var / www / clients / client1 / web1 / private:/ var / www / clients / client1 / web1 / tmp:/ var / www / habratest .livelinux.ru / web:/srv/www/habratest.livelinux.ru/web:/ usr / share / php5:/ usr / share / php:/ tmp:/ usr / share / phpmyadmin:/ etc / phpmyadmin:/ var / lib / phpmyadmin

php_admin_value [session.save_path] = "tcp:// localhost:11211"

php_admin_value [upload_tmp_dir] = / var / www / clients / client1 / web1 / tmp

php_admin_value [sendmail_path] = "/ usr / sbin / sendmail -t -i -fwebmaster@habratest.livelinux.ru"










MariaDB:


サーバーバージョン:10.0.21-MariaDB MariaDBサーバー




[mysqld]



シンボリックリンク= 0

default_storage_engine = InnoDB

innodb_file_per_table = 1

event_scheduler = on

datadir = / var / lib / mysql

socket = / var / lib / mysql / mysql.sock

connect_timeout = 600000

wait_timeout = 28800

max_connections = 600

max_allowed_pa​​cket = 512M

max_connect_errors = 10000

net_read_timeout = 600000

connect_timeout = 600000

net_write_timeout = 600000

innodb_open_files = 512

innodb_buffer_pool_size = 2G

innodb_buffer_pool_instances = 2

innodb_file_format = barracuda

innodb_locks_unsafe_for_binlog = 1

innodb_flush_log_at_trx_commit = 2

innodb_flush_method = O_DIRECT

トランザクション分離= READ-COMMITTED

innodb-data-file-path = ibdata1:10M:自動拡張

innodb-log-file-size = 256M

innodb_log_buffer_size = 8M

スキップ名解決

スキップ外部ロック

skip-innodb_doublewrite

query_cache_size = 128M

query_cache_type = 1

query_cache_min_res_unit = 2K

join_buffer_size = 8M

read_rnd_buffer_size = 3M

table_definition_cache = 2048

table_open_cache = 2048

thread_cache_size = 128

tmp_table_size = 200M

max_heap_table_size = 200M

log_error = /var/log/mysql/mysql-error.log

key_buffer_size = 256M

optimizer_switch = 'derived_merge = off、derived_with_keys = off'







どのようにテストしますか?




現在のサーバーでは、zabbix-proxがインストールされ、そのタスクが毎分実行されます:












テスト:





PHPのすべてのバージョンについて、オプティマイザーを使用しない場合のページ解釈速度と応答時​​間の比較:



結果(KBps)が高いほど良い











結果(ms)が低いほど良い
















Opcacheを使用した、PHPのすべてのバージョンのページ解釈速度と応答時​​間の比較:



結果(KBps)が高いほど良い











結果(ms)が低いほど良い
















APC、xCache、Opcacheを使用したページ解釈速度と応答時​​間の比較、PHP54



結果(KBps)が高いほど良い











結果(ms)が低いほど良い














APC、xCache、およびOpcacheを使用したページ解釈速度と応答時​​間の比較、PHP53



結果(KBps)が高いほど良い











結果(ms)が低いほど良い














協力のために、私のプロフィールの連絡先



All Articles