15
HIGH PERFORMANCE WordPress Iliya Polihronov WordCamp San Francisco 2012 Saturday, August 4, 12

High Performance WordPress

  • Upload
    vnsavage

  • View
    12.544

  • Download
    5

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: High Performance WordPress

HIGH PERFORMANCE

WordPress

Iliya PolihronovWordCamp San Francisco 2012

Saturday, August 4, 12

Page 2: High Performance WordPress

Iliya PolihronovSystems WranglerAutomattic

polihronov.wordpress.comslideshare.net/vnsavage @vnsavage

Saturday, August 4, 12

Page 3: High Performance WordPress

WordPress.com Numbers

‣ 115 million pageviews per day

‣ 2.6 billion requests per day

‣ over 200 plugins

‣ 500ms per page

Saturday, August 4, 12

Page 4: High Performance WordPress

Notable Users

Saturday, August 4, 12

Page 5: High Performance WordPress

Services InstallationNginx

PHP-FPM

wiki.nginx.org/Install

Compile PHP with --enable-fpm

For Debian Squeeze$ gpg --keyserver hkp://keys.gnupg.net --recv-keys E9C74FEEA2098A6E$ gpg --keyserver hkp://keys.gnupg.net --recv-keys ABF5BD827BD9BF62$ gpg -a --export E9C74FEEA2098A6E | apt-key add -$ gpg -a --export ABF5BD827BD9BF62 | apt-key add -$ echo 'deb http://nginx.org/packages/debian/ squeeze nginx' >> /etc/apt/sources.list$ echo 'deb http://packages.dotdeb.org squeeze-php54 all' >> /etc/apt/sources.list$ apt-get update$ apt-get install nginx php5-cli php5-fpm php5-cgi php5-mysql php5-memcache

Saturday, August 4, 12

Page 6: High Performance WordPress

Services InstallationAPC

MySQL

php.net/manual/en/apc.installation.php

percona.com/doc/percona-server/5.5/installation.html

For Debian Squeeze$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A$ gpg -a --export CD2EFD2A | apt-key add -$ echo ‘deb http://repo.percona.com/apt squeeze main’ >> /etc/apt/sources.list$ apt-get update$ apt-get install php5-apc memcached percona-server-server-5.5 percona-server-client-5.5

Memcached memcached.org

Saturday, August 4, 12

Page 7: High Performance WordPress

Nginx Configuration/etc/nginx/nginx.conf

worker_processes 8;worker_connections 2048;keepalive_timeout 30;

gzip on;gzip_types text/css text/javascript application/x-javascript application/json text/xml;gzip_min_length 500;gzip_comp_level 5;

location ~ \.(css|js|jp(e)?g|gif|png|swf|ico)$ { expires 1y;}

fastcgi_buffer_size 32k;fastcgi_buffers 256 4k;

/etc/init.d/nginx

ulimit -n 65536

Full configuration at polihronov.wordpress.com

Saturday, August 4, 12

Page 8: High Performance WordPress

PHP-FPM and APC/etc/php5/fpm/pool.d/www.conf

pm = dynamicpm.max_children = 40pm.start_servers = 5pm.min_spare_servers = 5pm.max_spare_servers = 10listen.backlog = 512

/etc/php5/conf.d/20-apc.ini

extension="apc.so"apc.enabled = 1apc.shm_size = 32M

/etc/php5/fpm/php.ini

output_buffering = 4096

Saturday, August 4, 12

Page 9: High Performance WordPress

MySQL Configuration/etc/mysql/my.cnf

key_buffer = 256Msort_buffer_size = 4Mread_buffer_size = 4Minnodb_buffer_pool_size = 256Minnodb_log_buffer_size = 8M

tmp_table_size = 32Mmax_heap_table_size = 32M

table_cache = 128thread_cache = 64

query_cache_type = 1query_cache_limit = 1Mquery_cache_size = 32M

InnoDB - for tables with lots of reads and writesmysqlreport - inspect important MySQL status values

Saturday, August 4, 12

Page 10: High Performance WordPress

Optimizing yourWordPress Install

‣ Keep it up to date

‣ Avoid unnecessary plugins

‣ Avoid slow pluginshttp://wordpress.org/extend/plugins/p3-profiler

Saturday, August 4, 12

Page 11: High Performance WordPress

Caching

WP Super Cachehttp://wordpress.org/extend/plugins/wp-super-cache/

Memcached Object Cachehttp://wordpress.org/extend/plugins/memcached/

‣ Custom permalinks, like /%year/%monthnum%/%postname%/

‣ Enable all the recommended settings

Saturday, August 4, 12

Page 12: High Performance WordPress

Benchmarks

With APC and Caching

Virtual machine on a laptop, using Apache Benchmark (ab):

16,140.70 REQUESTS/SEC

With APC

48.39 REQUESTS/SEC

Without APC

11.07 REQUESTS/SEC

Saturday, August 4, 12

Page 13: High Performance WordPress

At a Larger Scale

Load Balancers

INTERNET

Web Servers Web ServersCaching Servers

Master-Slave MySQLMemcached

Saturday, August 4, 12

Page 14: High Performance WordPress

HIGH PERFORMANCE

WordPress

Questions?

Saturday, August 4, 12

Page 15: High Performance WordPress

Iliya PolihronovSystems WranglerAutomattic

polihronov.wordpress.comslideshare.net/vnsavage @vnsavage

Saturday, August 4, 12