SlideShare a Scribd company logo
CACHING THE RIGHT WAY
Increase Your Application Performance & Validate It With Profiling
André Rømcke (@andrerom)

VP Engineering at eZ Systems (@ezsystems)
Jan. 28th 2017 - Antwerp - #PHPBenelux 2017
www.ez.no
Who?
๏André Rømcke | @andrerom
๏Norwegian, mountains, skiing, biking, running, technology, beer, wine, foodie, ..
๏PHP for 11 years. From 96: Html, CSS, JS, VB, C#, PHP, Bash, Groovy, (Hack)
๏Contributed to Symfony, FOS, Stash, Composer, PHP-FIG, Docker, & attempts for PHP
๏VP Engineering at eZ Systems
๏eZ Systems AS | ez.no
๏Global, 70+ people across 7+ countries, partners & community in many many more
๏Maker of eZ Publish since 2001, 6th+ gen called eZ Studio (commercial) & eZ Platform
๏eZ Platform | ezplatform.com
๏“New” open source Content Management System, a super flexible Full & Headless CMS
๏Developed on Symfony (v2.x) Full Stack since 2012, upcoming major on Symfony v3.3
www.ez.no
What is it with Caching?
www.ez.no
So what is it with this talk? And what not?
๏Talk focusing on cache tagging in Varnish and in Symfony Cache
๏It’s benefits, practice and profiling
๏Talk is specific about eZ Platform, and move from a cache approach that
๏This is in this case using, but not going into details on:
๏FOSHttpCache: See David Buchmann’s talk for that at 11:40
๏PSR-6: See Hannes Van De Vreken’s talk on that at 14:50
Bit of background of the application I work on:

eZ Platform
www.ez.no
eZ Platform 1.x: Overview
๏6th generation of eZ Publish, a CMS that has been around since 2001
๏Several large users around the world
๏Focus on being very extendable so it can be used in many cases
๏A tree based content model, we’ll come back to this
๏So old but “new” in the sense that it is a new product rewritten on Symfony
๏So more modern, but with less features
www.ez.no
eZ Platform 1.x Architecture
www.ez.no
eZ Platform 1.x: Persistance Cache
๏Currently built using Stash cache
๏A hierarchal cache, allowing you to clear trees of cache items
๏Benefit 1: Easy to get started
๏Problem 1: End up clearing to much cache
๏Problem 2: Many lookups to backend to resolve items
www.ez.no
eZ Platform 1.x: HttpCache
๏Uses FOSHttpCache[Bundle] 1.x
๏Lets you vary cache by user context (rights)
๏Lets you tag the response and BAN based on this
๏Problem 1: BAN on Varnish does not support grace
๏Problem 2: Multiple tags only on Varnish
Pinch of theory:

Where Cache Tagging/Labeling fits
www.ez.no
Problem
www.ez.no
Problem
Examples:
๏Data cache (PSR-6, ..):
๏Entity can be present on several cache keys
๏eg: Item lookup by id or by identifier/remote-id, in listings, ..
๏Reverse Proxy (Varnish with FosHttpCache, ..):
๏Entity can be rendered on several different pages (url ~= key)
๏And url won’t represent the unity when it’s a “fragment” of the page
๏It can also be, or not be, on a variant of a page depending on user rights
Result: Need for knowledge between Cache items and Commands/Actions affecting it.
www.ez.no
Solution: Tags/Labels for all
๏Data cache (PSR-6, ..):
๏key: item-66 tags: item-66
๏key: item-identifier-phpbenelux tags: item-66
๏key: item-list-type-article tags: item-66, item-44, (…)
๏Reverse Proxy (Varnish with FosHttpCache, ..):
๏url: Home/Articles/PHPBenelux tags: item-66
๏url: Home/Articles tags: item-23, item-66, (..)
๏url: api/item/66 tags: item-66
๏url: api/item/66?include=parent.name tags: item-66, item-23
Look at real world Solutions:

Symfony Cache (3.2+)
www.ez.noez.no
Symfony Cache Component
๏PSR-6 Compliant cache component
๏Aims to be fast, made by among others Blackfire CTO: Nicolas Grekas
๏Supports multi get calls to Redis and Memcached
๏Provides several built in cache adapters by default
๏Is progressively being used in several places in Symfony Framework, e.g.:
๏PropertyInfo
๏Serializer
๏Validator
๏(…)
๏.. And hopefully HTTP Cache at some point
www.ez.noez.no
Symfony Cache Adapters
๏Adapters:
๏APCu (per proces cache)
๏Array (in memory per request, mainly for testing)
๏Chain (chain several adapters after each-other)
๏Doctrine
๏FileSystem (Also PHPFile and PHPArray implementation for immutable opcache cache)
๏Proxy (To reuse other PSR-6 implementations)
๏Redis
๏Memcached
๏And TagAware..
www.ez.noez.no
Symfony Cache Backend Lookups
Stash Cache* Doctrine Cache** Symfony Cache***
loadContenetInfo(66) 5 2 1
loadContenet(66) 6 2 1
findContent($query)

10 items 42 2 1
*** With native adapters,

not Doctrine.
* memcached/redis, to compute keys
for hierarchical cache.
** With versioning.
www.ez.noez.no
Cache Backend latency with Stash
๏AWS ElasticCache Redis instances has latency of:
๏On larger EC2 instances: 0.2-0.5ms
๏On micro/small instances: Apparently much more
๏This means when proxy cache is cold:
๏Simple page with 20 items shown:
๏~82 lookups x latency = 16-41 ms
๏Large landing page with 200-1000 items shown:
๏~8.000-40.000 lookups x latency = 1.6-20 seconds
๏In theory Symfony cache should get a 4th of that
๏And much less if its support for multiple get is taken advantage of.



Look at real world Solutions:

Varnish xkey VMOD (4.1+)
www.ez.no
๏Formally: Surrogate keys, Hash Ninja, Secondary Hash/Hash-Two
๏Dedicated secondary hashes to objects
๏Much more efficient for tag purging then BAN is
๏Allows for expiring objects with softpurge() for use with grace
๏Deliver stale data while refresh happens in the background
๏Part of official `varnish-modules` VMOD collection package
๏Already part of Ubuntu, upcoming Debian and probably RHEL
Varnish xkey VMOD
www.ez.no
๏PR in progress to support in FOSHttpCache 2.1
๏Simple configuration and VCL change to switch from BAN
Varnish xkey & FOSHttpCache
Sip of demo time:

Some code examples, and if time profiling
ongoing move to Symfony 3.x (incl Cache
Component)
www.ez.no
๏For pure move from Stash to Symfony Cache just using file system as cache
๏With Reverse proxy disabled to hit backend
Demo Profiling Result
www.ez.no
๏Profiling should have been done using Redis/Memcached on AWS setup
๏20% improvements would have been many times more with latency
๏The profiling was done with Blackfire,
๏For your own use you can also use xdebug profiling, tideways.io, (..)
Demo Profiling Retrospective
The End, Questions?
This talk: https://joind.in/talk/66ef8
Other talks: http://www.slideshare.net/andreromcke
Twitter: @andrerom



FOSHttpCache: http://foshttpcache.readthedocs.io/en/latest/
Varnish xkey: https://github.com/varnish/varnish-modules/blob/master/docs/vmod_xkey.rst

More Related Content

What's hot

Building High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure PlatformBuilding High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure Platform
Wade Wegner
 
maXbox starter46 work with Wine
maXbox starter46 work with WinemaXbox starter46 work with Wine
maXbox starter46 work with Wine
Max Kleiner
 
Introducing with MongoDB
Introducing with MongoDBIntroducing with MongoDB
Introducing with MongoDBMahbub Tito
 
JCache is here. Say Goodbye to proprietary Caching APIs!
JCache is here. Say Goodbye to proprietary Caching APIs!JCache is here. Say Goodbye to proprietary Caching APIs!
JCache is here. Say Goodbye to proprietary Caching APIs!
Jaromir Hamala
 
Restinio (actual aug 2018)
Restinio (actual aug 2018)Restinio (actual aug 2018)
Restinio (actual aug 2018)
Nicolai Grodzitski
 
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
Kamil Czekirda
 
WebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossibleWebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossible
Yoan-Alexander Grigorov
 
Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編
Yasuyuki Sugai
 
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
Magento Meetup Wrocław
 
Difference between php and node
Difference between php and nodeDifference between php and node
Difference between php and node
Nguyễn Ngọc Phương
 
HTTPS Explained Through Fairy Tales
HTTPS Explained Through Fairy TalesHTTPS Explained Through Fairy Tales
HTTPS Explained Through Fairy Tales
OVHcloud
 
JugTAAS ReSTful
JugTAAS ReSTfulJugTAAS ReSTful
JugTAAS ReSTful
Tiziano Lattisi
 
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
LumoSpark
 
解密解密
解密解密解密解密
解密解密
Tom Chen
 
Minio: Associated projects in Go programming.
Minio: Associated projects in Go programming. Minio: Associated projects in Go programming.
Minio: Associated projects in Go programming.
Atul Jha
 
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
hamidsamadi
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.js
Valentin Lup
 
Windows 7 installation ppt
Windows 7 installation pptWindows 7 installation ppt
Windows 7 installation ppt
Nagarajan Kamalakannan
 
Nginx cheat sheet
Nginx cheat sheetNginx cheat sheet
Nginx cheat sheet
Lam Hoang
 

What's hot (20)

Building High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure PlatformBuilding High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure Platform
 
maXbox starter46 work with Wine
maXbox starter46 work with WinemaXbox starter46 work with Wine
maXbox starter46 work with Wine
 
Introducing with MongoDB
Introducing with MongoDBIntroducing with MongoDB
Introducing with MongoDB
 
JCache is here. Say Goodbye to proprietary Caching APIs!
JCache is here. Say Goodbye to proprietary Caching APIs!JCache is here. Say Goodbye to proprietary Caching APIs!
JCache is here. Say Goodbye to proprietary Caching APIs!
 
Restinio (actual aug 2018)
Restinio (actual aug 2018)Restinio (actual aug 2018)
Restinio (actual aug 2018)
 
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
 
WebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossibleWebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossible
 
Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編
 
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
 
Difference between php and node
Difference between php and nodeDifference between php and node
Difference between php and node
 
HTTPS Explained Through Fairy Tales
HTTPS Explained Through Fairy TalesHTTPS Explained Through Fairy Tales
HTTPS Explained Through Fairy Tales
 
JugTAAS ReSTful
JugTAAS ReSTfulJugTAAS ReSTful
JugTAAS ReSTful
 
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
 
解密解密
解密解密解密解密
解密解密
 
Minio: Associated projects in Go programming.
Minio: Associated projects in Go programming. Minio: Associated projects in Go programming.
Minio: Associated projects in Go programming.
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.js
 
Windows 7 installation ppt
Windows 7 installation pptWindows 7 installation ppt
Windows 7 installation ppt
 
Nginx cheat sheet
Nginx cheat sheetNginx cheat sheet
Nginx cheat sheet
 

Viewers also liked

Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
André Rømcke
 
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTPHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
Adam Englander
 
Beyond Design Patterns and Principles - PHPBenelux 2017
Beyond Design Patterns and Principles - PHPBenelux 2017Beyond Design Patterns and Principles - PHPBenelux 2017
Beyond Design Patterns and Principles - PHPBenelux 2017
Matthias Noback
 
eZ Accelerator v1
eZ Accelerator v1eZ Accelerator v1
eZ Accelerator v1
Sébastien Morel
 
Optimize your eZ Publish with Varnish
Optimize your eZ Publish with VarnishOptimize your eZ Publish with Varnish
Optimize your eZ Publish with Varnish
Sébastien Morel
 
FOSUserBundle with eZ Platform and MongoDB
FOSUserBundle with eZ Platform and MongoDBFOSUserBundle with eZ Platform and MongoDB
FOSUserBundle with eZ Platform and MongoDB
Sébastien Morel
 
UX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKley
UX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKleyUX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKley
UX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKley
eZ Systems
 
Silo-Based Architectures for High Availability Applications @CodeCampCluj
Silo-Based Architectures for High Availability Applications @CodeCampClujSilo-Based Architectures for High Availability Applications @CodeCampCluj
Silo-Based Architectures for High Availability Applications @CodeCampCluj
Tekkie Consulting
 
Php extensions
Php extensionsPhp extensions
Php extensions
Elizabeth Smith
 
SunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQL
Gabriela Ferrara
 
Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017
Colin O'Dell
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
chartjes
 
A recommendation engine for your php application
A recommendation engine for your php applicationA recommendation engine for your php application
A recommendation engine for your php application
Michele Orselli
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017
Colin O'Dell
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
Dana Luther
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
JWT - To authentication and beyond!
JWT - To authentication and beyond!JWT - To authentication and beyond!
JWT - To authentication and beyond!
Luís Cobucci
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHP
Chris Tankersley
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
 

Viewers also liked (20)

Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTPHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
 
Beyond Design Patterns and Principles - PHPBenelux 2017
Beyond Design Patterns and Principles - PHPBenelux 2017Beyond Design Patterns and Principles - PHPBenelux 2017
Beyond Design Patterns and Principles - PHPBenelux 2017
 
eZ Accelerator v1
eZ Accelerator v1eZ Accelerator v1
eZ Accelerator v1
 
Optimize your eZ Publish with Varnish
Optimize your eZ Publish with VarnishOptimize your eZ Publish with Varnish
Optimize your eZ Publish with Varnish
 
FOSUserBundle with eZ Platform and MongoDB
FOSUserBundle with eZ Platform and MongoDBFOSUserBundle with eZ Platform and MongoDB
FOSUserBundle with eZ Platform and MongoDB
 
UX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKley
UX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKleyUX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKley
UX Mind Games: The Secrets of Addictive Digital Experiences by Stephen MacKley
 
Silo-Based Architectures for High Availability Applications @CodeCampCluj
Silo-Based Architectures for High Availability Applications @CodeCampClujSilo-Based Architectures for High Availability Applications @CodeCampCluj
Silo-Based Architectures for High Availability Applications @CodeCampCluj
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
SunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQL
 
Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
 
A recommendation engine for your php application
A recommendation engine for your php applicationA recommendation engine for your php application
A recommendation engine for your php application
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
JWT - To authentication and beyond!
JWT - To authentication and beyond!JWT - To authentication and beyond!
JWT - To authentication and beyond!
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHP
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 

Similar to PHP Benelux 2017 - Caching The Right Way

Look Towards 2.0 and Beyond - eZ Conference 2016
Look Towards 2.0 and Beyond -   eZ Conference 2016Look Towards 2.0 and Beyond -   eZ Conference 2016
Look Towards 2.0 and Beyond - eZ Conference 2016
André Rømcke
 
eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...
eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...
eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...
eZ Systems
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
Sébastien Morel
 
SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis ClusterSymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
André Rømcke
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
Robert Lemke
 
Nice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 applicationNice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 application
Marc Weistroff
 
World of Node.JS
World of Node.JSWorld of Node.JS
World of Node.JS
Alexander Shtuchkin
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
jeresig
 
Docker 101
Docker 101 Docker 101
Docker 101
Kevin Nord
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3
Asher Martin
 
Ny symfony meetup may 2015
Ny symfony meetup may 2015Ny symfony meetup may 2015
Ny symfony meetup may 2015
Roland Benedetti
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
NCCOMMS
 
Open Source Flash 2010
Open Source Flash 2010Open Source Flash 2010
Open Source Flash 2010
Gaurav Saxena
 
JS digest. May 2017
JS digest. May 2017JS digest. May 2017
JS digest. May 2017
ElifTech
 
eZ Publish 5 in depth inspection
eZ Publish 5 in depth inspectioneZ Publish 5 in depth inspection
eZ Publish 5 in depth inspection
Jérôme Vieilledent
 
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis ClusterSfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
André Rømcke
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017
ElifTech
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9
DanHeidinga
 

Similar to PHP Benelux 2017 - Caching The Right Way (20)

Look Towards 2.0 and Beyond - eZ Conference 2016
Look Towards 2.0 and Beyond -   eZ Conference 2016Look Towards 2.0 and Beyond -   eZ Conference 2016
Look Towards 2.0 and Beyond - eZ Conference 2016
 
eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...
eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...
eZ Platform and eZ Studio: Where We Are, Where We Are Going, and a Look Towar...
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis ClusterSymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
 
Nice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 applicationNice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 application
 
World of Node.JS
World of Node.JSWorld of Node.JS
World of Node.JS
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
 
Docker 101
Docker 101 Docker 101
Docker 101
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3
 
Ny symfony meetup may 2015
Ny symfony meetup may 2015Ny symfony meetup may 2015
Ny symfony meetup may 2015
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
 
Open Source Flash 2010
Open Source Flash 2010Open Source Flash 2010
Open Source Flash 2010
 
JS digest. May 2017
JS digest. May 2017JS digest. May 2017
JS digest. May 2017
 
eZ Publish 5 in depth inspection
eZ Publish 5 in depth inspectioneZ Publish 5 in depth inspection
eZ Publish 5 in depth inspection
 
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis ClusterSfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9
 

Recently uploaded

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 

Recently uploaded (20)

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 

PHP Benelux 2017 - Caching The Right Way

  • 1. CACHING THE RIGHT WAY Increase Your Application Performance & Validate It With Profiling André Rømcke (@andrerom)
 VP Engineering at eZ Systems (@ezsystems) Jan. 28th 2017 - Antwerp - #PHPBenelux 2017
  • 2. www.ez.no Who? ๏André Rømcke | @andrerom ๏Norwegian, mountains, skiing, biking, running, technology, beer, wine, foodie, .. ๏PHP for 11 years. From 96: Html, CSS, JS, VB, C#, PHP, Bash, Groovy, (Hack) ๏Contributed to Symfony, FOS, Stash, Composer, PHP-FIG, Docker, & attempts for PHP ๏VP Engineering at eZ Systems ๏eZ Systems AS | ez.no ๏Global, 70+ people across 7+ countries, partners & community in many many more ๏Maker of eZ Publish since 2001, 6th+ gen called eZ Studio (commercial) & eZ Platform ๏eZ Platform | ezplatform.com ๏“New” open source Content Management System, a super flexible Full & Headless CMS ๏Developed on Symfony (v2.x) Full Stack since 2012, upcoming major on Symfony v3.3
  • 3. www.ez.no What is it with Caching?
  • 4. www.ez.no So what is it with this talk? And what not? ๏Talk focusing on cache tagging in Varnish and in Symfony Cache ๏It’s benefits, practice and profiling ๏Talk is specific about eZ Platform, and move from a cache approach that ๏This is in this case using, but not going into details on: ๏FOSHttpCache: See David Buchmann’s talk for that at 11:40 ๏PSR-6: See Hannes Van De Vreken’s talk on that at 14:50
  • 5. Bit of background of the application I work on:
 eZ Platform
  • 6. www.ez.no eZ Platform 1.x: Overview ๏6th generation of eZ Publish, a CMS that has been around since 2001 ๏Several large users around the world ๏Focus on being very extendable so it can be used in many cases ๏A tree based content model, we’ll come back to this ๏So old but “new” in the sense that it is a new product rewritten on Symfony ๏So more modern, but with less features
  • 8. www.ez.no eZ Platform 1.x: Persistance Cache ๏Currently built using Stash cache ๏A hierarchal cache, allowing you to clear trees of cache items ๏Benefit 1: Easy to get started ๏Problem 1: End up clearing to much cache ๏Problem 2: Many lookups to backend to resolve items
  • 9. www.ez.no eZ Platform 1.x: HttpCache ๏Uses FOSHttpCache[Bundle] 1.x ๏Lets you vary cache by user context (rights) ๏Lets you tag the response and BAN based on this ๏Problem 1: BAN on Varnish does not support grace ๏Problem 2: Multiple tags only on Varnish
  • 10. Pinch of theory:
 Where Cache Tagging/Labeling fits
  • 12. www.ez.no Problem Examples: ๏Data cache (PSR-6, ..): ๏Entity can be present on several cache keys ๏eg: Item lookup by id or by identifier/remote-id, in listings, .. ๏Reverse Proxy (Varnish with FosHttpCache, ..): ๏Entity can be rendered on several different pages (url ~= key) ๏And url won’t represent the unity when it’s a “fragment” of the page ๏It can also be, or not be, on a variant of a page depending on user rights Result: Need for knowledge between Cache items and Commands/Actions affecting it.
  • 13. www.ez.no Solution: Tags/Labels for all ๏Data cache (PSR-6, ..): ๏key: item-66 tags: item-66 ๏key: item-identifier-phpbenelux tags: item-66 ๏key: item-list-type-article tags: item-66, item-44, (…) ๏Reverse Proxy (Varnish with FosHttpCache, ..): ๏url: Home/Articles/PHPBenelux tags: item-66 ๏url: Home/Articles tags: item-23, item-66, (..) ๏url: api/item/66 tags: item-66 ๏url: api/item/66?include=parent.name tags: item-66, item-23
  • 14. Look at real world Solutions:
 Symfony Cache (3.2+)
  • 15. www.ez.noez.no Symfony Cache Component ๏PSR-6 Compliant cache component ๏Aims to be fast, made by among others Blackfire CTO: Nicolas Grekas ๏Supports multi get calls to Redis and Memcached ๏Provides several built in cache adapters by default ๏Is progressively being used in several places in Symfony Framework, e.g.: ๏PropertyInfo ๏Serializer ๏Validator ๏(…) ๏.. And hopefully HTTP Cache at some point
  • 16. www.ez.noez.no Symfony Cache Adapters ๏Adapters: ๏APCu (per proces cache) ๏Array (in memory per request, mainly for testing) ๏Chain (chain several adapters after each-other) ๏Doctrine ๏FileSystem (Also PHPFile and PHPArray implementation for immutable opcache cache) ๏Proxy (To reuse other PSR-6 implementations) ๏Redis ๏Memcached ๏And TagAware..
  • 17. www.ez.noez.no Symfony Cache Backend Lookups Stash Cache* Doctrine Cache** Symfony Cache*** loadContenetInfo(66) 5 2 1 loadContenet(66) 6 2 1 findContent($query)
 10 items 42 2 1 *** With native adapters,
 not Doctrine. * memcached/redis, to compute keys for hierarchical cache. ** With versioning.
  • 18. www.ez.noez.no Cache Backend latency with Stash ๏AWS ElasticCache Redis instances has latency of: ๏On larger EC2 instances: 0.2-0.5ms ๏On micro/small instances: Apparently much more ๏This means when proxy cache is cold: ๏Simple page with 20 items shown: ๏~82 lookups x latency = 16-41 ms ๏Large landing page with 200-1000 items shown: ๏~8.000-40.000 lookups x latency = 1.6-20 seconds ๏In theory Symfony cache should get a 4th of that ๏And much less if its support for multiple get is taken advantage of.
 

  • 19. Look at real world Solutions:
 Varnish xkey VMOD (4.1+)
  • 20. www.ez.no ๏Formally: Surrogate keys, Hash Ninja, Secondary Hash/Hash-Two ๏Dedicated secondary hashes to objects ๏Much more efficient for tag purging then BAN is ๏Allows for expiring objects with softpurge() for use with grace ๏Deliver stale data while refresh happens in the background ๏Part of official `varnish-modules` VMOD collection package ๏Already part of Ubuntu, upcoming Debian and probably RHEL Varnish xkey VMOD
  • 21. www.ez.no ๏PR in progress to support in FOSHttpCache 2.1 ๏Simple configuration and VCL change to switch from BAN Varnish xkey & FOSHttpCache
  • 22. Sip of demo time:
 Some code examples, and if time profiling ongoing move to Symfony 3.x (incl Cache Component)
  • 23. www.ez.no ๏For pure move from Stash to Symfony Cache just using file system as cache ๏With Reverse proxy disabled to hit backend Demo Profiling Result
  • 24. www.ez.no ๏Profiling should have been done using Redis/Memcached on AWS setup ๏20% improvements would have been many times more with latency ๏The profiling was done with Blackfire, ๏For your own use you can also use xdebug profiling, tideways.io, (..) Demo Profiling Retrospective
  • 25. The End, Questions? This talk: https://joind.in/talk/66ef8 Other talks: http://www.slideshare.net/andreromcke Twitter: @andrerom
 
 FOSHttpCache: http://foshttpcache.readthedocs.io/en/latest/ Varnish xkey: https://github.com/varnish/varnish-modules/blob/master/docs/vmod_xkey.rst