Post on 09-May-2015
description
WordPress Server Optimizations
Даниел Канчев WordPress Sofia User Group Февруари 2014
Performance Guru @SiteGround Security Freak Server Migrations Specialist VIP Customer Management FOSS Addict Addicted to extreme sports
Даниел Канчев@dvkanchev
По-доволни потребители —>> $$$
По-добри позиции в Google/Yandex
По-ниски разходи за web hosting
Защо трябва да оптимизирате?
Направете план
Web server setup - Apache or nginx
PHP setup - PHP-FPM, FastCGI, APC
MySQL setup
Object caching - Memcached/Redis
Full page (HTTP) caching - Varnish, nginx
Основни моменти в оптимизацията
MySQL
Използвайте Percona - http://www.percona.com/
Използвайте tmpfs за MySQL tmpdir - http://goo.gl/UOTjlW
MySQLtuner.pl - http://mysqltuner.pl
PHP
PHP handlers - DSO, SuPHP/SuExec, FastCGI/PHP-FPM
PHP modules info
Opcode caching, object caching - APC, xCache, Memcached, Redis
WordPress Interaction with Your Database
First request goes to the database server
Object Caching
First request goes to the database server
Objects are also stored in Memcached
Object Caching
All consecutive requests are forwarded to the Memcached server
Scanning
Lexing
Parsing
Compilation
Opcode
How PHP Works
Execution
!
Opcode
PHP Opcode Caching
Execution
Reverse Proxy Servers
Reverse Proxy Servers
Reverse Proxy Servers
Reverse Proxy Servers
nginx config which works
http://polihronov.wordpress.com/
Varnish config# Never cache administrator if (req.url ~ "wp-(login|admin)" || req.url ~ "preview=true") { return (pass); } if (req.http.Cookie ~ "(^|;\s*)(wpSGCacheBypass=1)(;|$)") { return(pass); } if (req.http.Cookie ~ "(^|;\s*)wordpress_logged_in_([^;]+)(;|$)") { return(pass); } if (req.http.Cookie ~ "(^|;\s*)(woocommerce_items_in_cart=1)(;|$)") { return(pass); } if (req.http.Cookie ~ "comment_author") { return(pass); } !include "common.vcl"; !return (lookup);
To CDN or not to CDN ?
Изводи
Оптимизацията е процес, а не събитие.
Винаги тествайте. Пазете информацията от всички тестове.
Информирайте се от големите акули.
Полезни линкове
http://highscalability.com/
http://www.mysqlperformanceblog.com/
http://wiki.nginx.org/WordPress
http://velocityconf.com/