SlideShare a Scribd company logo
1 of 26
Varnish the Drupal Way
About me
• Boyan Borisov
• Team Leader @
Propeople
• boyanb@propeople.dk
• @boyan_borisov
• Skype: boian.borisov
• http://linkedin.com/in/
boyanborisov
What is Varnish?
• Reverse proxy cache server
• ... and more (load balancer, filter, director, ...)
• Open Source (BSD), commercially supported
• Typically in front of a LAMP stack
Why do we need Varnish?
• Believe or not Drupal is not very fast by
default ;)
• “Large Scale Drupal” is not only a sales phrase
but the present and the future of Drupal
• May be this is the best and fastest way to
achieve great performance results
Why do we need Varnish?
What does Varnish do?
What can be cached?
• Drupal pages for anonymous users
• Static content: images, js, css
• Other types of static or generated content
• Varnish stores a cache entry for each Host +
URL
What should NOT be cached in
Varnish?
• Responses to POST requests
• Responses with a Set-Cookie : header
• User-specific content (logged-in page
requests)
• Very large media files (> 100MB)
• Has a Cache-Control: no-cache header
When the cache will expire?
• Response header: Cache-Control: max-age=
300
• If no Cache-Control specified then Varnish
uses the Expires date, if specified
• If no Cache-Control or Expires header then
uses Varnish's default TTL which is 2 minutes
but could be changed
But wait… what about Drupal?
• Install varnish
• Install and configure the Drupal varnish module -
https://drupal.org/project/varnish
• Update the default Varnish VCL configuration
with a Drupal related one
– https://github.com/boyanborisov/varnish-for-drupal
– https://fourkitchens.atlassian.net/wiki/display/TECH/
Configure+Varnish+3+for+Drupal+7
– https://drupal.org/node/1427486
• And don’t forget to enable the caching for the
anonymous users
Varnish state machine
VCL – Varnish Configuration Language
• Extend and modify Varnish cache policies
• Add behaviors during each phase of delivery
• Each Request is processed separately and
independently
• States are isolated but are related
• Return statements exit one state and start
another
• VCL defaults are ALWAYS appended below your
own VCL
Other VCL features
• Add/remove/change HTTP headers
• Redirects based on request parameters
• Rewrite requests
• Retry failed requests
• Saint and Grace: Deliver cached content when backend
is unresponsive
• ACLs: Network-address filtering
• Request filtering ESI: Separate cache entries and
separate cache policies for each part of a document
• Inline C code
VCL – Subroutines – breaking it down
• vcl_init – VCL is loaded, no request yet; VMOD initialization
• vcl_recv – Beginning of request, req is in scope
• vcl_pipe – Client & backend data passed unaltered
• vcl_pass – Request goes to backend and not cached
• vcl_hash – call hash_data to add to the hash
• vcl_hit – called on request found in the cache
• vcl_miss – called on request not found in the cache
• vcl_fetch – called on document retrieved from backend
• vcl_deliver – called prior to delivery of cached object
• vcl_error – called on errors
Directors
• Directors allow you to talk to the backend servers
• Directors are a glorified reverse proxy
– Allows for certain types of load balancing
– Allows for talking to a cluster
“A director is a logical group of backend servers
clustered together for redundancy. The basic role of
the director is to let Varnish choose a backend
server amongst several so if one is down another
can be used.”
Varnish realtime tools
• varnishstat – realtime status and performance
metrics
• varnishhist – live frequency plot of response
times
• varnishtop – live list of hottest files
• varnishlog – analyze incoming HTTP headers
• Varnish CLI – live admin capabilities
Drupal specifics
• Drupal emits Vary – Cookie,Accept-Encoding
• Cookie – Avoids cache collisions between
users Accept-Encoding : maintain separate
cache entries for compressed content (gzip,
deflate) vs. uncompressed content
ESI – Edge Side Includes
• ESI is a small markup language much like SSI
(server side includes) to include fragments (or
dynamic content for that matter)
• Think of it as replacing regions inside of a page as
if you were using XHR (AJAX) but single threaded.
• Three Statements can be utilized
– esi:include – Include a page
– esi:remove – Remove content
– <!-- esi --> - ESI disabled, execute normally
How to cache authenticated users?
• Authcache - https://drupal.org/project/authcache
“Authcache saves the final rendered HTML of a page to serve visitors.
A separate cache is created for each user role as defined by the
administrator, so some roles can be excluded if necessary.
Authcache places priority on serving pages to the visitor as fast as
possible. After a page is loaded by the browser, a second HTTP request
may be performed via Ajax. This initiates a lightweight
DRUPAL_BOOTSTRAP_SESSION that allows SQL queries to be executed
, and returns any user-customized data to the page (such as form
tokens or default values on a contact form).”
How to cache authenticated users?
How to cache authenticated users?
How to cache authenticated users?
“Production graphs from intranet solution
developed by Propeople ( around 50 000 users ).
Web CPU usage below 1% and varnish hit ratio >
80%. Varnish & Propeople rocks  ”
Rumen Yordanov
Open Source Department manager @Propeople
Cache invalidation
• Drupal invalidate the whole Varnish cache on
node/comment/etc save by default
• Expire module is a solution -
https://drupal.org/project/expire
Purging and banning
• Purging – a purge is what happens when you pick out
an object from the cache and discard it along with its
variants. Usually a purge is invoked through HTTP with
the method PURGE.
• Banning – You can think of bans as a sort of a filter on
objects already in the cache. You ban certain content
from being served from your cache. You can ban
content based on any metadata we have. A ban will
only work on objects already in the cache, it does not
prevent new content from entering the cache or being
served.
Demo
Questions?

More Related Content

What's hot

Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpSander Temme
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and dockerFabio Fumarola
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with PuppetKris Buytaert
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & LuaKit Chan
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyLeif Hedstrom
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORSEWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORSRob Tweed
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
 
Integrated Cache on Netscaler
Integrated Cache on NetscalerIntegrated Cache on Netscaler
Integrated Cache on NetscalerMark Hillick
 
Speed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisSpeed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisRicard Clau
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
How To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesHow To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesSeveralnines
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStackAustralian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStackMatt Ray
 

What's hot (20)

Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & Lua
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a Proxy
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORSEWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
 
ReplacingSquidWithATS
ReplacingSquidWithATSReplacingSquidWithATS
ReplacingSquidWithATS
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 
How Flipkart scales PHP
How Flipkart scales PHPHow Flipkart scales PHP
How Flipkart scales PHP
 
Integrated Cache on Netscaler
Integrated Cache on NetscalerIntegrated Cache on Netscaler
Integrated Cache on Netscaler
 
Speed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisSpeed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with Redis
 
Caching
CachingCaching
Caching
 
Memcached
MemcachedMemcached
Memcached
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Cassandra as Memcache
Cassandra as MemcacheCassandra as Memcache
Cassandra as Memcache
 
Cobbler, Func and Puppet: Tools for Large Scale Environments
Cobbler, Func and Puppet: Tools for Large Scale EnvironmentsCobbler, Func and Puppet: Tools for Large Scale Environments
Cobbler, Func and Puppet: Tools for Large Scale Environments
 
How To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesHow To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - Slides
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStackAustralian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStack
 

Similar to Varnish intro

Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkBryan Ollendyke
 
High Performance Drupal Sites
High Performance Drupal SitesHigh Performance Drupal Sites
High Performance Drupal SitesAbayomi Ayoola
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesExove
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 SystemsDavid Newman
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalChapter Three
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilitycherryhillco
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtNick Santamaria
 
Drupal is not your Website
Drupal is not your Website Drupal is not your Website
Drupal is not your Website Phase2
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experiencereeder29
 
Michael stack -the state of apache h base
Michael stack -the state of apache h baseMichael stack -the state of apache h base
Michael stack -the state of apache h basehdhappy001
 
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2Richard Esplin
 
Do you lose sleep at night?
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?Nathan Van Gheem
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an OverviewMatt Weaver
 
Drupal Is Not Your Web Site
Drupal Is Not Your Web SiteDrupal Is Not Your Web Site
Drupal Is Not Your Web SitePhase2
 

Similar to Varnish intro (20)

Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 
High Performance Drupal Sites
High Performance Drupal SitesHigh Performance Drupal Sites
High Performance Drupal Sites
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
 
Drupal is not your Website
Drupal is not your Website Drupal is not your Website
Drupal is not your Website
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
 
Michael stack -the state of apache h base
Michael stack -the state of apache h baseMichael stack -the state of apache h base
Michael stack -the state of apache h base
 
72d5drupal
72d5drupal72d5drupal
72d5drupal
 
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
Alfresco Tech Talk Live (Episode 70): Customizing Alfresco Share 4.2
 
Do you lose sleep at night?
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an Overview
 
Drupal Is Not Your Web Site
Drupal Is Not Your Web SiteDrupal Is Not Your Web Site
Drupal Is Not Your Web Site
 
Velocity - Edge UG
Velocity - Edge UGVelocity - Edge UG
Velocity - Edge UG
 

More from Boyan Borisov

DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve 1 milli...
DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve  1 milli...DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve  1 milli...
DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve 1 milli...Boyan Borisov
 
Drupal Layout Builder Ecosystem
Drupal Layout Builder Ecosystem Drupal Layout Builder Ecosystem
Drupal Layout Builder Ecosystem Boyan Borisov
 
Drupal in the cloud - Serverless and more
Drupal in the cloud - Serverless and moreDrupal in the cloud - Serverless and more
Drupal in the cloud - Serverless and moreBoyan Borisov
 
Drupal in the cloud - Serverless and more
 Drupal in the cloud - Serverless and more Drupal in the cloud - Serverless and more
Drupal in the cloud - Serverless and moreBoyan Borisov
 
Better editorial experience in Drupal 7
Better editorial experience in Drupal 7Better editorial experience in Drupal 7
Better editorial experience in Drupal 7Boyan Borisov
 
Large Scale Drupal - Behind the Scenes
Large Scale Drupal - Behind the ScenesLarge Scale Drupal - Behind the Scenes
Large Scale Drupal - Behind the ScenesBoyan Borisov
 
Better editorial experience in Drupal 7
Better editorial experience in Drupal 7Better editorial experience in Drupal 7
Better editorial experience in Drupal 7Boyan Borisov
 
Putting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your lifePutting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your lifeBoyan Borisov
 

More from Boyan Borisov (8)

DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve 1 milli...
DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve  1 milli...DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve  1 milli...
DrupalCon Europe 2020 - Drupal loves NoSQL databases or how to serve 1 milli...
 
Drupal Layout Builder Ecosystem
Drupal Layout Builder Ecosystem Drupal Layout Builder Ecosystem
Drupal Layout Builder Ecosystem
 
Drupal in the cloud - Serverless and more
Drupal in the cloud - Serverless and moreDrupal in the cloud - Serverless and more
Drupal in the cloud - Serverless and more
 
Drupal in the cloud - Serverless and more
 Drupal in the cloud - Serverless and more Drupal in the cloud - Serverless and more
Drupal in the cloud - Serverless and more
 
Better editorial experience in Drupal 7
Better editorial experience in Drupal 7Better editorial experience in Drupal 7
Better editorial experience in Drupal 7
 
Large Scale Drupal - Behind the Scenes
Large Scale Drupal - Behind the ScenesLarge Scale Drupal - Behind the Scenes
Large Scale Drupal - Behind the Scenes
 
Better editorial experience in Drupal 7
Better editorial experience in Drupal 7Better editorial experience in Drupal 7
Better editorial experience in Drupal 7
 
Putting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your lifePutting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your life
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Varnish intro

  • 2. About me • Boyan Borisov • Team Leader @ Propeople • boyanb@propeople.dk • @boyan_borisov • Skype: boian.borisov • http://linkedin.com/in/ boyanborisov
  • 3. What is Varnish? • Reverse proxy cache server • ... and more (load balancer, filter, director, ...) • Open Source (BSD), commercially supported • Typically in front of a LAMP stack
  • 4. Why do we need Varnish? • Believe or not Drupal is not very fast by default ;) • “Large Scale Drupal” is not only a sales phrase but the present and the future of Drupal • May be this is the best and fastest way to achieve great performance results
  • 5. Why do we need Varnish?
  • 7. What can be cached? • Drupal pages for anonymous users • Static content: images, js, css • Other types of static or generated content • Varnish stores a cache entry for each Host + URL
  • 8. What should NOT be cached in Varnish? • Responses to POST requests • Responses with a Set-Cookie : header • User-specific content (logged-in page requests) • Very large media files (> 100MB) • Has a Cache-Control: no-cache header
  • 9. When the cache will expire? • Response header: Cache-Control: max-age= 300 • If no Cache-Control specified then Varnish uses the Expires date, if specified • If no Cache-Control or Expires header then uses Varnish's default TTL which is 2 minutes but could be changed
  • 10. But wait… what about Drupal? • Install varnish • Install and configure the Drupal varnish module - https://drupal.org/project/varnish • Update the default Varnish VCL configuration with a Drupal related one – https://github.com/boyanborisov/varnish-for-drupal – https://fourkitchens.atlassian.net/wiki/display/TECH/ Configure+Varnish+3+for+Drupal+7 – https://drupal.org/node/1427486 • And don’t forget to enable the caching for the anonymous users
  • 12. VCL – Varnish Configuration Language • Extend and modify Varnish cache policies • Add behaviors during each phase of delivery • Each Request is processed separately and independently • States are isolated but are related • Return statements exit one state and start another • VCL defaults are ALWAYS appended below your own VCL
  • 13. Other VCL features • Add/remove/change HTTP headers • Redirects based on request parameters • Rewrite requests • Retry failed requests • Saint and Grace: Deliver cached content when backend is unresponsive • ACLs: Network-address filtering • Request filtering ESI: Separate cache entries and separate cache policies for each part of a document • Inline C code
  • 14. VCL – Subroutines – breaking it down • vcl_init – VCL is loaded, no request yet; VMOD initialization • vcl_recv – Beginning of request, req is in scope • vcl_pipe – Client & backend data passed unaltered • vcl_pass – Request goes to backend and not cached • vcl_hash – call hash_data to add to the hash • vcl_hit – called on request found in the cache • vcl_miss – called on request not found in the cache • vcl_fetch – called on document retrieved from backend • vcl_deliver – called prior to delivery of cached object • vcl_error – called on errors
  • 15. Directors • Directors allow you to talk to the backend servers • Directors are a glorified reverse proxy – Allows for certain types of load balancing – Allows for talking to a cluster “A director is a logical group of backend servers clustered together for redundancy. The basic role of the director is to let Varnish choose a backend server amongst several so if one is down another can be used.”
  • 16. Varnish realtime tools • varnishstat – realtime status and performance metrics • varnishhist – live frequency plot of response times • varnishtop – live list of hottest files • varnishlog – analyze incoming HTTP headers • Varnish CLI – live admin capabilities
  • 17. Drupal specifics • Drupal emits Vary – Cookie,Accept-Encoding • Cookie – Avoids cache collisions between users Accept-Encoding : maintain separate cache entries for compressed content (gzip, deflate) vs. uncompressed content
  • 18. ESI – Edge Side Includes • ESI is a small markup language much like SSI (server side includes) to include fragments (or dynamic content for that matter) • Think of it as replacing regions inside of a page as if you were using XHR (AJAX) but single threaded. • Three Statements can be utilized – esi:include – Include a page – esi:remove – Remove content – <!-- esi --> - ESI disabled, execute normally
  • 19. How to cache authenticated users? • Authcache - https://drupal.org/project/authcache “Authcache saves the final rendered HTML of a page to serve visitors. A separate cache is created for each user role as defined by the administrator, so some roles can be excluded if necessary. Authcache places priority on serving pages to the visitor as fast as possible. After a page is loaded by the browser, a second HTTP request may be performed via Ajax. This initiates a lightweight DRUPAL_BOOTSTRAP_SESSION that allows SQL queries to be executed , and returns any user-customized data to the page (such as form tokens or default values on a contact form).”
  • 20. How to cache authenticated users?
  • 21. How to cache authenticated users?
  • 22. How to cache authenticated users? “Production graphs from intranet solution developed by Propeople ( around 50 000 users ). Web CPU usage below 1% and varnish hit ratio > 80%. Varnish & Propeople rocks  ” Rumen Yordanov Open Source Department manager @Propeople
  • 23. Cache invalidation • Drupal invalidate the whole Varnish cache on node/comment/etc save by default • Expire module is a solution - https://drupal.org/project/expire
  • 24. Purging and banning • Purging – a purge is what happens when you pick out an object from the cache and discard it along with its variants. Usually a purge is invoked through HTTP with the method PURGE. • Banning – You can think of bans as a sort of a filter on objects already in the cache. You ban certain content from being served from your cache. You can ban content based on any metadata we have. A ban will only work on objects already in the cache, it does not prevent new content from entering the cache or being served.
  • 25. Demo