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
500
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
78
Skalowanie aplikacji PHP
leafnode
1
430
Other Decks in Technology
See All in Technology
kaonavi Tech Night#1
kaonavi
0
160
AI時代のPlaywright活用(システムテストを自動化する ー 実行エンジンにPla ywrightを選んだ理由)
ynisqa1988
2
990
Type-safe IaC for Dart
coborinai
0
180
システム監視入門
grimoh
1
330
AWS環境のセキュリティ不安を解消した企業事例 ~よくある課題と対策を一挙公開~
asanoharuki
0
160
Webアプリ認証の全体像 / The Big Picture of Web App Authentication
kitano_yuichi
1
450
キャリアLT会#3
beli68
2
250
現場との対話から始める “作る前に問い直す”業務改善
mochico50
2
280
AmplifyHostingConstructからSSRフレームワークのためのホスティング設計を考察する/amplify-hosting-construct
fossamagna
1
310
インシデント事例と パッケージの全量解析に学ぶ ソフトウェアサプライチェーンの守り方 / supply-chain-attack-defense
flatt_security
0
990
AIコード生成×サプライチェーン攻撃 — PHPが直面する“二重の信頼問題
shinyasaita
0
470
Devsumi 2026 Summer 人もAIも使える共通基盤を事業の加速装置にする~デザインシステム運用に学ぶ組織レバレッジ~ 渡辺 凌央
legalontechnologies
PRO
1
300
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
GitHub's CSS Performance
jonrohan
1033
470k
The Curse of the Amulet
leimatthew05
2
13k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.1k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
360
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
420
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
240
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
410
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
490
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
190
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
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