Drupal, varnish, esi - Toulouse November 2

Marcus Deglos
Marcus DeglosFounder, Solutions Architect at Techito
Drupal, varnish, esi - Toulouse November 2
Marcus Deglos
@manarth
#cdl2011
Drupal, varnish, esi - Toulouse November 2
> Old
           faithful, serving
           sites since 1996.
         > Quick
         > Simple
Apache
Apache's model


             Web server
Apache's model with PHP


                      Web server




               PHP engine
Do it with Drupal


                   Web server
                                  DB


                                index.php


            PHP engine
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"

"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html

                        Example HTML
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" version="XHTML+RDFa 1.0" dir="ltr"

xmlns:content="http://purl.org/rss/1.0/modules/content/"

xmlns:dc="http://purl.org/dc/terms/"
 xmlns:foaf="http://xmlns.com/foaf/0.1/"

xmlns:og="http://ogp.me/ns#"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"

xmlns:sioc="http://rdfs.org/sioc/ns#"
 xmlns:sioct="http://rdfs.org/sioc/types#"

xmlns:skos="http://www.w3.org/2004/02/skos/core#"

xmlns:xsd="http://www.w3.org/2001/XMLSchema#">

<head
profile="http://www.w3.org/1999/xhtml/vocab">
 <meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<link rel="shortcut icon"
href="http://testbed.local/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<meta
name="Generator" content="Drupal 7 (http://drupal.org)" />
 <title>Welcome to Site-Install |
Site-Install</title>




                HTML from homepage after
                          running drushsi
Drag race results
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
> Prepared in
          advance
        > Typically uses a
          build-script
        > Produces static
          pages
        > Quick
        > No complex
          behaviour
        > Boost module is an
Baked     example
> Pages created on
  the fly
> CMS or other
  complex dynamic
  system
> Allows complex
  behaviour
> Drupal does this
> Slow
                     Fried
Drupal, varnish, esi - Toulouse November 2
> Software
                     package
                     (daemon) for
                     linux
                   > Reverse proxy,
                     such as Squid,
                     Nginx and Zeus
What is Varnish?   > Cache
How Varnish works
   GET /blog
   Host   deglos.com
   User-AgentMozilla/5.0 (Macintosh; Intel
   Mac OS X 10.6; rv:8.0.1) Gecko/20100101
   Firefox/8.0.1
   Accept
      text/html,application/xhtml+xml,applic
   ation/xml;q=0.9,*/*;q=0.8
   Varnish                Drupal
   Accept-Language en-us,en;q=0.5
   Accept-Encoding gzip, deflate
   Accept-Charset    ISO-8859-1,utf-
   8;q=0.7,*;q=0.7
   Connectionkeep-alive
Varnish is slower
  If Varnish passes every request to Drupal
  – and acts just as a MITM – your site will
  be slower.



  Varnish               Drupal
Varnish needs to cache



     Varnish           Drupal




               Cache
Varnish + cache is quicker
   10x faster
   (or more)



          Varnish           Drupal




                    Cache
Personalisation is a problem



        Varnish           Drupal




                  Cache
The Uncacheable



  Varnish           Drupal




            Cache
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Example VCL:
#This is a basic VCL configuration file for
  varnish.
backend default {
  .host = "127.0.0.1";
  .port = "80";
}

sub vcl_fetch {
  unset obj.http.Cache-Control;
  unset obj.http.Expires;
  set obj.ttl = 86400s;
}
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
vcl.list
telnet localhost6082
Trying ::1...
Connected to localhost.
Escape character is '^]'.
vcl.list
200 23
active          1 boot
help
telnet localhost6082
Trying ::1...
Connected to localhost.
Escape character is '^]'.
help
200 376
help [command]
ping [timestamp]
status
start
stop
stats
...
url.purge
telnet localhost6082
Trying ::1...
Connected to localhost.
Escape character is '^]'.
url.purge .*
200 0
Drupal, varnish, esi - Toulouse November 2
Setting up Varnish
> Download varnish daemon
  debian: apt-get install varnish
  redhat:yum install varnish
> Re-configure Apache to listen on port 8080
  (or other non-standard port)
> Configure Varnish to listen on port 80
> Configure Varnish VCL to connect to
  Apache
> VCL tweaks (default does not cache
  Drupal)
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Serving ESIs



Varnish           Drupal




          Cache
Serving ESIs



Varnish           Drupal




          Cache
Serving ESIs
<div id="nav-masthead" class="grid-12">
<ul>
<li class="homepage active first active">
<a href="/home" class="active active">Drupal Homepage</a>
</li>
<li class="dashboard last">
<a href="/user/dashboard">Your Dashboard</a>
</li>
</ul>                   Varnish                      Drupal
<div id="userinfo">
<a href="/user" title="View &amp; edit your user profile">Logged in as
manarth</a>
<a href="/logout">Log out</a>
</div>
</div><!-- /#nav-masthead -->            Cache
Serving ESIs
<div id="nav-masthead" class="grid-12">
<ul>
<li class="homepage active first active">
<a href="/home" class="active active">Drupal Homepage</a>
</li>
<li class="dashboard last">
<a href="/user/dashboard">Your Dashboard</a>
</li>
</ul>                 Varnish                 Drupal
<esisrc="http://example.com/esi/userinfo" />




</div><!-- /#nav-masthead -->     Cache
Serving ESIs

<div id="userinfo">
<a href="/user" title="View &amp; edit your user profile">Logged in
as manarth</a>
<a href="/logout">Log out</a>
</div>
                 Varnish                     Drupal




                                  Cache
What do you need in order to do
             ESIs?
> Replace personalisationwith ESI tags
  Theme-alters?
> Provide backend hook_menuhandlers for
  each ESI tag
> Ensure that Varnish is caching
> Rule 35 applies
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Configuring ESI Blocks
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
Flickr Credits
> Babbage engine
  http://www.flickr.com/photos/melgart/4444251
  225
> Cookies
  http://www.flickr.com/photos/sabine01/24855
  02578
> Frying wok
  http://www.flickr.com/photos/18403292@N00/
  3048993
> Varnish
  http://www.flickr.com/photos/dawniecakes/46
  86467791
Drupal, varnish, esi - Toulouse November 2
1 of 53

Recommended

Performance all teh things by
Performance all teh thingsPerformance all teh things
Performance all teh thingsMarcus Deglos
1.3K views63 slides
Speeding Up The Snail by
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The SnailMarcus Deglos
1.4K views27 slides
Varnish bof by
Varnish bofVarnish bof
Varnish bofMarcus Deglos
2.6K views58 slides
Drupal feature proposal: two new stream-wrappers by
Drupal feature proposal: two new stream-wrappersDrupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersMarcus Deglos
702 views28 slides
Varnish intro by
Varnish introVarnish intro
Varnish introBoyan Borisov
1.1K views26 slides
Caching with Varnish by
Caching with VarnishCaching with Varnish
Caching with Varnishschoefmax
14K views29 slides

More Related Content

What's hot

Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server by
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu ServerForget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Serveraaroncouch
4.6K views23 slides
Varnish - PLNOG 4 by
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4Leszek Urbanski
3.6K views82 slides
Dockerizing WordPress by
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPressdotCloud
18.2K views20 slides
HBaseConEast2016: HBase on Docker with Clusterdock by
HBaseConEast2016: HBase on Docker with ClusterdockHBaseConEast2016: HBase on Docker with Clusterdock
HBaseConEast2016: HBase on Docker with ClusterdockMichael Stack
753 views20 slides
The secret life of a dispatcher (Adobe CQ AEM) by
The secret life of a dispatcher (Adobe CQ AEM)The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)Venugopal Gummadala
5.7K views17 slides
Roy foubister (hosting high traffic sites on a tight budget) by
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)WordCamp Cape Town
2.5K views29 slides

What's hot(20)

Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server by aaroncouch
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu ServerForget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
aaroncouch4.6K views
Dockerizing WordPress by dotCloud
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
dotCloud18.2K views
HBaseConEast2016: HBase on Docker with Clusterdock by Michael Stack
HBaseConEast2016: HBase on Docker with ClusterdockHBaseConEast2016: HBase on Docker with Clusterdock
HBaseConEast2016: HBase on Docker with Clusterdock
Michael Stack753 views
The secret life of a dispatcher (Adobe CQ AEM) by Venugopal Gummadala
The secret life of a dispatcher (Adobe CQ AEM)The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)
Venugopal Gummadala5.7K views
Roy foubister (hosting high traffic sites on a tight budget) by WordCamp Cape Town
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
WordCamp Cape Town2.5K views
Apache Performance Tuning: Scaling Up by Sander Temme
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
Sander Temme11.4K views
Magento 2 Workflows by Ryan Street
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 Workflows
Ryan Street4.7K views
Web agencies: An analysis of the OVH infrastructure to optimise your web proj... by OVHcloud
Web agencies: An analysis of the OVH infrastructure to optimise your web proj...Web agencies: An analysis of the OVH infrastructure to optimise your web proj...
Web agencies: An analysis of the OVH infrastructure to optimise your web proj...
OVHcloud345 views
Using memcache to improve php performance by Sudar Muthu
Using memcache to improve php performanceUsing memcache to improve php performance
Using memcache to improve php performance
Sudar Muthu4.2K views
Apache web server installation/configuration, Virtual Hosting by webhostingguy
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hosting
webhostingguy1.4K views
Web server installation_configuration_apache by Shaojie Yang
Web server installation_configuration_apacheWeb server installation_configuration_apache
Web server installation_configuration_apache
Shaojie Yang969 views
Develop with linux containers and docker by Fabio Fumarola
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
Fabio Fumarola1.4K views
Aem dispatcher – tips & tricks by Ashokkumar T A
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
Ashokkumar T A5.4K views
HBaseConEast2016: Practical Kerberos with Apache HBase by Michael Stack
HBaseConEast2016: Practical Kerberos with Apache HBaseHBaseConEast2016: Practical Kerberos with Apache HBase
HBaseConEast2016: Practical Kerberos with Apache HBase
Michael Stack1.6K views

Similar to Drupal, varnish, esi - Toulouse November 2

Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013 by
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
16.9K views63 slides
Using and scaling Rack and Rack-based middleware by
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
1.1K views38 slides
Apache Wizardry - Ohio Linux 2011 by
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Rich Bowen
4.4K views198 slides
Deploy Rails Application by Capistrano by
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
1.3K views18 slides
Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ... by
Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ...Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ...
Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ...Codemotion
951 views60 slides
DevOps Meetup ansible by
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansiblesriram_rajan
549 views42 slides

Similar to Drupal, varnish, esi - Toulouse November 2(20)

Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013 by Carlos Sanchez
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez16.9K views
Using and scaling Rack and Rack-based middleware by Alona Mekhovova
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
Alona Mekhovova1.1K views
Apache Wizardry - Ohio Linux 2011 by Rich Bowen
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
Rich Bowen4.4K views
Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ... by Codemotion
Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ...Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ...
Gianluca Arbezzano Wordpress: gestione delle installazioni e scalabilità con ...
Codemotion951 views
DevOps Meetup ansible by sriram_rajan
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
sriram_rajan549 views
Harmonious Development: Via Vagrant and Puppet by Achieve Internet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
Achieve Internet4.7K views
Continuous Delivery: The Next Frontier by Carlos Sanchez
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
Carlos Sanchez1.6K views
Cache all the things - A guide to caching Drupal by digital006
Cache all the things - A guide to caching DrupalCache all the things - A guide to caching Drupal
Cache all the things - A guide to caching Drupal
digital0063.5K views
Apache Cookbook - TekX Chicago 2010 by Rich Bowen
Apache Cookbook - TekX Chicago 2010Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010
Rich Bowen2.8K views
Drupal Performance - SerBenfiquista.com Case Study by hernanibf
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
hernanibf3K views
Why Managed Service Providers Should Embrace Container Technology by Sagi Brody
Why Managed Service Providers Should Embrace Container TechnologyWhy Managed Service Providers Should Embrace Container Technology
Why Managed Service Providers Should Embrace Container Technology
Sagi Brody2.1K views
MNPHP Scalable Architecture 101 - Feb 3 2011 by Mike Willbanks
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011
Mike Willbanks1K views
Introduction to Drupal - Installation, Anatomy, Terminologies by Gerald Villorente
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
Gerald Villorente1.1K views

More from Marcus Deglos

Vagrant crash course by
Vagrant crash courseVagrant crash course
Vagrant crash courseMarcus Deglos
6.2K views94 slides
Drupal haters gonna hate by
Drupal haters gonna hateDrupal haters gonna hate
Drupal haters gonna hateMarcus Deglos
3.9K views43 slides
With one click by
With one clickWith one click
With one clickMarcus Deglos
1.8K views29 slides
Panels rocks! by
Panels rocks!Panels rocks!
Panels rocks!Marcus Deglos
526 views22 slides
SSO To go by
SSO To goSSO To go
SSO To goMarcus Deglos
765 views17 slides
Where in the world by
Where in the worldWhere in the world
Where in the worldMarcus Deglos
904 views47 slides

More from Marcus Deglos(6)

Recently uploaded

Microsoft Power Platform.pptx by
Microsoft Power Platform.pptxMicrosoft Power Platform.pptx
Microsoft Power Platform.pptxUni Systems S.M.S.A.
52 views38 slides
AMAZON PRODUCT RESEARCH.pdf by
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdfJerikkLaureta
19 views13 slides
virtual reality.pptx by
virtual reality.pptxvirtual reality.pptx
virtual reality.pptxG036GaikwadSnehal
11 views15 slides
ChatGPT and AI for Web Developers by
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web DevelopersMaximiliano Firtman
187 views82 slides
PharoJS - Zürich Smalltalk Group Meetup November 2023 by
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
126 views17 slides
Lilypad @ Labweek, Istanbul, 2023.pdf by
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdfAlly339821
9 views45 slides

Recently uploaded(20)

AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta19 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi126 views
Lilypad @ Labweek, Istanbul, 2023.pdf by Ally339821
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdf
Ally3398219 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg16 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst476 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada126 views
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291616 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada135 views
From chaos to control: Managing migrations and Microsoft 365 with ShareGate! by sammart93
From chaos to control: Managing migrations and Microsoft 365 with ShareGate!From chaos to control: Managing migrations and Microsoft 365 with ShareGate!
From chaos to control: Managing migrations and Microsoft 365 with ShareGate!
sammart939 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10237 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker33 views

Drupal, varnish, esi - Toulouse November 2

  • 4. > Old faithful, serving sites since 1996. > Quick > Simple Apache
  • 5. Apache's model Web server
  • 6. Apache's model with PHP Web server PHP engine
  • 7. Do it with Drupal Web server DB index.php PHP engine
  • 8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html Example HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" version="XHTML+RDFa 1.0" dir="ltr"
 xmlns:content="http://purl.org/rss/1.0/modules/content/"
 xmlns:dc="http://purl.org/dc/terms/"
 xmlns:foaf="http://xmlns.com/foaf/0.1/"
 xmlns:og="http://ogp.me/ns#"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
 xmlns:sioc="http://rdfs.org/sioc/ns#"
 xmlns:sioct="http://rdfs.org/sioc/types#"
 xmlns:skos="http://www.w3.org/2004/02/skos/core#"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#">

<head profile="http://www.w3.org/1999/xhtml/vocab">
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="http://testbed.local/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
 <title>Welcome to Site-Install | Site-Install</title> HTML from homepage after running drushsi
  • 13. > Prepared in advance > Typically uses a build-script > Produces static pages > Quick > No complex behaviour > Boost module is an Baked example
  • 14. > Pages created on the fly > CMS or other complex dynamic system > Allows complex behaviour > Drupal does this > Slow Fried
  • 16. > Software package (daemon) for linux > Reverse proxy, such as Squid, Nginx and Zeus What is Varnish? > Cache
  • 17. How Varnish works GET /blog Host deglos.com User-AgentMozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0.1) Gecko/20100101 Firefox/8.0.1 Accept text/html,application/xhtml+xml,applic ation/xml;q=0.9,*/*;q=0.8 Varnish Drupal Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Accept-Charset ISO-8859-1,utf- 8;q=0.7,*;q=0.7 Connectionkeep-alive
  • 18. Varnish is slower If Varnish passes every request to Drupal – and acts just as a MITM – your site will be slower. Varnish Drupal
  • 19. Varnish needs to cache Varnish Drupal Cache
  • 20. Varnish + cache is quicker 10x faster (or more) Varnish Drupal Cache
  • 21. Personalisation is a problem Varnish Drupal Cache
  • 22. The Uncacheable Varnish Drupal Cache
  • 27. Example VCL: #This is a basic VCL configuration file for varnish. backend default { .host = "127.0.0.1"; .port = "80"; } sub vcl_fetch { unset obj.http.Cache-Control; unset obj.http.Expires; set obj.ttl = 86400s; }
  • 30. vcl.list telnet localhost6082 Trying ::1... Connected to localhost. Escape character is '^]'. vcl.list 200 23 active 1 boot
  • 31. help telnet localhost6082 Trying ::1... Connected to localhost. Escape character is '^]'. help 200 376 help [command] ping [timestamp] status start stop stats ...
  • 32. url.purge telnet localhost6082 Trying ::1... Connected to localhost. Escape character is '^]'. url.purge .* 200 0
  • 34. Setting up Varnish > Download varnish daemon debian: apt-get install varnish redhat:yum install varnish > Re-configure Apache to listen on port 8080 (or other non-standard port) > Configure Varnish to listen on port 80 > Configure Varnish VCL to connect to Apache > VCL tweaks (default does not cache Drupal)
  • 37. Serving ESIs Varnish Drupal Cache
  • 38. Serving ESIs Varnish Drupal Cache
  • 39. Serving ESIs <div id="nav-masthead" class="grid-12"> <ul> <li class="homepage active first active"> <a href="/home" class="active active">Drupal Homepage</a> </li> <li class="dashboard last"> <a href="/user/dashboard">Your Dashboard</a> </li> </ul> Varnish Drupal <div id="userinfo"> <a href="/user" title="View &amp; edit your user profile">Logged in as manarth</a> <a href="/logout">Log out</a> </div> </div><!-- /#nav-masthead --> Cache
  • 40. Serving ESIs <div id="nav-masthead" class="grid-12"> <ul> <li class="homepage active first active"> <a href="/home" class="active active">Drupal Homepage</a> </li> <li class="dashboard last"> <a href="/user/dashboard">Your Dashboard</a> </li> </ul> Varnish Drupal <esisrc="http://example.com/esi/userinfo" /> </div><!-- /#nav-masthead --> Cache
  • 41. Serving ESIs <div id="userinfo"> <a href="/user" title="View &amp; edit your user profile">Logged in as manarth</a> <a href="/logout">Log out</a> </div> Varnish Drupal Cache
  • 42. What do you need in order to do ESIs? > Replace personalisationwith ESI tags Theme-alters? > Provide backend hook_menuhandlers for each ESI tag > Ensure that Varnish is caching > Rule 35 applies
  • 52. Flickr Credits > Babbage engine http://www.flickr.com/photos/melgart/4444251 225 > Cookies http://www.flickr.com/photos/sabine01/24855 02578 > Frying wok http://www.flickr.com/photos/18403292@N00/ 3048993 > Varnish http://www.flickr.com/photos/dawniecakes/46 86467791

Editor's Notes

  1. Back, to the dawn of the internet, when email was in fidonet and 56k modems were all the rage.
  2. Add animation through the tubes.Dries makes requestGoes through internetHits serverHanded to apacheApache looks up from diskMight add some headersReturns the fileDodges the lolcat on the way back
  3. Add animation through the tubes.Dries makes requestGoes through internetHits serverHanded to apacheApache recognises it&apos;s .php and passes to ModPHP straight awayModPHP looks up from diskHands to lexical parserProcessesReturns the file to apacheDodges the lolcat on the way back
  4. Add animation through the tubes.Dries makes requestGoes through internetHits serverHanded to apacheApache processes .htaccess rulesEvery URL is index.phpPassed to ModPHP straight awayModPHP looks up from diskHands to lexical parserProcesses, invokes Drupal bootstrapReturns the file to apacheDodges the lolcat on the way back
  5. Benchmark:ApachePlain old PHP handler (no processing)Drupal
  6. Benchmark:ApachePlain old PHP handler (no processing)DrupalPHP parser adds 20%
  7. Refer to concepts such as baked vs fried
  8. Baked or fried?
  9. Prepared in advance No personalisation (more choc chips) Ready to eat
  10. One serving cooked at a time Wait a bit longer to eat Cooked freshPersonalised to taste
  11. - Looks at the hook_block information and uses appropriate cache rules – per user, etc.