SlideShare a Scribd company logo
1 of 37
Download to read offline
APACHE SLING & FRIENDS TECH MEETUP
BERLIN, 23-25 SEPTEMBER 2013
Become happier by using Varnish Cache
Stefan Maurer
Senior Software Engineer, Namics AG
Agenda
adaptTo() 2013 2
 Varnish Cache at a glance
 Use Cases and Architectures
 Limitations and Pitfalls
Varnish Cache at a glance
adaptTo() 2013 3
 Reverse Proxy Cache
 1.0.0 in 2006
 Current version is 3.0.4
 Free under BSD License
 Available for various Linux Distributions,
Max OS X, Open Solaris, Solaris 10,
FreeBSD and Windows (with Cygwin)
Varnish Cache at a glance
adaptTo() 2013 4
 Designed as HTTP accelerator – not
more, not less
 “Varnish is a modern program, designed
and written for modern operating systems”
https://www.varnish-cache.org/trac/wiki/VarnishFeatures
 Storage
 malloc or file
 Load balancing
 ESI (subset)
Varnish Cache at a glance
adaptTo() 2013 5
 Process architecture
 Management process and child process
 Configuration change without restart
Source: www.varnish-software.com/static/book/Tuning.html
Varnish Cache at a glance
adaptTo() 2013 6
 Configuration
 Startup parameters
 Varnish Configuration Language (VCL)
sub vcl_fetch {
if (req.url ~ ".jpg$") {
set beresp.ttl = 60s;
}
}
Varnish Cache at a glance
adaptTo() 2013 Source: www.varnish-software.com/static/book/VCL_Basics.html
Varnish Cache at a glance
adaptTo() 2013 8
 Logging
 Logs to shared memory
 Separate application for display and write
back
Agenda
adaptTo() 2013 9
 Varnish Cache at a glance
 Use Cases and Architectures
 Limitations and Pitfalls
Use Cases and Architectures
adaptTo() 2013 10
 Use case 1: Static resources
 Use case 2: REST API calls
 Use case 3: Full website
Use Case 1: Static Resources
adaptTo() 2013 11
 Use Case
 Cache resources like CSS / JS / static
images “forever”
 Benefit with Varnish
 Internal network traffic decreases
significant
 Do not bore backend systems ;-)
 Solution
 Cookie-less domain sc.customer.com
served by Varnish
CQ5 Publisher
Dispatcher
www.customer.com
Varnish Cache
sc.customer.com
Use Case 1: Static Resources
adaptTo() 2013 12
 Architecture Sample 1
Browser
Varnish Cache
sc.customer.com
Dispatcher
www.customer.com
Load Balancer
CQ5 Publisher
Use Case 1: Static Resources
adaptTo() 2013 13
 Architecture Sample 2
Browser
Varnish Cache
sc.customer.com
Dispatcher
www.customer.com
Load Balancer
www.customer.com
CQ5 Publisher
Dispatcher
www.customer.com
CQ5 Publisher
Use Case 1: Static Resources
adaptTo() 2013 14
 Why not directly connect Varnish with
CQ5 Publisher?
 Possible. But requires configuration for
restricted paths like /system/console
 Changes in CQ
 Load resources from static domain with a
timestamp:
<script
type="text/javascript"
src="http://sc.customer.com/etc/designs/customer/clientlib.201309231000.js"
></script>
<img src="http://sc.customer.com/content/dam/logo.201309231000.png" />
Use Case 1: Static Resources
adaptTo() 2013 15
backend default {
.host = "dispatcher-hostname";
.port = "80";
}
sub vcl_recv {
if (req.url !~ "^/etc/designs/" && req.url !~ "^/content/dam/"){
error 405 "Not allowed.";
}
unset req.http.cookie;
}
sub vcl_fetch {
unset beresp.http.set-cookie;
unset beresp.http.expires;
unset beresp.http.Etag;
set beresp.http.Cache-Control = "max-age=86400";
set beresp.ttl = 4w;
set beresp.http.magicmarker = "1";
}
sub vcl_deliver {
if (resp.http.magicmarker) {
unset resp.http.magicmarker;
set resp.http.age = "0";
}
}
Use Cases and Architectures
adaptTo() 2013 16
 Use case 1: Static resources
 Use case 2: REST API calls
 Use case 3: Full website
Use Case 2: REST API Calls
adaptTo() 2013 17
 Use Case
 Cache requests to backend APIs
 Benefit with Varnish
 Reduce load on backend systems
 Reduce response time
 Handle backend downtime
 Custom time to life for each backend
 Solution
 Call backend through Varnish Cache
Use Case 2: REST API Calls
adaptTo() 2013 18
 Sample: Yahoo Finance API
 http://finance.yahoo.com/d/quotes.csv?s=ADBE&f=snd1l1c1p2
 Last trade date, price, change and percents
 But: has limit of requests/day
 CQ Publisher calls Varnish with prefix
“finance”
 http://varnish/finance/d/quotes.csv?s=ADBE&f=snd1l1c1p2
 Varnish executes API Call and caches
the response for one hour
Use Case 2: REST API Calls
adaptTo() 2013 19
 Architecture
Varnish Cache
Yahoo Finance API
CQ5 Publisher
Backend 2..n
Use Case 2: REST API Calls
adaptTo() 2013 20
backend yahoofinance {
.host = "finance.yahoo.com";
.port = "80";
}
sub vcl_recv {
if (req.url ~ "^/finance") {
set req.backend = yahoofinance;
set req.url = regsub(req.url, "^/finance", "");
unset req.http.cookie;
}
}
sub vcl_fetch {
if(req.backend == yahoofinance) {
set beresp.ttl = 1h;
unset beresp.http.set-cookie;
return(deliver);
}
}
Use Cases and Architectures
adaptTo() 2013 21
 Use case 1: Static resources
 Use case 2: REST API calls
 Use case 3: Full website
Use Case 3: Full Website
adaptTo() 2013 22
 Use Case
 Cache generated HTML and related
resources
 Benefit with Varnish
 Reduce load on backend systems
 Reduce response time
 Granular cache invalidation
CQ5 Publisher
Dispatcher
Use Case 3: Full Website
adaptTo() 2013 23
 Architecture Sample 1
Browser
Varnish Cache
Dispatcher
CQ5 Publisher
CQ5 Publisher
Varnish Cache
Use Case 3: Full Website
Dispatcher
adaptTo() 2013 24
 Architecture Sample 2
Browser
Varnish Cache
Load Balancer
CQ5 Publisher
Dispatcher
Use Case 3: Full Website
adaptTo() 2013 25
 Cache Invalidation
Short TTL (1 minute) Long TTL (1 month)
Frequently called pages + +
Seldom called pages - +
Instant invalidation - +
Low complexity + -
Use Case 3: Full Website
adaptTo() 2013 26
 Excludes from cache
sub vcl_recv {
if (req.url ~ "?"
|| req.url ~ "/cug_") {
return(pass);
}
}
sub vcl_fetch {
if (beresp.http.Dispatcher ~ "no-cache"
|| beresp.http.cache-control ~ "(no-cache|private)"
|| beresp.http.pragma ~ "no-cache") {
set beresp.ttl = 0s;
}
else {
set beresp.ttl = 4w;
}
}
Use Case 3: Full Website
adaptTo() 2013 28
 Invalidate a page with “smart bans”
acl purgers {
"127.0.0.1";
"192.168.0.0"/24;
}
sub vcl_recv {
if (req.http.X-Purge-URL) {
if (!client.ip ~ purgers) {
error 405 "Method not allowed";
}
ban("obj.http.x-url == " + req.http.X-Purge-URL);
error 200 "Banned URL";
}
}
sub vcl_fetch {
set beresp.http.x-url = req.url;
}
Use Case 3: Full Website
adaptTo() 2013 29
 Invalidate from CQ Publisher with
Modification Listener
 Modify: /content/customer/en/news/adaptto
 Risky: Purge only page and sub pages
/content/customer/en/news/adaptto.*
 Safe: Purge whole language tree
/content/customer/en.*
Agenda
adaptTo() 2013 30
 Varnish Cache at a glance
 Use Cases and Architectures
 Limitations and Pitfalls
Limitations and Pitfalls
adaptTo() 2013 31
 SSL termination
 Problem
Varnish has no SSL termination
 Justification
Varnish source code: 80’000 lines of code
OpenSSL: 340’000 lines of code
 Solution
Use another tier in front of Varnish (nginx,
pond, …)
Limitations and Pitfalls
adaptTo() 2013 32
 Avoid “double purge”
 Assumed situation
2 Publisher and 1 Varnish
 Problem
Modification listener is executed on both
Publishers  2 purge requests
 Solution
Define “master” publisher and handle
failover
Limitations and Pitfalls
adaptTo() 2013 33
 Proxy
 Assumed situation
- Varnish is used to cache REST API Calls
- Your customer force to use proxy for all
external requests
 Problem
Varnish has no configuration for backend
through proxy
 Solution
Set proxy as backend and tweak URL
Limitations and Pitfalls
adaptTo() 2013 34
 Proxy solution
backend proxy {
.host = "corporate-proxy-hostname";
.port = "8080";
}
sub vcl_recv {
set req.backend = proxy;
set req.http.X-Forwarded-For = client.ip;
set req.http.host = "dispatcher-hostname";
set req.http.port = 80;
set req.url = "http://" + req.http.host + ":" +
req.http.port + req.url;
}
adaptTo() 2013 35
Thank you
Namics
adaptTo() 2012 36
 5 Locations in Germany and Switzerland
Frankfurt, Hamburg, München, Zürich, St. Gallen
 Many interesting projects with CQ5 and
other technologies
 400 + 1 (?) Employees
www.namics.com/jobs
Resources and Further Links
adaptTo() 2013 37
 https://www.varnish-
cache.org/trac/wiki/VCLExampleLongerCaching
 https://www.varnish-software.com/static/book/Tuning.html
 https://www.varnish-
software.com/static/book/_images/vcl.png
 http://blog.namics.com/2013/01/www-zh-ch-ist-50x-schneller-
und-stabiler.html
 http://blog.namics.com/2010/12/varnish-cache.html
Variable availability in VCL
adaptTo() 2012 38

More Related Content

What's hot

Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisationgrooverdan
 
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...Continuent
 
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
 
Wido den Hollander - 10 ways to break your Ceph cluster
Wido den Hollander - 10 ways to break your Ceph clusterWido den Hollander - 10 ways to break your Ceph cluster
Wido den Hollander - 10 ways to break your Ceph clusterShapeBlue
 
Packaging Strategy for Community Openstack and Implementation Reference | Hoj...
Packaging Strategy for Community Openstack and Implementation Reference | Hoj...Packaging Strategy for Community Openstack and Implementation Reference | Hoj...
Packaging Strategy for Community Openstack and Implementation Reference | Hoj...Vietnam Open Infrastructure User Group
 
Eventually, Scylla Chooses Consistency
Eventually, Scylla Chooses ConsistencyEventually, Scylla Chooses Consistency
Eventually, Scylla Chooses ConsistencyScyllaDB
 
Performance Benchmarking of Clouds Evaluating OpenStack
Performance Benchmarking of Clouds                Evaluating OpenStackPerformance Benchmarking of Clouds                Evaluating OpenStack
Performance Benchmarking of Clouds Evaluating OpenStackPradeep Kumar
 
How to monitor your micro-service with Prometheus?
How to monitor your micro-service with Prometheus?How to monitor your micro-service with Prometheus?
How to monitor your micro-service with Prometheus?Wojciech Barczyński
 
Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0
Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0
Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0Continuent
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsCloudera, Inc.
 
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Ludovico Caldara
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758davidblum
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterSeveralnines
 
Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015Stephen Gordon
 
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...Vietnam Open Infrastructure User Group
 
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWDEWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWDRob Tweed
 

What's hot (19)

re7jweiss
re7jweissre7jweiss
re7jweiss
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
 
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
 
Wido den Hollander - 10 ways to break your Ceph cluster
Wido den Hollander - 10 ways to break your Ceph clusterWido den Hollander - 10 ways to break your Ceph cluster
Wido den Hollander - 10 ways to break your Ceph cluster
 
Packaging Strategy for Community Openstack and Implementation Reference | Hoj...
Packaging Strategy for Community Openstack and Implementation Reference | Hoj...Packaging Strategy for Community Openstack and Implementation Reference | Hoj...
Packaging Strategy for Community Openstack and Implementation Reference | Hoj...
 
Velocity 2010 - ATS
Velocity 2010 - ATSVelocity 2010 - ATS
Velocity 2010 - ATS
 
Eventually, Scylla Chooses Consistency
Eventually, Scylla Chooses ConsistencyEventually, Scylla Chooses Consistency
Eventually, Scylla Chooses Consistency
 
Performance Benchmarking of Clouds Evaluating OpenStack
Performance Benchmarking of Clouds                Evaluating OpenStackPerformance Benchmarking of Clouds                Evaluating OpenStack
Performance Benchmarking of Clouds Evaluating OpenStack
 
How to monitor your micro-service with Prometheus?
How to monitor your micro-service with Prometheus?How to monitor your micro-service with Prometheus?
How to monitor your micro-service with Prometheus?
 
Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0
Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0
Real-Time Data Loading from MySQL to Hadoop with New Tungsten Replicator 3.0
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to Coprocessors
 
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera Cluster
 
Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015
 
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
 
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWDEWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
 
overbooking.ppt
overbooking.pptoverbooking.ppt
overbooking.ppt
 

Similar to Become Happier by using Varnish Cache

Emerging storage-trends-for-containers
Emerging storage-trends-for-containersEmerging storage-trends-for-containers
Emerging storage-trends-for-containerskiran mova
 
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...Acquia
 
Improving the Accumulo User Experience
 Improving the Accumulo User Experience Improving the Accumulo User Experience
Improving the Accumulo User ExperienceAccumulo Summit
 
Microsoft Windows Server AppFabric
Microsoft Windows Server AppFabricMicrosoft Windows Server AppFabric
Microsoft Windows Server AppFabricMark Ginnebaugh
 
Four Ways to Improve ASP .NET Performance and Scalability
 Four Ways to Improve ASP .NET Performance and Scalability Four Ways to Improve ASP .NET Performance and Scalability
Four Ways to Improve ASP .NET Performance and ScalabilityAlachisoft
 
gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”Ruggero Citton
 
Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfAmazon Web Services
 
Cloud-native Java EE-volution
Cloud-native Java EE-volutionCloud-native Java EE-volution
Cloud-native Java EE-volutionQAware GmbH
 
Cloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfCloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfLeah Cole
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streamingphanleson
 
ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006Rupesh Kumar
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nirmal Mehta
 
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Amazon Web Services
 
Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfAmazon Web Services
 
Where is my cache architectural patterns for caching microservices by example
Where is my cache architectural patterns for caching microservices by exampleWhere is my cache architectural patterns for caching microservices by example
Where is my cache architectural patterns for caching microservices by exampleRafał Leszko
 
Containerize Legacy .NET Framework Web Apps for Cloud Migration
Containerize Legacy .NET Framework Web Apps for Cloud MigrationContainerize Legacy .NET Framework Web Apps for Cloud Migration
Containerize Legacy .NET Framework Web Apps for Cloud MigrationAmazon Web Services
 
H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API OverviewRaymond Peck
 
H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API OverviewSri Ambati
 
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Ovadiah Myrgorod
 
How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018Antonios Giannopoulos
 

Similar to Become Happier by using Varnish Cache (20)

Emerging storage-trends-for-containers
Emerging storage-trends-for-containersEmerging storage-trends-for-containers
Emerging storage-trends-for-containers
 
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
 
Improving the Accumulo User Experience
 Improving the Accumulo User Experience Improving the Accumulo User Experience
Improving the Accumulo User Experience
 
Microsoft Windows Server AppFabric
Microsoft Windows Server AppFabricMicrosoft Windows Server AppFabric
Microsoft Windows Server AppFabric
 
Four Ways to Improve ASP .NET Performance and Scalability
 Four Ways to Improve ASP .NET Performance and Scalability Four Ways to Improve ASP .NET Performance and Scalability
Four Ways to Improve ASP .NET Performance and Scalability
 
gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”
 
Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdf
 
Cloud-native Java EE-volution
Cloud-native Java EE-volutionCloud-native Java EE-volution
Cloud-native Java EE-volution
 
Cloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfCloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdf
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
 
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
 
Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdf
 
Where is my cache architectural patterns for caching microservices by example
Where is my cache architectural patterns for caching microservices by exampleWhere is my cache architectural patterns for caching microservices by example
Where is my cache architectural patterns for caching microservices by example
 
Containerize Legacy .NET Framework Web Apps for Cloud Migration
Containerize Legacy .NET Framework Web Apps for Cloud MigrationContainerize Legacy .NET Framework Web Apps for Cloud Migration
Containerize Legacy .NET Framework Web Apps for Cloud Migration
 
H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API Overview
 
H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API Overview
 
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
 
How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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 ...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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...
 

Become Happier by using Varnish Cache

  • 1. APACHE SLING & FRIENDS TECH MEETUP BERLIN, 23-25 SEPTEMBER 2013 Become happier by using Varnish Cache Stefan Maurer Senior Software Engineer, Namics AG
  • 2. Agenda adaptTo() 2013 2  Varnish Cache at a glance  Use Cases and Architectures  Limitations and Pitfalls
  • 3. Varnish Cache at a glance adaptTo() 2013 3  Reverse Proxy Cache  1.0.0 in 2006  Current version is 3.0.4  Free under BSD License  Available for various Linux Distributions, Max OS X, Open Solaris, Solaris 10, FreeBSD and Windows (with Cygwin)
  • 4. Varnish Cache at a glance adaptTo() 2013 4  Designed as HTTP accelerator – not more, not less  “Varnish is a modern program, designed and written for modern operating systems” https://www.varnish-cache.org/trac/wiki/VarnishFeatures  Storage  malloc or file  Load balancing  ESI (subset)
  • 5. Varnish Cache at a glance adaptTo() 2013 5  Process architecture  Management process and child process  Configuration change without restart Source: www.varnish-software.com/static/book/Tuning.html
  • 6. Varnish Cache at a glance adaptTo() 2013 6  Configuration  Startup parameters  Varnish Configuration Language (VCL) sub vcl_fetch { if (req.url ~ ".jpg$") { set beresp.ttl = 60s; } }
  • 7. Varnish Cache at a glance adaptTo() 2013 Source: www.varnish-software.com/static/book/VCL_Basics.html
  • 8. Varnish Cache at a glance adaptTo() 2013 8  Logging  Logs to shared memory  Separate application for display and write back
  • 9. Agenda adaptTo() 2013 9  Varnish Cache at a glance  Use Cases and Architectures  Limitations and Pitfalls
  • 10. Use Cases and Architectures adaptTo() 2013 10  Use case 1: Static resources  Use case 2: REST API calls  Use case 3: Full website
  • 11. Use Case 1: Static Resources adaptTo() 2013 11  Use Case  Cache resources like CSS / JS / static images “forever”  Benefit with Varnish  Internal network traffic decreases significant  Do not bore backend systems ;-)  Solution  Cookie-less domain sc.customer.com served by Varnish
  • 12. CQ5 Publisher Dispatcher www.customer.com Varnish Cache sc.customer.com Use Case 1: Static Resources adaptTo() 2013 12  Architecture Sample 1 Browser Varnish Cache sc.customer.com Dispatcher www.customer.com Load Balancer CQ5 Publisher
  • 13. Use Case 1: Static Resources adaptTo() 2013 13  Architecture Sample 2 Browser Varnish Cache sc.customer.com Dispatcher www.customer.com Load Balancer www.customer.com CQ5 Publisher Dispatcher www.customer.com CQ5 Publisher
  • 14. Use Case 1: Static Resources adaptTo() 2013 14  Why not directly connect Varnish with CQ5 Publisher?  Possible. But requires configuration for restricted paths like /system/console  Changes in CQ  Load resources from static domain with a timestamp: <script type="text/javascript" src="http://sc.customer.com/etc/designs/customer/clientlib.201309231000.js" ></script> <img src="http://sc.customer.com/content/dam/logo.201309231000.png" />
  • 15. Use Case 1: Static Resources adaptTo() 2013 15 backend default { .host = "dispatcher-hostname"; .port = "80"; } sub vcl_recv { if (req.url !~ "^/etc/designs/" && req.url !~ "^/content/dam/"){ error 405 "Not allowed."; } unset req.http.cookie; } sub vcl_fetch { unset beresp.http.set-cookie; unset beresp.http.expires; unset beresp.http.Etag; set beresp.http.Cache-Control = "max-age=86400"; set beresp.ttl = 4w; set beresp.http.magicmarker = "1"; } sub vcl_deliver { if (resp.http.magicmarker) { unset resp.http.magicmarker; set resp.http.age = "0"; } }
  • 16. Use Cases and Architectures adaptTo() 2013 16  Use case 1: Static resources  Use case 2: REST API calls  Use case 3: Full website
  • 17. Use Case 2: REST API Calls adaptTo() 2013 17  Use Case  Cache requests to backend APIs  Benefit with Varnish  Reduce load on backend systems  Reduce response time  Handle backend downtime  Custom time to life for each backend  Solution  Call backend through Varnish Cache
  • 18. Use Case 2: REST API Calls adaptTo() 2013 18  Sample: Yahoo Finance API  http://finance.yahoo.com/d/quotes.csv?s=ADBE&f=snd1l1c1p2  Last trade date, price, change and percents  But: has limit of requests/day  CQ Publisher calls Varnish with prefix “finance”  http://varnish/finance/d/quotes.csv?s=ADBE&f=snd1l1c1p2  Varnish executes API Call and caches the response for one hour
  • 19. Use Case 2: REST API Calls adaptTo() 2013 19  Architecture Varnish Cache Yahoo Finance API CQ5 Publisher Backend 2..n
  • 20. Use Case 2: REST API Calls adaptTo() 2013 20 backend yahoofinance { .host = "finance.yahoo.com"; .port = "80"; } sub vcl_recv { if (req.url ~ "^/finance") { set req.backend = yahoofinance; set req.url = regsub(req.url, "^/finance", ""); unset req.http.cookie; } } sub vcl_fetch { if(req.backend == yahoofinance) { set beresp.ttl = 1h; unset beresp.http.set-cookie; return(deliver); } }
  • 21. Use Cases and Architectures adaptTo() 2013 21  Use case 1: Static resources  Use case 2: REST API calls  Use case 3: Full website
  • 22. Use Case 3: Full Website adaptTo() 2013 22  Use Case  Cache generated HTML and related resources  Benefit with Varnish  Reduce load on backend systems  Reduce response time  Granular cache invalidation
  • 23. CQ5 Publisher Dispatcher Use Case 3: Full Website adaptTo() 2013 23  Architecture Sample 1 Browser Varnish Cache Dispatcher CQ5 Publisher
  • 24. CQ5 Publisher Varnish Cache Use Case 3: Full Website Dispatcher adaptTo() 2013 24  Architecture Sample 2 Browser Varnish Cache Load Balancer CQ5 Publisher Dispatcher
  • 25. Use Case 3: Full Website adaptTo() 2013 25  Cache Invalidation Short TTL (1 minute) Long TTL (1 month) Frequently called pages + + Seldom called pages - + Instant invalidation - + Low complexity + -
  • 26. Use Case 3: Full Website adaptTo() 2013 26  Excludes from cache sub vcl_recv { if (req.url ~ "?" || req.url ~ "/cug_") { return(pass); } } sub vcl_fetch { if (beresp.http.Dispatcher ~ "no-cache" || beresp.http.cache-control ~ "(no-cache|private)" || beresp.http.pragma ~ "no-cache") { set beresp.ttl = 0s; } else { set beresp.ttl = 4w; } }
  • 27. Use Case 3: Full Website adaptTo() 2013 28  Invalidate a page with “smart bans” acl purgers { "127.0.0.1"; "192.168.0.0"/24; } sub vcl_recv { if (req.http.X-Purge-URL) { if (!client.ip ~ purgers) { error 405 "Method not allowed"; } ban("obj.http.x-url == " + req.http.X-Purge-URL); error 200 "Banned URL"; } } sub vcl_fetch { set beresp.http.x-url = req.url; }
  • 28. Use Case 3: Full Website adaptTo() 2013 29  Invalidate from CQ Publisher with Modification Listener  Modify: /content/customer/en/news/adaptto  Risky: Purge only page and sub pages /content/customer/en/news/adaptto.*  Safe: Purge whole language tree /content/customer/en.*
  • 29. Agenda adaptTo() 2013 30  Varnish Cache at a glance  Use Cases and Architectures  Limitations and Pitfalls
  • 30. Limitations and Pitfalls adaptTo() 2013 31  SSL termination  Problem Varnish has no SSL termination  Justification Varnish source code: 80’000 lines of code OpenSSL: 340’000 lines of code  Solution Use another tier in front of Varnish (nginx, pond, …)
  • 31. Limitations and Pitfalls adaptTo() 2013 32  Avoid “double purge”  Assumed situation 2 Publisher and 1 Varnish  Problem Modification listener is executed on both Publishers  2 purge requests  Solution Define “master” publisher and handle failover
  • 32. Limitations and Pitfalls adaptTo() 2013 33  Proxy  Assumed situation - Varnish is used to cache REST API Calls - Your customer force to use proxy for all external requests  Problem Varnish has no configuration for backend through proxy  Solution Set proxy as backend and tweak URL
  • 33. Limitations and Pitfalls adaptTo() 2013 34  Proxy solution backend proxy { .host = "corporate-proxy-hostname"; .port = "8080"; } sub vcl_recv { set req.backend = proxy; set req.http.X-Forwarded-For = client.ip; set req.http.host = "dispatcher-hostname"; set req.http.port = 80; set req.url = "http://" + req.http.host + ":" + req.http.port + req.url; }
  • 35. Namics adaptTo() 2012 36  5 Locations in Germany and Switzerland Frankfurt, Hamburg, München, Zürich, St. Gallen  Many interesting projects with CQ5 and other technologies  400 + 1 (?) Employees www.namics.com/jobs
  • 36. Resources and Further Links adaptTo() 2013 37  https://www.varnish- cache.org/trac/wiki/VCLExampleLongerCaching  https://www.varnish-software.com/static/book/Tuning.html  https://www.varnish- software.com/static/book/_images/vcl.png  http://blog.namics.com/2013/01/www-zh-ch-ist-50x-schneller- und-stabiler.html  http://blog.namics.com/2010/12/varnish-cache.html
  • 37. Variable availability in VCL adaptTo() 2012 38