Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Varnish to the Rescue
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Leszek Krupiński
April 11, 2014
Technology
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Varnish to the Rescue
Introduction to Varnish. Basics & pitfalls. Presented at techfusion.io
Leszek Krupiński
April 11, 2014
Transcript
109 slides
Varnish to the rescue Leszek Krupiński
@leafnode PHPers Manual Consultant Architect
intro
web 1. User 2. Browser 3. Server
user is impatient
fast!
100ms
1s = -11% Page Views -16% User Satisfaction -7% Conversion
1-5s ! 32% consumers lost
(2012) average: 2.45s
Optimize application
• Frameworks • Limits • Time-consuming operations • Cost
Maybe it’s not needed?
Cache!
Many levels, many solutions
But… my site is very dynamic!
1s TTL
From 20 rq/s to 1 rq/s in single apt-get install
Fresh content takes most hits
Varnish The Web Accelerator
None
None
None
Architecture
Works with the kernel not against it
mmap, threads, epoll, kqueue
Backends: memory, file
If it fits in memory, use memory
Works on HTTP headers
Cache-control, If-Modified-Since, Expires, Pragma, If-None-Match, Etag, Vary, Age
Varnish uses language both browser and backend know
In-memory logs
75 000 rq/s at TMECC 143 000 rq/s at Redpill-Linpro
Do I need a lot of memory?
Nope
Fresh content takes most hits
Take that, slashdot effect!
Configuration
Lots of possibilities
Unfortunately, lots of possibilities
Varnish Configuration Language
Compiled directly to C
Hook-like configuration
vcl_fetch vcl_recv vcl_hit vcl_miss vcl_hash vcl_pass vcl_deliver vcl_error
None
restart
Objects req, bereq, resp, beresp, obj
Defaults
vcl_recv
None
None
None
vcl_hash
None
VMods
throttle, cookie, shield, redis, memcached, curl, url code, redirect…
Varnish: load balancer failover system
None
Directors
Default: random
Round-robin, client, hash, dns
Health check
None
Saint mode
Grace mode
Two hard things
Invalidate cache
Ban list Efficient way to invalidate cache
Over HTTP
Use PURGE header
None
None
None
Real life issues
Cookies
Varnish does not cache when cookies are involved
Ignore cookies
None
Pick cookies
None
Pick URLs
None
Redirects
POST
PHP sessions
CURL VMod
None
None
PHP + memcached
None
mobile detection
None
mobile detection II
None
VMod: DeviceAtlas Mobile Detection
Cache “one-time” data
Example: dynamic image resizing
1B pictures 10 sizes
apache + moddims
Fresh content takes most hits
Different TTL for different parts?
ESI!
None
None
Testing?
jQuery plugin
Just in! Varnish 4.0
Log query language, background fetch, byte counters, security improvements
http://speakerdeck.com/leafnode
More Decks by Leszek Krupiński
See All by Leszek Krupiński
So that the daemon won’t die
leafnode
2
420
Practical PHP7
leafnode
2
520
Dobrze posól swoje hasło
leafnode
0
130
Dobrze posól swoje hasło (z notatkami)
leafnode
0
120
PHPNG kontra HHVM
leafnode
0
130
PHPNG kontra HHVM (z notatkami)
leafnode
0
92
Ewolucja PHP: PHP 5.6, NG, PHP 7, HHVM
leafnode
2
320
Sculpin - Generowanie statycznych stron w PHP
leafnode
2
85
Skalowanie aplikacji PHP
leafnode
1
440
Other Decks in Technology
See All in Technology
生成AI時代のIAMのマニアックな話
takuros
6
3k
TSKaigi Sendai 2026 - tsgo時代のTypeScript Playgroundはどう動くか
teamlab
PRO
0
120
顧客合意を取りながら進めるAWSコスト削減の実践
optim
0
160
Bots in Kiro Crew (One point of contact for ongoing work) | Kiro: Zero to Hero 12
inariku
PRO
1
120
Frontier Teams — Amazon は AI で「開発のやり方」をどう変えたのか
kmotohas
0
130
Reticulum, le réseau cypherpunk dont vous avez besoin !
rlifchitz
0
130
Agent Harnessはどう作る?事例から学ぶAI Agentの設計思想
sergicalsix
0
260
大江戸Ruby会議でデータベース クライアントの話をするのは 間違っているだろうか
yahonda
1
120
Ebitengine製iOSアプリ公開ボタンを押す会
eiei114
0
120
サボる子はいねぇがー!AgentCoreハーネスの脆弱性に学ぶ、エージェントの入力バリデーション
iwamot
PRO
5
320
Gifu WordPress Meetup #200 に向けて、私たちには何ができるだろうか?/ 2026-11-07 Gifu WordPress Meetup
torounit
0
250
DBTS2026 盛り上がってますか!?Databricksが実現するAI時代のデータ基盤
akuwano
1
200
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.9k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
Six Lessons from altMBA
skipperchong
29
4.6k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
470
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Amusing Abliteration
ianozsvald
1
390
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
KATA
mclloyd
PRO
35
16k
Being A Developer After 40
akosma
PRO
92
590k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
880