WordPress Server 

Optimizations

Даниел Канчев
WordPress Sofia User Group

Февруари 2014
Даниел Канчев
@dvkanchev

Performance Guru @SiteGround
Security Freak
Server Migrations Specialist
VIP Customer Management
FOSS Addict
Addicted to extreme sports
Защо трябва да оптимизирате?

По-доволни потребители —>> $$$
По-добри позиции в 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
How PHP Works
Scanning
Lexing
Parsing
Compilation
Opcode

Execution
PHP Opcode Caching

!

Opcode

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/
Bash Мерси!
@dvkanchev / daniel.k@siteground.com

Sofia WP User Group Presentation