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.
• 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
is perceived as reac$ng instantaneously •A 100ms to 300ms delay is percep$ble •1 second is about the limit for the user's flow of thought to stay uninterrupted •Users expect a site to load in 2 seconds •AXer 3 seconds, 40% will abandon your site. •10 seconds is about the limit for keeping the user's a*en$on •Modern applicaDons spend more Dme in the browser than on the server-side
the client-side and server side as possible (javascript, css, images, fonts, content). • Leverage a CDN + browser caching • Use a reverse proxy cache on the server side • Queuing - Do not delay the user experience for tasks that can be executed in the background • Async - Optimize work to execute concurrently / asynchronously
h:p response should be queued •Sending noDficaDons + posDng to social accounts •AnalyDcs + InstrumentaDon •UpdaDng profiles and discovering friends from social accounts •Consuming web services like Twi:er Streaming API
the same content on different URLs, then that content will be fetched and stored multiple times. Tip: note that URLs are case sensitive! • Ensure the server provides a validation token (ETag): validation tokens eliminate the need to transfer the same bytes when a resource has not changed on the server. • Identify which resources can be cached by intermediaries: those with responses that are identical for all users are great candidates to be cached by a CDN and other intermediaries. • Determine the optimal cache lifetime for each resource: different resources may have different freshness requirements. Audit and determine the appropriate max-age for each one. • Determine the best cache hierarchy for your site: the combination of resource URLs with content fingerprints, and short or no-cache lifetimes for HTML documents allows you to control how quickly updates are picked up by the client.
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
Nginx •Stay up to date with your framework + dependencies (using Composer) •OpDmize 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 producDon performance with AppDynamics!
tomorrows anti-patterns • The limitations of HTTP/1.X forced us to develop various application workarounds (sharding, concatenation, spriting, inlining, etc.) to optimize performance. However, in the process we’ve also introduced numerous regressions: poor caching, unnecessary downloads, delayed execution, and more. • HTTP/2 eliminates the need for these hacks and allows us to both simplify our applications and deliver improved performance. • You should unshard (domains), unconcat (css/javascript), and unsprite your assets (images) • You should switch from inlining to server push • Read Ilya Grigorik awesome book on browser performance - http://hpbn.co/http2