Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Varnish to the Rescue
Search
Leszek Krupiński
April 11, 2014
Technology
140
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
More Decks by Leszek Krupiński
See All by Leszek Krupiński
So that the daemon won’t die
leafnode
2
410
Practical PHP7
leafnode
2
510
Dobrze posól swoje hasło
leafnode
0
120
Dobrze posól swoje hasło (z notatkami)
leafnode
0
110
PHPNG kontra HHVM
leafnode
0
130
PHPNG kontra HHVM (z notatkami)
leafnode
0
86
Ewolucja PHP: PHP 5.6, NG, PHP 7, HHVM
leafnode
2
310
Sculpin - Generowanie statycznych stron w PHP
leafnode
2
79
Skalowanie aplikacji PHP
leafnode
1
440
Other Decks in Technology
See All in Technology
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
150
「重なり」は迎える側がつくる ― 人もAIエージェントも歓迎するプロダクトエンジニアリング ―
go0517go
PRO
0
120
Claude Codeの体系的な理解と知識のフック
oikon48
10
6.5k
Point Cloud as a Foreign Language for Multi-modal Large Language Model
takmin
0
360
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.3k
Azure App Service / Container Apps の組み込み認証
kuniteru
0
140
振り返りこそエンジニアの本領
negima
0
130
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
590
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
1
310
V8コントリビュート超入門
riyaamemiya
0
110
20260903 Tokyo Jazug Night #62 | Azure エンジニアよ、 その環境は本当にセキュアか?
olivia_0707
1
460
Does an AI Watermark Survive Translation?
machinetranslation
0
520
Featured
See All Featured
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
4 Signs Your Business is Dying
shpigford
187
23k
ラッコキーワード サービス紹介資料
rakko
1
4.7M
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
850
Faster Mobile Websites
deanohume
310
32k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
400
Building Adaptive Systems
keathley
44
3.2k
30 Presentation Tips
portentint
PRO
1
380
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
320
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Site-Speed That Sticks
csswizardry
13
1.5k
Transcript
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