SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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 PlatformWade Wegner
 
maXbox starter46 work with Wine
maXbox starter46 work with WinemaXbox starter46 work with Wine
maXbox starter46 work with WineMax 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
 
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015Kamil Czekirda
 
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
 
HTTPS Explained Through Fairy Tales
HTTPS Explained Through Fairy TalesHTTPS Explained Through Fairy Tales
HTTPS Explained Through Fairy TalesOVHcloud
 
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.jsValentin Lup
 
Nginx cheat sheet
Nginx cheat sheetNginx cheat sheet
Nginx cheat sheetLam Hoang
 

Tendances (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
 

En vedette

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 SymfonyAndré 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 RESTAdam 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 2017Matthias Noback
 
Optimize your eZ Publish with Varnish
Optimize your eZ Publish with VarnishOptimize your eZ Publish with Varnish
Optimize your eZ Publish with VarnishSébastien Morel
 
FOSUserBundle with eZ Platform and MongoDB
FOSUserBundle with eZ Platform and MongoDBFOSUserBundle with eZ Platform and MongoDB
FOSUserBundle with eZ Platform and MongoDBSé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 MacKleyeZ 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 @CodeCampClujTekkie Consulting
 
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 MySQLGabriela Ferrara
 
Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017Colin 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 workshopchartjes
 
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 applicationMichele Orselli
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Colin O'Dell
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projectsIgnacio 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 MigrationsDana Luther
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim 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 PHPChris Tankersley
 

En vedette (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
 

Similaire à 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 2016André 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 PlatformSé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 ClusterAndré 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 KubernetesRobert 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 applicationMarc Weistroff
 
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
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Asher Martin
 
Ny symfony meetup may 2015
Ny symfony meetup may 2015Ny symfony meetup may 2015
Ny symfony meetup may 2015Roland 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 PageSpeededm00se
 
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 2010Gaurav Saxena
 
JS digest. May 2017
JS digest. May 2017JS digest. May 2017
JS digest. May 2017ElifTech
 
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 ClusterAndré Rømcke
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017ElifTech
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9DanHeidinga
 

Similaire à 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
 

Dernier

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 

Dernier (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 

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