SlideShare a Scribd company logo
1 of 16
Varnish
Making eZ Publish sites fly




         Peter Keung


                       http://www.mugo.ca
eZ DFS


Web    Web   Web




NFS            MySQL




                   http://www.mugo.ca
Predictably unpredictable




                  http://www.mugo.ca
Varnish: What
Reverse proxy

              1. request               2. MISS
 Visitor #1                 Varnish                  Web app

              4. response             3. response




                                        Web app
              1. request
 Visitor #2                 Varnish
                                          zzzzzz
                                         zzzzzzz
                2. HIT                     zzzzz




                                       http://www.mugo.ca
Varnish: What

https://www.varnish-cache.org/
Example: Varnish on port 80; Apache on port
88
Serve HTTP GET requests: HTML and assets
very very very very very fast
Can sit on each web server
Can be a load balancer
Saint and grace modes

                                 http://www.mugo.ca
Varnish: Why
Traffic spikes!
vs more hardware
  Cost
  Reliance on NFS
vs CDN
  Cost
  Closer to the application, more hands on
  Not closer to the user
  Use together

                                  http://www.mugo.ca
Optimize everywhere

Apache, MySQL, eZ Publish
Browser caching
Minifying CSS and JS




                            http://www.mugo.ca
Varnish + eZ Publish
eZ Market extension
  http://ez.no/Products/eZ-Market
Mugo Varnish extension:
  https://github.com/mugoweb/mugo_varnish




                                    http://www.mugo.ca
How to integrate
Custom static cache handler
  https://github.com/ezsystems/ezpublish/pull/119
  eZ Publish 2011.9 or 4.7
ezpEvent since 4.5
Purge specific URLs in Administration Interface




                                  http://www.mugo.ca
Configuring Varnish
VCL
 Similar to C
 vcl_recv: what to do with the request
 vcl_hit / vcl_miss
 vcl_fetch: what to do with the response
 vcl_deliver: send the response back
TTL



                                  http://www.mugo.ca
vcl_recv: purge
if( req.request == "PURGE" )
{
    # Limit access for security reasons
    if( !client.ip ~ purge )
    {
        error 405 "Not allowed.";
    }
    # URL purges -- one for the URL and one for all view parameter variations
    if( req.http.X-Purge-Url )
    {
        set req.http.X-Purge-Url1 = "^" + req.http.X-Purge-Url + "$";
        set req.http.X-Purge-Url2 = "^" + req.http.X-Purge-Url + "/(";
        ban( "obj.http.x-url ~ " + req.http.X-Purge-Url1 );
        ban( "obj.http.x-url ~ " + req.http.X-Purge-Url2 );
        error 200 "URL Purged.";
    }
    # Any regular expressions here
    if( req.http.X-Purge-Reg )
    {
        ban( "obj.http.x-url ~ " + req.http.X-Purge-Reg );
        error 200 "Regular Expression Purged.";
    }
    error 405 "Missing X-Purge-Url or X-Purge-Reg header.";
}

                                                            http://www.mugo.ca
vcl_fetch: setting TTL
# Only cache www.yoursite.com
# Only 200 responses
if( req.http.host == "www.yoursite.com" &&
    beresp.status == 200
)
{
    if( req.url ~ "^/var/plain/storage/images/.*" )
    {
        set beresp.ttl = 30d;
        set beresp.http.X-Ttl = "30d";
    }
    else
    {
        # Default caching time
        set beresp.ttl = 300s;
        set beresp.http.X-Ttl = "300s";
    }
}




                                                      http://www.mugo.ca
vcl_deliver: adding diagnostic info
set resp.http.X-Served-By = server.hostname;
if (obj.hits > 0)
{
    set resp.http.X-Cache = "HIT";
    set resp.http.X-Cache-Hits = obj.hits;
}
else
{
    set resp.http.X-Cache = "MISS";
}




                                               http://www.mugo.ca
Tweaks
Cookies: eZ Publish < 4.4
Controlling TTL and excluding pages
  header( 'Edge-control: cache-maxage=86400s' );
  {ezpagedata_append( 'http_headers', 'Edge-
  Control: cache-maxage=0s' )}
Edge Side Includes




                                 http://www.mugo.ca
Ongoing maintenance
   varnishstat
   varnishadm
   curl -I http://www.yoursite.com
HTTP/1.1 200 OK
Server: Apache
X-Cache-Hits: 17
X-Cache: HIT
X-Served-By: CloudWeb2
Via: 1.1 varnish
X-Ttl: 300s
X-Powered-By: eZ Publish
Age: 206




                                     http://www.mugo.ca
Relax




Questions? hi@mugo.ca


                        http://www.mugo.ca

More Related Content

What's hot

Presentation of JSConf.eu
Presentation of JSConf.euPresentation of JSConf.eu
Presentation of JSConf.euFredrik Wendt
 
Solaris 11 base box for Vagrant using Packer
Solaris 11 base box for Vagrant using PackerSolaris 11 base box for Vagrant using Packer
Solaris 11 base box for Vagrant using PackerAlan Chalmers
 
Tools used for debugging
Tools used for debuggingTools used for debugging
Tools used for debuggingMarian Marinov
 
Eduardo Silva - monkey http-server everywhere
Eduardo Silva - monkey http-server everywhereEduardo Silva - monkey http-server everywhere
Eduardo Silva - monkey http-server everywhereStarTech Conference
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's EncryptWalter Ebert
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry managerToshiaki Baba
 
Passwordless login with unix auth_socket
Passwordless login with unix auth_socketPasswordless login with unix auth_socket
Passwordless login with unix auth_socketOtto Kekäläinen
 
Environments line-up! Vagrant & Puppet 101
Environments line-up! Vagrant & Puppet 101Environments line-up! Vagrant & Puppet 101
Environments line-up! Vagrant & Puppet 101jelrikvh
 
agri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertoragri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertorToshiaki Baba
 
Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編Yasuyuki Sugai
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSSKazumi Hirose
 
Redmine on amazon ec2
Redmine on amazon ec2Redmine on amazon ec2
Redmine on amazon ec2Ikuru Kanuma
 
A little systemtap
A little systemtapA little systemtap
A little systemtapyang bingwu
 

What's hot (20)

Presentation of JSConf.eu
Presentation of JSConf.euPresentation of JSConf.eu
Presentation of JSConf.eu
 
Solaris 11 base box for Vagrant using Packer
Solaris 11 base box for Vagrant using PackerSolaris 11 base box for Vagrant using Packer
Solaris 11 base box for Vagrant using Packer
 
Tools used for debugging
Tools used for debuggingTools used for debugging
Tools used for debugging
 
Start using vagrant now!
Start using vagrant now!Start using vagrant now!
Start using vagrant now!
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
 
Eduardo Silva - monkey http-server everywhere
Eduardo Silva - monkey http-server everywhereEduardo Silva - monkey http-server everywhere
Eduardo Silva - monkey http-server everywhere
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 
Passwordless login with unix auth_socket
Passwordless login with unix auth_socketPasswordless login with unix auth_socket
Passwordless login with unix auth_socket
 
Environments line-up! Vagrant & Puppet 101
Environments line-up! Vagrant & Puppet 101Environments line-up! Vagrant & Puppet 101
Environments line-up! Vagrant & Puppet 101
 
agri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertoragri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertor
 
T.Pollak y C.Yaconi - Prey
T.Pollak y C.Yaconi - PreyT.Pollak y C.Yaconi - Prey
T.Pollak y C.Yaconi - Prey
 
Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編Vagrant勉強会 チュートリアル編
Vagrant勉強会 チュートリアル編
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSS
 
Puppet
PuppetPuppet
Puppet
 
Redmine on amazon ec2
Redmine on amazon ec2Redmine on amazon ec2
Redmine on amazon ec2
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
Laravel Day / Deploy
Laravel Day / DeployLaravel Day / Deploy
Laravel Day / Deploy
 

Similar to Varnish: Making eZ Publish sites fly

How we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaHow we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaCosimo Streppone
 
VUG5: Varnish at Opera Software
VUG5: Varnish at Opera SoftwareVUG5: Varnish at Opera Software
VUG5: Varnish at Opera SoftwareCosimo Streppone
 
Nginx Workshop Aftermath
Nginx Workshop AftermathNginx Workshop Aftermath
Nginx Workshop AftermathDenis Zhdanov
 
Altitude SF 2017: Advanced VCL: Shielding and Clustering
Altitude SF 2017: Advanced VCL: Shielding and ClusteringAltitude SF 2017: Advanced VCL: Shielding and Clustering
Altitude SF 2017: Advanced VCL: Shielding and ClusteringFastly
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Ben Hall
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHPDavid de Boer
 
June8 presentation
June8 presentationJune8 presentation
June8 presentationnicobn
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019Matt Raible
 
HTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The DeadHTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The Deadnoamt
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - DeploymentFabio Akita
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with VarnishVarnish Software
 
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with RackDonSchado
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Данил Иванов
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Jeff Jones
 
Spider Setup with AWS/sandbox
Spider Setup with AWS/sandboxSpider Setup with AWS/sandbox
Spider Setup with AWS/sandboxI Goo Lee
 
MySQL Spider Architecture
MySQL Spider ArchitectureMySQL Spider Architecture
MySQL Spider ArchitectureI Goo Lee
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web ApplicationMartins Sipenko
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Arun Gupta
 

Similar to Varnish: Making eZ Publish sites fly (20)

How we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaHow we use and deploy Varnish at Opera
How we use and deploy Varnish at Opera
 
VUG5: Varnish at Opera Software
VUG5: Varnish at Opera SoftwareVUG5: Varnish at Opera Software
VUG5: Varnish at Opera Software
 
Nginx Workshop Aftermath
Nginx Workshop AftermathNginx Workshop Aftermath
Nginx Workshop Aftermath
 
Altitude SF 2017: Advanced VCL: Shielding and Clustering
Altitude SF 2017: Advanced VCL: Shielding and ClusteringAltitude SF 2017: Advanced VCL: Shielding and Clustering
Altitude SF 2017: Advanced VCL: Shielding and Clustering
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHP
 
June8 presentation
June8 presentationJune8 presentation
June8 presentation
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
 
HTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The DeadHTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The Dead
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - Deployment
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with Varnish
 
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with Rack
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Spider Setup with AWS/sandbox
Spider Setup with AWS/sandboxSpider Setup with AWS/sandbox
Spider Setup with AWS/sandbox
 
MySQL Spider Architecture
MySQL Spider ArchitectureMySQL Spider Architecture
MySQL Spider Architecture
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Varnish: Making eZ Publish sites fly

  • 1. Varnish Making eZ Publish sites fly Peter Keung http://www.mugo.ca
  • 2. eZ DFS Web Web Web NFS MySQL http://www.mugo.ca
  • 3. Predictably unpredictable http://www.mugo.ca
  • 4. Varnish: What Reverse proxy 1. request 2. MISS Visitor #1 Varnish Web app 4. response 3. response Web app 1. request Visitor #2 Varnish zzzzzz zzzzzzz 2. HIT zzzzz http://www.mugo.ca
  • 5. Varnish: What https://www.varnish-cache.org/ Example: Varnish on port 80; Apache on port 88 Serve HTTP GET requests: HTML and assets very very very very very fast Can sit on each web server Can be a load balancer Saint and grace modes http://www.mugo.ca
  • 6. Varnish: Why Traffic spikes! vs more hardware Cost Reliance on NFS vs CDN Cost Closer to the application, more hands on Not closer to the user Use together http://www.mugo.ca
  • 7. Optimize everywhere Apache, MySQL, eZ Publish Browser caching Minifying CSS and JS http://www.mugo.ca
  • 8. Varnish + eZ Publish eZ Market extension http://ez.no/Products/eZ-Market Mugo Varnish extension: https://github.com/mugoweb/mugo_varnish http://www.mugo.ca
  • 9. How to integrate Custom static cache handler https://github.com/ezsystems/ezpublish/pull/119 eZ Publish 2011.9 or 4.7 ezpEvent since 4.5 Purge specific URLs in Administration Interface http://www.mugo.ca
  • 10. Configuring Varnish VCL Similar to C vcl_recv: what to do with the request vcl_hit / vcl_miss vcl_fetch: what to do with the response vcl_deliver: send the response back TTL http://www.mugo.ca
  • 11. vcl_recv: purge if( req.request == "PURGE" ) { # Limit access for security reasons if( !client.ip ~ purge ) { error 405 "Not allowed."; } # URL purges -- one for the URL and one for all view parameter variations if( req.http.X-Purge-Url ) { set req.http.X-Purge-Url1 = "^" + req.http.X-Purge-Url + "$"; set req.http.X-Purge-Url2 = "^" + req.http.X-Purge-Url + "/("; ban( "obj.http.x-url ~ " + req.http.X-Purge-Url1 ); ban( "obj.http.x-url ~ " + req.http.X-Purge-Url2 ); error 200 "URL Purged."; } # Any regular expressions here if( req.http.X-Purge-Reg ) { ban( "obj.http.x-url ~ " + req.http.X-Purge-Reg ); error 200 "Regular Expression Purged."; } error 405 "Missing X-Purge-Url or X-Purge-Reg header."; } http://www.mugo.ca
  • 12. vcl_fetch: setting TTL # Only cache www.yoursite.com # Only 200 responses if( req.http.host == "www.yoursite.com" && beresp.status == 200 ) { if( req.url ~ "^/var/plain/storage/images/.*" ) { set beresp.ttl = 30d; set beresp.http.X-Ttl = "30d"; } else { # Default caching time set beresp.ttl = 300s; set beresp.http.X-Ttl = "300s"; } } http://www.mugo.ca
  • 13. vcl_deliver: adding diagnostic info set resp.http.X-Served-By = server.hostname; if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; set resp.http.X-Cache-Hits = obj.hits; } else { set resp.http.X-Cache = "MISS"; } http://www.mugo.ca
  • 14. Tweaks Cookies: eZ Publish < 4.4 Controlling TTL and excluding pages header( 'Edge-control: cache-maxage=86400s' ); {ezpagedata_append( 'http_headers', 'Edge- Control: cache-maxage=0s' )} Edge Side Includes http://www.mugo.ca
  • 15. Ongoing maintenance varnishstat varnishadm curl -I http://www.yoursite.com HTTP/1.1 200 OK Server: Apache X-Cache-Hits: 17 X-Cache: HIT X-Served-By: CloudWeb2 Via: 1.1 varnish X-Ttl: 300s X-Powered-By: eZ Publish Age: 206 http://www.mugo.ca
  • 16. Relax Questions? hi@mugo.ca http://www.mugo.ca