going beyond lamp again - manchester wordpress user group
TRANSCRIPT
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
LAMP To speed things up a bit
Going Beyond...
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Going beyond shared hosts
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
WHERE TO PLAY?
Cheap VPS/Dedicated Box
Vagrant
Use third party services
PAAS hosting
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
LAMP Linux
ApacheMySQL
PHP
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
L[AMP] Linux
ApacheMySQL
PHP
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
WIMP Windows
IISMySQL
PHP
REALLY!!!
OMG You like Serious init!
CRAZY??
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
[AMP] “Use the best tool for the job...
...Not just the most popular”- almost certainly an engineer
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
[AMP] “You don’t dig latrines with a swiss army knife”
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
ANGINX HTTP and Proxy Server
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
AApache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache.
- Chris Lea (https://chrislea.com/)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
MMaria DB & Percona Server
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
PHipHop Virtual Machine (HHVM)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
P<?hh function yieldInfiniteInts(): Continuation<int> { $i = 0; while (true) { yield $i++; } } !
$generator = yieldInfiniteInts(); foreach ($generator as $value) { echo "$value\n"; }
http://docs.hhvm.com/manual/en/hack.continuations.php
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Pasync function getAsyncTemplatePart( $slug, $name = false ) { return get_template_part( $slug, $name ); } !
async function gatherTemplateParts($templates) { $return = array(); !
foreach( $templates as $slug => $name ) { $return[] = getAsyncTemplatePart( $slug, $name ); } !
await GenArrayWaitHandle::create($return); } !
gatherTemplateParts( $templates )->join();
Async grabbing WordPress Templates in HackLang
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Key value storesMemcached and Redis (Redis Cloud)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
id user_login user_pass user_nicename user_email …1 tim diufhdiufg£bsdh874£423223 Tim [email protected] …
Traditional SQL DB
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Key : Value : Expiry (Optional) !
Tim : Geeky
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
WHAT ARE THEY GOOD FOR IN WORDPRESS?
Storing replicable Data…
Transients
Caching
Job Queues backends
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Memory comes and goes especially with age!
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Transients API
Key : Value : Expiry (Optional)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Using KSV to cache WordPress
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Rendering/ Template/Theme
Processing/ ObjectsMySQL
HTTP/ Other Services
WordPress
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Page/Fragment Caching
Object CachingQuery Cache
HTTP Caching
Caching
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Caching can and will screw with you!
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Queue ManagementBeanstalkd & Gearman
(Amazon SQS)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk
1. WordPress sends job to queue 2. Job Server (Beanstalk, Gearman) Holds in a queue 3. Worker picks job from the queue and completes it
2 .
3 .1 .
QUEUE MANAGEMENT SYSTEM
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk
1. User clicks approve on a comment, WordPress queries the database and collects all the emails to notify and the message to send and passes it to the job server.
2. Job Server put’s the emails into a queue
3. Script calls the queue server and takes the email and message, emails the user and marks job complete, repeats until the queue is empty2 .
3 .1 .
QUEUE MANAGEMENT SYSTEM (IN PRACTICE)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
function gatherTemplateParts( $templates ){ $client = new GearmanClient(); $client->addServer(); $client->setCompleteCallback(function(GearmanTask $task, $context) use (&$return) { $return[] = $task->data(); }); !
foreach( $templates as $template ){ $client->addTask('getAsyncTemplatePart', $template ); } client->runTasks(); }
ASYNC WITH GEARMAN - CLIENT
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
$worker = new GearmanWorker(); $worker->addServer(); $worker->addFunction('getAsyncTemplatePart', function(GearmanJob $job){ return get_template_part( key(), current() ); }); while ($worker->work());
ASYNC WITH GEARMAN - WORKER
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Caching reverse proxiesVarnish
(CloudFront, CloudFlare)
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
CLOUDFRONT NGINX (ORIGIN)
NGINX
Server
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
VARNISH NGINX (ORIGIN)
PROXY CACHING OVER SSL WITH VARNISH
NGINX SSL END POINT
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
Caching can and will screw with you!
C O M PA N Y N A M E P R E S E N TAT I O N T I T L E 1 2 - 1 2 - 2 0 1 2TimNash.co.uk @tnash #beyondLAMP
The End! Thanks for listening and don’t forget to visit...
!
!
Slides: https://timnash.co.uk/mwug-may-2014