Scaling Dynamic WordPress Sites - WordCamp US 2015

Preview:

Citation preview

ScalingDynamic

WordPressWebsites

WordCampUSDec.5th,2015

WhoamI?

AaronEdwards

@UglyRobotDev

https://profiles.wordpress.org/uglyrobot

,,andCAMPUSPRESS

• CTOofIncsub

• WordPressdevelopersince2.6,specializinginMultisite

• Creatoroflotsofpluginsandservices

Onesizedoesn’tfitall• Mostcachingpluginsandperformancetalks

focusonFullPageCaching

• Doesnothingfordynamicwebsites!

MembershipSites

WordPressMultisite

PageGenerationTime(ms)

0 100 200 300 400 500 600

29ms200ms300ms

PHP Database WebExternal

GooglePagespeedrecommends200msmax!

PageGenerationTime

DatabaseOptimization• Limitandoptimizequeries

• https://wordpress.org/plugins/query-monitor/

• OptimizeMySQLconfig

• Querycache

• MySQLTuner

• Converthigh-writetablestoInnoDB

• SwitchtoMariaDB(10-20%)orAWSAurora(2-3x)

orkeepthequeriesfromevergettingtoyourDB…

Disk

Memory

WordPressObjectCache

ObjectCachingPlugins

• Memcached-Recommended

• http://wordpress.org/extend/plugins/memcached/orW3TC

• Redis-Recommended

• https://wordpress.org/plugins/redis-cache/

• APC

• https://wordpress.org/plugins/apc/orW3TC

• FileBased-notrecommended

wp-content/object-cache.php

PHPOptimization:CodeProfiling

• Beginners:P3(PluginPerformanceProfiler)

• https://wordpress.org/plugins/p3-profiler/

• Advanced:Xdebug+(web/win/k)cachegrind

• EasiestwayistheVVVlocaldevelopment

environment

• OnProduction:

PHPOptimization:WorstOffenders1. Unnecessary/unoptimizedqueries

1. Usewp_cache_*functions(objectcacherequired)

2. Per-pageloaddatabasewrites(stats,redirection,logging

plugins)

2. Watchoutforremoterequests!

1. Uselowtimeouts

2. Cacheaslongaspossible,notintransients

3. Flushingrewriterulespoorly

4. Directfilesystemaccess

SpeedingUpPHP• UseNGINXinsteadofApache

• InMultisiteuseaCDNorVarnish

• MoveSessionstoragetoRAM

• UpgradePHPto5.5or5.6

• EnableandconfigureOPcache

• Makesurecodebasefitsincachesize:

• opcache.memory_consumption

• opcache.max_accelerated_files

• Increaserevalidationfrequency:

• opcache.revalidate_freq

SwitchtoHHVMorPHP7!

http://talks.php.net/fluent15#/wpbench

AppMonitoringatScaleStatsD+StatsD

WordPressClient+

Grafana

https://github.com/etsy/statsd

https://wordpress.org/plugins/statsd/

http://grafana.org/

• Liveapplicationprofiling

Tootechnicalforyou?• HireanexperiencedSysAdmin

• Useacutting-edgemanagedWordPresshost

Thankyou#WCUS!@UglyRobotDev

Drag&dropsitebuilding,100+WordPresspluginsand24/7expertWordPresssupport