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
Openminds Techtalk: Varnish
Search
Bernard Grymonpon
October 11, 2011
Technology
2
180
Openminds Techtalk: Varnish
Openminds techtalk about Varnish - Dutch video is at
http://vimeo.com/openminds
Bernard Grymonpon
October 11, 2011
Tweet
Share
More Decks by Bernard Grymonpon
See All by Bernard Grymonpon
Techtalk: beveiligde verbindingen
wonko
0
450
MySQL techtalk
wonko
0
540
Metrics & Dashboards
wonko
0
420
Varnish
wonko
0
90
Vagrant en Sneakers
wonko
0
560
Techtalk: DNS & domeinen
wonko
1
290
Arrrrcamp 2012: Testing Chef
wonko
1
350
New Relic Techtalk
wonko
1
670
DrupalCamp Ghent 2012
wonko
1
590
Other Decks in Technology
See All in Technology
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
760
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
690
心が動くエンジニアリング ── 私が夢中になる理由
16bitidol
0
100
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
0
170
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
For a Future-Friendly Web
brad_frost
175
9.4k
Making Projects Easy
brettharned
115
5.9k
The Cult of Friendly URLs
andyhume
78
6k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Gamification - CAS2011
davidbonilla
80
5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Ruby is Unlike a Banana
tanoku
97
11k
Transcript
Varnish voor webbouwers Openminds TechTalk 6 juli 2011 Tuesday 11
October 2011
SOFTWARE Tuesday 11 October 2011
Varnish • Noorse tabloid Verdens Gang - 1.0 in 2006
- 3.0 enkele dagen terug • Snelheidswinst site: 10x - 300x • caching HTTP reverse proxy Tuesday 11 October 2011
normaal Server Client Internetlijn Datacentrum Tuesday 11 October 2011
klassieke proxy Server Client Trage Internetlijn Proxy Datacentrum Client Client
Tuesday 11 October 2011
reverse proxy Server Proxy Snelle lijnen Datacentrum Client Client Client
Tuesday 11 October 2011
reverse proxy Server Proxy Snelle lijnen Datacentrum Client Client Client
Server Server Tuesday 11 October 2011
caching reverse proxy Server Caching Proxy Datacentrum Client Client Client
Server Server Tuesday 11 October 2011
Waarom? •Serverbelasting omlaag •Veel snellere site-ervaring •Veel meer hits/s afwerken
met zelfde hardware •Ademruimte voor serverhits Tuesday 11 October 2011
Tuesday 11 October 2011
Caching •Identieke aanvraag - identiek antwoord •We houden het volledige
antwoord bij •Headers •Data (HTML) Tuesday 11 October 2011
Identieke aanvraag Identiek antwoord Tuesday 11 October 2011
Aanvraag GET / HTTP/1.1 Host: www.openminds.be User-Agent: Mozilla/5.0 (Macintosh; Intel
Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en,en-us;q=0.7,nl-be;q=0.3 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive Cookie: __utma=121817557.1268321880.1308719392.1309764385.1309861948.8; __utmz=121817557.1308719392.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09 Og9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db25 0cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2Vkew Y7CFQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; __utmc=121817557; __utmb=121817557.2.10.1309861948 Tuesday 11 October 2011
Aanvraag GET / HTTP/1.1 Host: www.openminds.be User-Agent: Mozilla/5.0 (Macintosh; Intel
Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en,en-us;q=0.7,nl-be;q=0.3 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive Cookie: __utma=121817557.1268321880.1308719392.1309764385.1309861948.8; __utmz=121817557.1308719392.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09 Og9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db25 0cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2Vkew Y7CFQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; __utmc=121817557; __utmb=121817557.2.10.1309861948 Tuesday 11 October 2011
Aanvraag •Host •URI (pad, method/verb, version) •Cookies •Encoding / compressie
Tuesday 11 October 2011
Antwoord HTTP/1.1 200 OK Server: nginx/0.5.32 Date: Tue, 05 Jul
2011 10:52:36 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15 Etag: "25ec477310b3f81f097d5f6f3b5824f6" X-Rack-Cache: stale, invalid, store X-Content-Digest: af41dfcde5cfeaa55717261890560d56595be969 X-Runtime: 2559 Cache-Control: max-age=300, public Age: 21 Set-Cookie: _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09O g9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db250c m9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2VkewY7C FQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; path=/; HttpOnly Content-Length: 11565 Status: 200 X-server: pro-005 X-Proxy: fosfor Tuesday 11 October 2011
Wat cachen? •Statische content (images, css, js, ...) •Hoofdpagina’s /
hoofdpaden •Zoveel mogelijk •Versie per variatie bijhouden (encoding...) •GET/HEAD Tuesday 11 October 2011
Tuesday 11 October 2011
Wat niet cachen •admin/management secties •pagina’s die zich aanpassen aan
user (logged in, winkelmandje, profielen, ...) •404 / 500 / ... •POST/PUT/DELETE Tuesday 11 October 2011
Cookies •Sessie - antwoord niet cachen •Google - doet er
op zich niet toe •Variaties - antwoord wel cachebaar Tuesday 11 October 2011
Stel... •... dat de webapplicatie dit meegeeft •browser-cache hints worden
gestuurd •meestal fout Tuesday 11 October 2011
Cache-Control HTTP/1.1 200 OK Server: nginx/0.5.32 Date: Tue, 05 Jul
2011 10:52:36 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15 Etag: "25ec477310b3f81f097d5f6f3b5824f6" X-Rack-Cache: stale, invalid, store X-Content-Digest: af41dfcde5cfeaa55717261890560d56595be969 X-Runtime: 2559 Cache-Control: max-age=300, public Age: 21 Set-Cookie: _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09O g9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db250c m9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2VkewY7C FQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; path=/; HttpOnly Content-Length: 11565 Status: 200 X-server: pro-005 X-Proxy: fosfor Tuesday 11 October 2011
Cache hints •max-age - eenvoudig (HTTP 1.1) •expires - zeer
specifiek (HTTP 1.0) •“pragma: no-cache” •etags •... Tuesday 11 October 2011
Varnish manipuleert •Zowel aanvraag als antwoord •Strippen, herzetten, ... van
velden •Cookies manipuleren •Cache-timings Tuesday 11 October 2011
Cache timings •De duur dat Varnish het zelf bijhoudt (varnish
ttl) - bvb 24 uur •De duur dat een client het mag bijhouden (browser cache) - bvb 2 uur of 30 dagen Tuesday 11 October 2011
Een voorbeeld •Gewone, publieke site •Rails-applicatie met eigen CMS •Eenvoudige
VDS •100Mbps •Eenvoudige varnish config (cache-control was correct) Tuesday 11 October 2011
Tuesday 11 October 2011
1 second cache •Pollers •100 tot 10000 polls per seconde
•+/- timestamp terugsturen •zorgt voor 99 tot 9999 minder hits/s Tuesday 11 October 2011
1 second cache Tuesday 11 October 2011
Images •Hard forceren •Alle cookies strippen •Hogere cache-control zetten Tuesday
11 October 2011
Talen •Taal niet opslaan in sessie •Taal in cookie opslaan
(language=nl) •Wordt een variatie voor Varnish •Homepagina voor Nederlands •Homepagina voor Frans Tuesday 11 October 2011
Anonieme cookies •Drupal 6 •Symfony •CakePHP •Rails •... Tuesday 11
October 2011
Admin interfaces •Volledig namespaced (/admin/...) •Andere url (admin.openminds.be) •Sessie-cookie verwijderen
bij logout Tuesday 11 October 2011
Logged in users •Moeilijk! •Assets op andere hosts/url •Ajax ?
•Partial caching van Varnish (advanced) Tuesday 11 October 2011
There are only two hard things in Computer Science: cache
invalidation and naming things — Phil Karlton Tuesday 11 October 2011
Cache invalidation •Wat bij edit/put/post/... •eenvoudig: PURGE op juiste URL(s)
•control channel •Drupal module •Lacquer gem •Purged de browser niet !!! Tuesday 11 October 2011
Webbouwers •Anonieme cookies nodig? •Admin sectie duidelijk •Variaties aantoonbaar (language-cookie
bv) •Cache-control headers zijn belangrijk •Vooraf over nadenken Tuesday 11 October 2011
Kleine sites •Snelheid omhoog •Zijn meestal zeer statisch •Code mag
zelfs iets minder performant dan •Purge kan volledig zijn Tuesday 11 October 2011
Grote projecten •Performantie •Beschikbaarheid •Kosten drukken (minder hardware) •Cache invalidation
belangrijk Tuesday 11 October 2011
Opletten voor... •User-agent voor Mobile Device detection •Captcha (cookies voor
images?) •X-Forwarded-For Tuesday 11 October 2011
Varnish niet voor •Grote downloads •Volledig getrackte sites (cookies) Tuesday
11 October 2011
Varnish extra’s •Grace timeout •Meerdere backends - loadbalancing / failover
•Specifieke, partial caching Tuesday 11 October 2011
Uitrollen: dedicated •Eenvoudige opzet - laag voor webserver •Configuratie op
maat •Verregaande manipulaties mogelijk •Op maat, contacteer ons Tuesday 11 October 2011
Uitrollen: shared •Algemene configuratie nodig •Conservatieve configuratie •Minimale manipulatie mogelijk
•Openminds biedt het aan Tuesday 11 October 2011
Openminds varnish •Beta •Opt-in mechanisme •Gezonde defaults •IPv4 en IPv6
•Regels worden nog gecommuniceerd! Tuesday 11 October 2011
Q & A Tuesday 11 October 2011