Sie sind auf Seite 1von 53

HTTP cache

or

Ink by the barrel.


or

Enough about Johannes Gutenberg, let's talk about Karl Georg Ferdinand Gilke.
Poul Henning Ka!" #"hk$Free%&'.org(

111 Ty"ogra"hy) *ulti"le Fonts, Hy"henation, +igatures ,c -se"ll checking an o"tional e.tra./

0*&

*ulti!edia) &caling, 0ro""ing, Ga!!a correction -1/

Production) 2e"lication 'eli3ery

0ontent 0reation)
4eeds di3erse in"ut !ethods)
Te.t Editors, I!age scaling5cro""ing, File i!"ort 6ilters, Feeds...

Fle.ible +ayout5Ty"ogra"hy tools


78&I78G, &e!antic *arku", 0&&

0ontent cross re6erencing 9 e."ensi3e database looku"s)


Other articles about Paris Hilton

0o!"osition rules can be co!"le.)


No airline ads, if crash present in headline

:ser Generated 0ontent


'iscussions, galleries, "ersonal 3ie;s, chats etc.

0ontent Production)
2e"eated re"roduction o6 !aster co"y

It ;as "rinted on a !onster a Heidelberg. 8ou can s!ell the ;eight) T;o tons, ;ithout the ink.

(Catch me if you can)

Karl Georg Ferdinand Gilke's <=<> in3ention) he !ing 'oes one thing) *o3e "a"er, reliably , 6ast.

htt")55;;;.youtube.co!5;atch139b+G:<Pba?Es

The @arnish Ele3ator Pitch)


@arnish deli3ers content 6ast , reliably ... reduces the load on your 0*& database ... chea" hard;are does <AAB kreC5s ... can assist in content co!"osition ... can 6i. stu"id !istakes, 6ast ... is Free , D"en &ource &o6t;are ... has co!!ercial su""ort

Photo) *ichael Feistel

7hat you get...

...7hat you "ay 6or

The ;ebsite @G.no is one o6 4or;ays largest in ter!s o6 tra66ic. 0lassical ne;s site) ra"idly changing contents in a slo; 0*& syste!. <> &Cuid caches used as accelerators. :nha""y ;ith "er6or!ance and stability.

*ulti!edia ar! o6 4or3egian ne;s"a"er @erdens Gang

&lo; res"onse Terrible "eak handling

&igni6icant loss

&Cuid <> ser3ers

@arnish E ser3ers

&tarting 6ro! scratch, setting goals)


@arnish is only a HTTP accelerator. %etter con6iguration. %etter !anage!ent. -*uch/ 6aster. 0ontent !anage!ent 6ocused 6eature set

2F0>F<F cast list


G HTTP Gccelerator is not a HTTP cache.
0aching "olicy can be tailored to 0*& syste! and site "olicies. 2F0>F<F co!"liance as origin ser3er. 0an ne3er cache "er user data

7eb bro;sers

0an so!eti!es cache "er user data 0*& syste!

$ # # # # # # #

cat /etc/foobar.conf copied from example.conf /svend 19870104 updated to new version /knud 19941231 various changes /valdemar 19960523 DON'T MESS WITH THIS!!!

# The manual has the details. HDXHSVVaCS=0 # Dimensionality of chosen of space allocation_base=3.1418f(21.4e-ij) # overflow method (0-7) [default=7] overflow_method=8

acl_set= { 1 2 3 4 6 7 21 } invert_acls=server acl_reset = { 3 !8 }

@0+ @arnish 0on6iguration +anguage


sub vcl_recv { if (req.url ~ (\.\.|\.exe)) { error(999, Bugger off.); } if (client.i ~ e!itor_i s) { set req."tt .x#c$s % no#st&ts; return( &ss); } if (req.url ~ \.(' g| ng|gif|css)() { unset req."tt .coo)ie; unset req."tt .&ut"entic&te; set req.b&c)en! % st&tic_b&c)en!; } if (req.url %% "otstor*."$tl) { set req.url % "otstor*."t$l); } }

7hy @0+ rocks)


0o!"iled to binary5shlib 3ia 0 code 2uns 6ull s"eed 8ou can ha3e !ulti"le @0+'s loaded at the sa!e ti!e &;itch bet;een the! ;ithout restart Instantaneous Gllo;s you to do anything you !ight 6ancy Inline 0 code, 'nu66 said. *odules5shlib ;ill !ake it easier -E.A 6eature/

sub vcl_recv { if (client.ip == varnish1) { set req.backend = usa; } else { set req.backend = england; } } @arnishH> Ger!any %ackend :&G @arnishH< England

*anaging @arnish
0o!!and +ine Inter6ace 6or real ti!e control *anage!ent57orker "rocess s"lit) *anager -re/starts ;orker Gllo;s "ri3ilege se"aration 0ontains !ultithreading to ;orker "rocess

@arnish architecture
0luster 0ontroller 0!d+ine "anager 0!d+ine 0hildProc*gt @0+ co!"iler 0+I inter6ace 7eb inter6ace 0*& inter6ace &*& inter6ace Para!s5Grgs InitialiIation 7atchdog Cacher 0!d+ine &torage +og5&tats Gcce"t5herder %ackend 7orker threads Gri! 2ea"er Hashing log;riter stats ad hoc &hared *e!ory

Dne binary "rogra!

0 co!"iler

&hared obJect

0+I !anage!ent
$ telnet localhost 81 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. param.show 200 675 default_ttl 120 [seconds] thread_pools 5 [pools] thread_pool_max 1500 [threads] thread_pool_min 1 [threads] thread_pool_timeout 120 [seconds] overflow_max 100 [%] http_workspace 8192 [bytes] sess_timeout 5 [seconds] pipe_timeout 60 [seconds] send_timeout 600 [seconds] auto_restart on [bool] [...]

0+I !anage!ent
param.show overflow_max 200 330 overflow_max 100 [%] Default is 100 Limit on overflow queue length in percent of thread_pool_max parameter. NB: We don't know yet if it is a good idea to change this parameter. Caution advised.

Per6or!ance and s"eed


Progra! 6or "er6or!ance 6ro! day one :se !odern 6eatures) @irtual *e!ory send6ile->/, acce"tK6ilters->/, kCueue->/ -and e3ery other trick in the book/

0P:

2G*

'I&K

%us

4ot your dads co!"uter any!ore)


2G* 1

'I&K 1

0P: 1

...and besides, the o"erating syste! 3irtualiIes all o6 this

0P:s50ores 0aches

The @irtual Page 0ache


6or!erly kno;n as 2G*

DbJect storage
high 2TT

Per6or!ance Pricelist

char L" B9 MN strlen-"/N !e!c"y-", C, l/N +ocking &yste! 0all 0onte.t &;itch I5D 'isk Gccess File o"eration 'irectory o"eration

0P:

<AA,AAA,AAA5s

*e!ory

Protection

*echanical

MA5s

0lassical logging is horribly e."ensi3e)


Filesyste! o"eration, called once. FILE *flog; flog = fopen(/var/log/mylog, a); [...] fprintf(flog, %s Something went wrong with %s\n, timestamp(), foo2str(object)); fflush(flog); 'isk I5D, called < !io ti!es

< O A.A<As B <,AAA,AAA L A.AA<s 9 <F !inutes

+ogging to shared !e!ory is al!ost 6ree)


char *logp, *loge; fd = open(...); logp = mmap(..., size); loge = logp + size; Filesyste! o"s, called once.

*e!ory and arith!etic, < !io calls

[...] logp[1] = LOG_ERROR; logp[2] = sprintf(logp + 3, Something went bad with %s, foo2str(obj)); logp[3 + logp[2]] = LOG_END; logp[0] = LOG_ENTRY; logp += 3 + logp[2];

> O A.A<As B <,AAA,AAA L .AAAA<s 9 <A seconds

E?P*bit5s

<QR0P:

7here does !y tra66ic co!e 6ro! 1


$ varnishtop -i rxheader -I Referer 33913.74 4730.72 925.62 510.10 434.37 349.55 344.66 324.06 297.25 263.82 242.55 Referer: Referer: Referer: Referer: Referer: Referer: Referer: Referer: Referer: Referer: Referer:

http://www.vg.no/ http://vg.no/ http://www.vg.no http://www.vg.no/pub/vgart.hbs?art http://www.vg.no/export/Transact/m http://www.vg.no/pub/vgart.hbs?art http://www.vg.no/pub/vgart.hbs?art http://www.vg.no/export/Transact/t http://www.nettby.no/user/ http://www.vg.no/sport/fotball/ http://www.vg.no/pub/vgart.hbs?art

@arnishto"-</ S log6ile to" "rogra! 7hat is !y !ost "o"ular :2+ 1 $ varnishtop -i rxurl
1304.86 989.08 495.05 491.01 490.05 480.08 468.12 352.66 317.75 306.79 298.84 292.84 280.94 279.84 /tmv11.js /sistenytt.html /include/global/art.js /css/hoved.css /gfk/ann/n.gif /gfk/ann/ng.gif /gfk/front/tipsvg.png /css/ufront.css /t.gif /gfk/plu2.gif /css/front.css /gfk/min2.gif /css/blog.css /

@arnishhist-</ 2es"onse ti!e histogra! 0ache Hits

0ache *isses

2eal ti!e statistics 3ia shared !e!ory


16:23:13 Hitrate ratio: Hitrate avg: 17772105 130213161 129898315 85043 227180 313630 439 54 6196 1656 3222 2258 65685 65686 9 0.9986 435.55 3623.22 3617.23 0.00 4.99 4.99 0.00 0.00 1.00 -24.97 0.00 -51.95 5.99 5.99 9 0.9986 9 0.9986 Client connections accepted Client requests received Cache hits Cache hits for pass Cache misses Backend connections initiated Backend connections recyles Backend connections unused N struct srcaddr N active struct srcaddr N struct sess_mem N struct sess N struct object N struct objecthead

301.26 2207.26 2201.93 1.44 3.85 5.32 0.01 0.00 0.11 0.03 0.05 0.04 1.11 1.11

Content Management Features:


Instant action purges (regexp or exact match) TTL/Caching policy control in VCL Load/Situation mitigation in VCL eader !ashing Vary "dge#Side#Includes ("SI)

Purges) 0ache e3iction based on e.act criteria Dnly through htt" transaction -9 cache hit/ 0an take all @ary) 3ersions o6 obJect. %ans)

4%) @arnish E.A Ter!inology

0ache hit "re3ention based on loose criteria ban req.url ~ .*royal.*naked.* 0+I or htt" transaction

Gll the other stu66 you can do in @0+


TT+ control cache5"ass5"i"e decision :2+ re;rites header ;ashing IP based access control 'o& "re3ention &"ider dieting !odKsecurity like screening ,c ,c.

Gnd i6 @0+ can not do it 1


Inline 0 code) sub vcl_recv { C{ syslog(LOG_INFO, "Trouble: %u, foo); }C } In E.A also) !odules in the 6or! o6 shared libraries.

"dge#Side#Includes ($"SI$)
)er#user )age Sca**old+ uncached (pass) Index TTL & ' hour %rticle TTL & ' month Top ( Stories TTL& 'min %d (pass) Feature TTL & 'd

<html> <H1>Hello Samuel B. Nobody</H1> [...] <esi include src=right_index.html> [...] <esi include src=article_1723.html> [...]

%ackend
TT+9<h
<H2>Index of toda <TABLE>[...]</TAB

TT+9EAs

@arnish
<html> <H1>Hello Samuel B. Nobody</H1> [...] <H2>Index of todays top stories</H2> <TABLE>[...]</TABLE> [...] <H2>Nobel peace price to software gen <H3>Server-rooms world-wide silent af [...]

<H2>Nobel peace pric <H3>Server-rooms wor

TT+9E<d

TT+9EAs

0lient

Gnd i6 I had !ore ti!e I ;ould also !ention)


2ound 2obin, 2ando!, 0lient , Hash backend directors %ackend Health "olling, grace !ode, saint !ode *odular storage , hash , ;aiter code GPIs +ib3arnisha"i.a library 6or stats5log5cli access I"3F su""ort on all net;ork connections G0+'s are co!"iled to 0 code too 9 3ery 6ast P&K security on 0+I connection Pri3ilege se"aration5dro" -!anager5;orker "rocess/ 7ritten entirely in 0, only FPkloc -incl. JE!alloc/ 0ache hit 9 Q syste! calls -ty") <M EATs/ Gl!ost <AR o6 source lines are asserts ?>.ER o6 a""ro. MAkloc co3ered by <?= test cases %uiltin use6ul "anic5backtrace 6or!atter 7hy !arines.co! sent e!ail saying 8ou sa3ed our ass

varnish (,-rnsh) n. 1. a. % paint containing /...0 tr.,. varnished+ varnishing+ varnishes 1. To co,er 1ith ,arnish. 2. To gi,e a smooth and glossy *inish to. 3. To gi,e a decepti,ely attracti,e appearance to2 gloss o,er.

Commercial support: Varnish#So*t1are.com

3e*erence 4S: Free5S6+ Linux )ac7ages a,aila8le: 9es: )orta8le to: %ny reasona8le )4SI;

Das könnte Ihnen auch gefallen