Scaling PHP in The Real World
-
Upload
appdynamics -
Category
Technology
-
view
1.412 -
download
0
description
Transcript of Scaling PHP in The Real World
![Page 1: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/1.jpg)
SCALING PHP IN THE REAL WORLD!Dustin Whittle
![Page 2: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/2.jpg)
PHP IS USED BY THE LIKES OF FACEBOOK, YAHOO, ZYNGA, TUMBLR, ETSY, AND WIKIPEDIA. HOW DO THE LARGEST INTERNET COMPANIES
SCALE PHP TO MEET THEIR DEMAND? !
JOIN THIS SESSION AND FIND OUT HOW TO USE THE LATEST TOOLS IN PHP FOR DEVELOPING HIGH PERFORMANCE APPLICATIONS. WE’LL
TAKE A LOOK AT COMMON TECHNIQUES FOR SCALING PHP APPLICATIONS AND BEST
PRACTICES FOR PROFILING AND OPTIMIZING PERFORMANCE. AFTER THIS SESSION, YOU’LL
LEAVE PREPARED TO TACKLE YOUR NEXT ENTERPRISE PHP PROJECT.
![Page 3: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/3.jpg)
AGENDA• Why performance matters?
• The problems with PHP
• Best practice designs
• Distributed data caches with Redis and Memcached
• Doing work in the background with queues
• Http caching and a reverse proxy with Varnish
• Using the right tool for the job
• Tools of the trade
• Xdebug + WebGrind
• XHProf + XHProf GUI
• AppDynamics
• Google PageSpeed
• Architecture not applications
![Page 4: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/4.jpg)
DUSTIN WHITTLE
• dustinwhittle.com
• @dustinwhittle
• Technologist, Pilot, Skier, Diver, Sailor, Golfer
![Page 5: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/5.jpg)
WHAT I HAVE WORKED ON
• Developer Evangelist @
• Consultant & Trainer @
• Developer Evangelist @
![Page 6: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/6.jpg)
DID YOU KNOW FACEBOOK, YAHOO, ZYNGA, TUMBLR, ETSY, AND
WIKIPEDIA WERE ALL BUILT ON PHP?
![Page 7: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/7.jpg)
WHY DOES PERFORMANCE MATTER?
![Page 8: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/8.jpg)
WHEN MOZILLA SHAVED 2.2 SECONDS OFF THEIR LANDING PAGE, FIREFOX DOWNLOADS INCREASED 15.4%
![Page 9: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/9.jpg)
MAKING BARACK OBAMA’S WEBSITE 60% FASTER INCREASED DONATION CONVERSIONS BY 14%
![Page 10: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/10.jpg)
AMAZON AND WALMART INCREASED REVENUE 1% FOR
EVERY 100MS OF IMPROVEMENT
![Page 11: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/11.jpg)
![Page 12: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/12.jpg)
PERFORMANCE DIRECTLY IMPACTS THE BOTTOM LINE
![Page 13: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/13.jpg)
![Page 14: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/14.jpg)
PHP IS SLOWER THAN JAVA, C++, ERLANG, SCALA, AND
GO!
![Page 16: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/16.jpg)
...AND PHP HAS SOME SERIOUS DESIGN ISSUES AND INCONSISTENCIES!
![Page 17: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/17.jpg)
...BUT THERE ARE WAYS TO SCALE TO HANDLE HIGH TRAFFIC APPLICATIONS
![Page 18: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/18.jpg)
PHP IS NOT YOUR PROBLEM!
![Page 19: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/19.jpg)
WHAT VERSION OF PHP DO YOU RUN?
![Page 20: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/20.jpg)
UPGRADE YOUR PHP ENVIRONMENT TO 2014!
![Page 21: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/21.jpg)
NGINX + PHP-FPM
![Page 22: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/22.jpg)
USE AN OPCODE CACHE!
![Page 23: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/23.jpg)
PHP 5.5 HAS ZEND OPCACHE
![Page 24: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/24.jpg)
APC
![Page 25: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/25.jpg)
USE AUTOLOADING AND PSR-0
![Page 26: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/26.jpg)
SYMFONY2 CLASSLOADER COMPONENT WITH APC
CACHING
![Page 27: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/27.jpg)
SCALING BEYOND A SINGLE SERVER IN PHP
![Page 28: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/28.jpg)
OPTIMIZE YOUR SESSIONS!
![Page 29: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/29.jpg)
THE DEFAULT IN PHP IS TO PERSIST SESSIONS TO DISK
![Page 30: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/30.jpg)
IT IS BETTER TO STORE SESSIONS IN A DATABASE
![Page 31: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/31.jpg)
EVEN BETTER IS TO STORE IN A DATABASE WITH A
SHARED CACHE IN FRONT
![Page 32: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/32.jpg)
PECL INSTALL MEMCACHED
![Page 33: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/33.jpg)
session.save_handler = memcached
session.save_path = "10.0.0.10:11211,10.0.0.11:11211,10.0.0.12:11211"
memcached.sess_prefix = “session.”
memcached.sess_consistent_hash = On
memcached.sess_remove_failed = 1
memcached.sess_number_of_replicas = 2
memcached.sess_binary = On
memcached.sess_randomize_replica_read = On
memcached.sess_locking = On
memcached.sess_connect_timeout = 200
memcached.serializer = “igbinary”
![Page 34: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/34.jpg)
THE BEST SOLUTION IS TO LIMIT SESSION SIZE AND STORE ALL DATA
IN A SIGNED OR ENCRYPTED COOKIE
![Page 35: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/35.jpg)
LEVERAGE AN IN-MEMORY DATA CACHE
![Page 36: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/36.jpg)
MEMCACHED.ORG
![Page 37: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/37.jpg)
REDIS.IO
![Page 38: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/38.jpg)
• Any data that is expensive to generate/query and long lived should be cached
• Web Service Responses
• HTTP Responses
• Database Result Sets
• Configuration Data
![Page 39: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/39.jpg)
GUZZLE HTTP CLIENT HAS BUILT-IN SUPPORT FOR CACHING
WEB SERVICE REQUESTS
![Page 40: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/40.jpg)
$memcache = new Memcache();
$memcache->connect('localhost', 11211);
!$memcacheDriver = new Doctrine\Common\Cache\MemcacheCache();
$memcacheDriver->setMemcache($memcache);
!$client = new Guzzle\HttpClient(‘http://www.test.com/’);
!$cachePlugin = new Guzzle\Plugin\Cache\CachePlugin(array(
‘storage’ => new Guzzle\Plugin\Cache\DefaultCacheStorage(
new Guzzle\Plugin\Cache\DoctrineCacheAdapter($memcacheDriver)
)
));
$client->addSubscriber($cachePlugin);
!$response = $client->get(‘http://www.wikipedia.org/’)->send();
!$response = $client->get(‘http://www.wikipedia.org/’)->send();
![Page 41: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/41.jpg)
DOCTRINE ORM FOR PHP HAS BUILT-IN CACHING SUPPORT FOR MEMCACHED AND REDIS
![Page 42: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/42.jpg)
$memcache = new Memcache();
$memcache->connect('localhost', 11211);
!$memcacheDriver = new Doctrine\Common\Cache\MemcacheCache();
$memcacheDriver->setMemcache($memcache);
!$config = new Doctrine\ORM\Configuration();
$config->setQueryCacheImpl($memcacheDriver);
$config->setMetadataCacheImpl($memcacheDriver);
$config->setResultCacheImpl($memcacheDriver);
!$entityManager = Doctrine\ORM\EntityManager::create(array(‘driver’ => ‘pdo_sqlite’, ‘path’ => __DIR__ . ‘/db.sqlite’), $config);
!$query = $em->createQuery(‘select u from EntitiesUser u’);
$query->useResultCache(true, 60);
!$users = $query->getResult();
![Page 43: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/43.jpg)
DO BLOCKING WORK IN BACKGROUND TASKS VIA
QUEUES
![Page 44: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/44.jpg)
• Resque
• Gearman
• RabbitMQ
• Kafka
• Beanstalkd
• ZeroMQ
• ActiveMQ
![Page 45: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/45.jpg)
RESQUE
![Page 46: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/46.jpg)
• Any process that is slow and not important for the http response should be queued
• Sending notifications + posting to social accounts
• Analytics + Instrumentation
• Updating profiles and discovering friends from social accounts
• Consuming web services like Twitter Streaming API
![Page 47: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/47.jpg)
![Page 48: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/48.jpg)
![Page 49: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/49.jpg)
![Page 50: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/50.jpg)
![Page 51: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/51.jpg)
LEVERAGE HTTP CACHING
![Page 52: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/52.jpg)
![Page 53: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/53.jpg)
![Page 54: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/54.jpg)
EXPIRES OR INVALIDATION
![Page 55: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/55.jpg)
EXPIRATION
![Page 56: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/56.jpg)
![Page 57: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/57.jpg)
![Page 58: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/58.jpg)
VALIDATION
![Page 59: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/59.jpg)
![Page 60: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/60.jpg)
![Page 61: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/61.jpg)
EXPIRATION AND INVALIDATION
![Page 62: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/62.jpg)
![Page 63: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/63.jpg)
![Page 64: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/64.jpg)
![Page 65: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/65.jpg)
SYMFONY2 HTTPFOUNDATION COMPONENT WITH HTTP
CACHING
![Page 66: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/66.jpg)
use Symfony\Component\HttpFoundation\Response;
!
$response = new Response(‘Hello World!’, 200, array(‘content-type’ => ‘text/html’));
!
$response->setCache(array(
‘etag’ => ‘a_unique_id_for_this_resource’,
‘last_modified’ => new DateTime(),
‘max_age’ => 600,
‘s_maxage’ => 600,
‘private’ => false,
‘public’ => true,
));
![Page 67: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/67.jpg)
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
!
$request = Request::createFromGlobals();
!
$response = new Response(‘Hello World!’, 200, array(‘content-type’ => ‘text/html’));
!
if ($response->isNotModified($request)) {
$response->send();
}
![Page 68: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/68.jpg)
• Varnish
• Squid
• Nginx Proxy Cache
• Apache Proxy Cache
![Page 69: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/69.jpg)
USE VARNISH AS A REVERSE PROXY CACHE TO ALLEVIATE LOAD ON YOUR APP SERVERS
![Page 70: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/70.jpg)
OPTIMIZE YOUR FRAMEWORK!
![Page 71: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/71.jpg)
![Page 72: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/72.jpg)
• Stay up-to-date with the latest stable version of your favorite framework
• Disable features you are not using (I18N, Security, etc)
• Always use a data cache like Memcached/Redis
• Enable caching features for views and database result sets
• Always use a HTTP cache like Varnish
![Page 73: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/73.jpg)
SHARDING
![Page 74: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/74.jpg)
TAKING A LARGE PROBLEM AND MAKING IT INTO MANAGEABLE
SMALLER PROBLEMS
![Page 75: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/75.jpg)
![Page 76: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/76.jpg)
![Page 77: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/77.jpg)
SERVICE ORIENTED ARCHITECTURE !
JAVA/SCALA/ERLANG/GO/NODE BACKEND !
PHP OR PURE JAVASCRIPT FRONTEND
![Page 78: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/78.jpg)
PHP AS GLUE
![Page 79: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/79.jpg)
COMPANIES OF GREAT SCALE MOVE AWAY FROM PHP OR
CREATE THEIR OWN VARIANT
![Page 80: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/80.jpg)
YAHOO! & YPHP
![Page 81: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/81.jpg)
FACEBOOK & HIPHOP
![Page 82: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/82.jpg)
![Page 83: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/83.jpg)
LEARN TO HOW TO PROFILE CODE FOR PHP
PERFORMANCE
![Page 84: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/84.jpg)
XDEBUG + WEBGRIND
![Page 85: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/85.jpg)
![Page 86: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/86.jpg)
XHPROF + XHPROF GUI
![Page 87: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/87.jpg)
![Page 88: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/88.jpg)
![Page 89: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/89.jpg)
![Page 90: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/90.jpg)
![Page 91: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/91.jpg)
![Page 92: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/92.jpg)
![Page 93: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/93.jpg)
![Page 94: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/94.jpg)
![Page 95: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/95.jpg)
• Upgrade to PHP 5.5 with Zend OpCache using PHP-PFM + Nginx
• Stay up to date with your framework + dependencies (using Composer)
• Optimize your session store to use signed cookies or database with caching
• Cache your database and web service access with Memcache or Redis
• Do blocking work in the background with queues and tasks using Resque
• Use HTTP caching and a reverse proxy cache like Varnish
• Profile code with Xdebug + Webgrind and monitor production performance
![Page 96: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/96.jpg)
DON’T FORGET TO OPTIMIZE THE CLIENT SIDE
![Page 97: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/97.jpg)
IN MODERN WEB APPLICATIONS MOST OF THE LATENCY COMES
FROM THE CLIENT SIDE
![Page 98: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/98.jpg)
USE ASSETIC TO OPTIMIZE CLIENT-SIDE ASSETS
![Page 99: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/99.jpg)
GOOGLE PAGESPEED
![Page 100: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/100.jpg)
GOOGLE PAGESPEED INSIGHTS
![Page 101: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/101.jpg)
![Page 102: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/102.jpg)
![Page 103: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/103.jpg)
GOOGLE PAGESPEED API
![Page 104: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/104.jpg)
CURL "HTTPS://WWW.GOOGLEAPIS.COM/PAGESPEEDONLINE/V1/RUNPAGESPEED?
URL=HTTP://DUSTINWHITTLE.COM/&KEY=XXX"
![Page 105: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/105.jpg)
SCALABILITY IS ABOUT THE ENTIRE ARCHITECTURE, NOT SOME
MINOR CODE OPTIMIZATIONS.
![Page 106: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/106.jpg)
QUESTIONS?
![Page 107: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/107.jpg)
FIND THESE SLIDES ON SPEAKERDECK !
HTTPS://SPEAKERDECK.COM/DUSTINWHITTLE
![Page 108: Scaling PHP in The Real World](https://reader034.fdocuments.in/reader034/viewer/2022052410/554a197fb4c9055c598b52d9/html5/thumbnails/108.jpg)