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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Bernard Grymonpon
October 11, 2011
Technology
210
2
Share
Openminds Techtalk: Varnish
Openminds techtalk about Varnish - Dutch video is at
http://vimeo.com/openminds
Bernard Grymonpon
October 11, 2011
More Decks by Bernard Grymonpon
See All by Bernard Grymonpon
Techtalk: beveiligde verbindingen
wonko
0
460
MySQL techtalk
wonko
0
590
Metrics & Dashboards
wonko
0
450
Varnish
wonko
0
140
Vagrant en Sneakers
wonko
0
570
Techtalk: DNS & domeinen
wonko
1
310
Arrrrcamp 2012: Testing Chef
wonko
1
480
New Relic Techtalk
wonko
1
720
DrupalCamp Ghent 2012
wonko
1
640
Other Decks in Technology
See All in Technology
ポスター発表&デモと総括 / Poster Presentations & Demonstrations and Summary
ks91
PRO
0
180
AI時代から振り返るTerraform drift運用の歴史 / AI Age Reflections on the History of Terraform Drift Operations
aeonpeople
2
630
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
Unlocking the Apps
pimterry
0
150
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
950
Spring AI × MCP 入門〜AIエージェントへのツール公開、境界設計から始める最小構成 〜
yuyamiyamoto
0
200
組織の中で自分を経営する技術
shoota
0
230
オンコールの負荷軽減のためのBits Assistant 活用方法 / How to Use Bits Assistant to Reduce the Workload on On-Call Staff
sms_tech
1
370
Claude Codeですべての日常業務を爆速化しよう!
minorun365
PRO
17
16k
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
140
Mastering Ruby Box
tagomoris
3
130
大学生が本気でDatabricksを活用してDiscordサークルをデータ駆動させてみた
phantomjuju
1
310
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
3
380
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
44k
Building AI with AI
inesmontani
PRO
1
1k
Abbi's Birthday
coloredviolet
2
7.8k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
600
BBQ
matthewcrist
89
10k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
170
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
370
Odyssey Design
rkendrick25
PRO
2
660
Tell your own story through comics
letsgokoyo
1
940
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
130
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